Sayfayı Yazdır | Pencereyi Kapat

TCL UNİT

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Clomosy ile değişken kullanımı
Forum Tanımlaması: TRObject dili ile değişken tanımlaması ve ekranda gösterme
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=1210
Tarih: 21 Ekim 2025 Saat 23:10
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: TCL UNİT
Mesajı Yazan: Gökçe ulusoy
Konu: TCL UNİT
Mesaj Tarihi: 21 Ekim 2025 Saat 09:09
var
  Form1 :TclForm;
  PnlMain, PnlEntry : TclProPanel;
  BtnLogin,BtnSignUp :TCLProButton;
  EdtUName, EdtUPassword : TclProEdit;
  Unit1:TCLUnit;

void GoToMainPage;
{
  Unit1.UnitName='Mainpage'
  Unit1.CallerForm=Form1;
  Unit1.Run;
}


void GetUserLogin(AUserName,AUserPassword);
{
  try
    
    Clomosy.DBSQLServerQuery.SQL.Text =
      'SELECT * FROM Users WHERE UserName = :UserName AND UserPassword = :UserPassword';
    
    Clomosy.DBSQLServerQuery.ParamByName('UserName').Value= AUserName;
    Clomosy.DBSQLServerQuery.ParamByName('UserPassword').Value= AUserPassword;
    Clomosy.DBSQLServerQuery.ExecSQL;
    Clomosy.DBSQLServerQuery.Connection.Commit;
    
    if (not Clomosy.DBSQLServerQuery.Eof)
        {
          ShowMessage('Login successful.');
          GoToMainPage;
        }
        else
          ShowMessage(' Login failed.');
          
  except
    ShowMessage('004: Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
  }
}

void GetUserRegistration(AUserName,AUserPassword);
{
  try
    Clomosy.DBSQLServerQuery.Sql.Text = '
    INSERT INTO Users (UserName, UserPassword) VALUES ('+QuotedStr(AUserName)+', '+QuotedStr(AUserPassword)+')';
    Clomosy.DBSQLServerQuery.Open;
    ShowMessage('User registered.');
  
  except
    ShowMessage('003: Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
  }
}

void GetUserControl;
 var
   clickedBtn:TClProButton;
{
  clickedBtn = TClProButton(Form1.Clsender); 

  if((EdtUName.Text <>'' ) && (EdtUPassword.Text <>'' ))
  {
    if(clickedBtn.clTagStr == 'SignUp')
      GetUserRegistration(EdtUName.Text,EdtUPassword.Text);
    else if (clickedBtn.clTagStr == 'Login')
      GetUserLogin(EdtUName.Text,EdtUPassword.Text);
  
  EdtUName.Text = '';
  EdtUPassword.Text = '';
    
  }
  else ShowMessage('Do not leave username and password blank.');
}
  
  void SqlserverConnectionCreateTable;
  var
    TableExists: Boolean;
  {
    try
      Clomosy.DBSQLServerConnect('SQL Server', 'DESKTOP-2AGN5H8\ATIKER', 'sa', '1', 'Gökyar',1433);
 
      // Check if the table exists
      Clomosy.DBSQLServerQuery.Sql.Text='SELECT * FROM sys.tables WHERE name = ''Users''';

      Clomosy.DBSQLServerQuery.Open;
      
      // Check the results
      TableExists = not Clomosy.DBSQLServerQuery.Eof;
      
      // Create the table if it does not exist
      if not (TableExists)
      {
        Clomosy.DBSQLServerQuery.Sql.Text = 'CREATE TABLE Users(
        userID INTEGER PRIMARY KEY AUTOINCREMENT,
        UserName TEXT ,
        UserPassword TEXT )';
        Clomosy.DBSQLServerQuery.Open;
        
        ShowMessage('Table successfully added to the database!');
        
        try
          Clomosy.DBSQLServerQuery.Sql.Text = '
          INSERT INTO Users (UserName, UserPassword) VALUES (''ömer'', ''123456'');
          INSERT INTO Users (UserName, UserPassword) VALUES (''leyla'', ''456789'');';
          Clomosy.DBSQLServerQuery.Open;
          ShowMessage('Adding data to the table was successful!');
        
        except
          ShowMessage('001: Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
        }
        ShowMessage('Data was added to the existing Users table.');
      }

    except
     ShowMessage('002: Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    }
  }


