Exemple #1
0
 private void button_login_Click(object sender, EventArgs e)
 {
     try
     {
         MySqlCommand com = new MySqlCommand();
         com.Connection = Util.con;
         com.Parameters.Add("@user", MySqlDbType.VarChar, 50).Value = textBox_username.Text.Trim();
         com.Parameters.Add("@pass", MySqlDbType.VarChar, 200).Value = Util.MD5Hash(textBox_password.Text.Trim());
         com.CommandText = "SELECT * FROM user WHERE username=@user AND password=@pass";
         Util.con.Open();
         MySqlDataReader read = com.ExecuteReader();
         if (read.Read())
         {
             Session.USER.Add("id", read["id"].ToString());
             Session.USER.Add("username", read["username"].ToString());
             Session.USER.Add("level", (int)read["level"]);
             this.Close();
             this.frmMain = new MainForm();
             this.frmMain.Show();
         }
         Util.con.Close();
     }
     catch (MySqlException sqlE)
     {
         return;
     }
 }
Exemple #2
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     MainForm frmMain = new MainForm();
     frmMain.Show();
     Application.Run();
 }
Exemple #3
0
 private void button_ok_Click(object sender, EventArgs e)
 {
     server.Hostname = textBox_hostname.Text;
     server.Username = textBox_username.Text;
     server.Password = textBox_password.Text;
     server.Database = textBox_database.Text;
     Session.SERVER = Util.connect(server);
     if (Session.SERVER.Count != 0)
     {
         ArrayList arrServer = new ArrayList();
         arrServer.Add(server);
         Util.saveList(arrServer, "server.list");
         this.Close();
         this.frmMain = new MainForm();
         this.frmMain.Show();
     }
 }