{
  Form1 = TclForm.Create(Self);
  Unit1 = TclUnit.Create;
  
  Form1.SetFormBGImage(' https://resmim.net/cdn/2025/10/17/j7YS9i.webp" rel="nofollow - https://resmim.net/cdn/2025/10/17/j7YS9i.webp ')
  Form1.clsetCaption('Login Page');
  SqLServerConnectionCreateTable;
  PnlMain = Form1.AddNewProPanel(Form1,'PnlMain');
  PnlMain.ALign = AlCenter;
  PnlMain.Height = Form1.clHeight / 3;
  PnlMain.Width = Form1.clWidth - 20;
  PnlMain.clProSettings.BackgroundColor = nil;
  PnlMain.SetclProSettings(PnlMain.clProSettings);
  
  EdtUName = Form1.AddNewProEdit(PnlMain,'EdtUName', 'User Name');
  EdtUName.Align=alMostTop;
  EdtUName.Height = PnlMain.Height / 4; 
  EdtUName.Margins.Top= 5;
  EdtUName.Margins.Left= 10;
  EdtUName.Margins.Left= 10;
  EdtUName.clProSettings.BorderColor = clAlphaColor.clHexToColor('#c838e5');
  EdtUName.clProSettings.BorderWidth = 1;
  EdtUName.clProSettings.RoundHeight = 20;
  EdtUName.clProSettings.RoundWidth = 20;
  EdtUName.clProSettings.IsRound = True;
  EdtUName.SetclProSettings(EdtUName.clProSettings);
  
  EdtUPassword = Form1.AddNewProEdit(PnlMain,'EdtUPassword', 'User Password');
  EdtUPassword.Align=alMostTop;
  EdtUPassword.Height = PnlMain.Height / 4;
  EdtUPassword.Margins.Top= 5;
  EdtUPassword.Margins.Left= 10;
  EdtUPassword.Margins.Left= 10;
  EdtUPassword.SetclProSettings(EdtUName.clProSettings);
  
  
  PnlEntry = Form1.AddNewProPanel(PnlMain,'PnlEntry');
  PnlEntry.ALign = AlBottom;
  PnlEntry.Height = PnlMain.Height / 4;
  PnlEntry.Margins.Top= 5;
  PnlEntry.Margins.Left= 10;
  PnlEntry.Margins.Left= 10;
  PnlEntry.SetclProSettings(PnlMain.clProSettings);
  
  BtnLogin = Form1.AddNewProButton(PnlEntry,'BtnLogin','Login'); 
  BtnLogin.Align=alLeft;
  BtnLogin.Width = PnlEntry.Width / 2;
  BtnLogin.clTagStr = 'Login';
  BtnLogin.clProSettings.TextSettings.Font.Style = [fsBold];
  BtnLogin.clProSettings.BorderColor = clAlphaColor.clHexToColor('#c838e5');
  BtnLogin.clProSettings.BorderWidth = 2;
  BtnLogin.clProSettings.RoundHeight = 20;
  BtnLogin.clProSettings.RoundWidth = 20;
  BtnLogin.clProSettings.IsRound = True;
  BtnLogin.SetclProSettings(BtnLogin.clProSettings);
  Form1.AddNewEvent(BtnLogin,tbeOnClick,'GoToMainPage');
  //Form1.AddNewEvent(BtnLogin,tbeOnClick,'GetUserControl');
  
  BtnSignUp = Form1.AddNewProButton(PnlEntry,'BtnSignUp','Sign Up'); 
  BtnSignUp.Align=alRight;
  BtnSignUp.Width = PnlEntry.Width / 2;
  BtnSignUp.clTagStr = 'SignUp';
  BtnSignUp.SetclProSettings(BtnLogin.clProSettings);
  Form1.AddNewEvent(BtnSignUp,tbeOnClick,'GetUserControl');
  
  Form1.Run;
}Mainpage sayfası çalışmıyor.



Cevaplar:
Mesajı Yazan: Emr.Erkmn
Mesaj Tarihi: 21 Ekim 2025 Saat 09:29
Merhaba Gökçe,
Birim adını kontrol eder misin?
Kodda herhangi bir hata yok.



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net