Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     conn.Open();
     cmd = new SqlCommand("Select * from Tai_Khoan Where Ma_TaiKhoan = '" + textBox1.Text + "' and MatKhau = '" + textBox2.Text + "'", conn.conn);
     dr  = cmd.ExecuteReader();
     if (dr.HasRows)
     {
         label5.Text = "";
         this.Hide();
         QuanTri quantri = new QuanTri();
         quantri.Show();
         if (checkBox1.Checked)
         {
             FileStream   stream = new FileStream(Application.StartupPath + @"\config.dat", FileMode.Create);
             BinaryWriter binstr = new BinaryWriter(stream);
             binstr.Write(textBox1.Text);
             binstr.Write(textBox2.Text);
             binstr.Write(checkBox1.Checked);
             binstr.Close();
             return;
         }
         else if (checkBox1.Checked == false)
         {
             File.Delete("config.dat");
         }
     }
     else
     {
         label5.Text = "Sai Tài Khoản Hoặc Mật Khẩu";
         textBox2.Clear();
     }
     conn.Close();
 }
Exemple #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     conn.Open();
     cmd = new SqlCommand("Select * from Tai_Khoan Where Ma_TaiKhoan = '"+textBox1.Text+"' and MatKhau = '"+textBox2.Text+"'", conn.conn);
     dr = cmd.ExecuteReader();
         if (dr.HasRows)
         {
             label5.Text = "";
             this.Hide();
             QuanTri quantri = new QuanTri();
             quantri.Show();
             if (checkBox1.Checked)
             {
                 FileStream stream = new FileStream(Application.StartupPath + @"\config.dat", FileMode.Create);
                 BinaryWriter binstr = new BinaryWriter(stream);
                 binstr.Write(textBox1.Text);
                 binstr.Write(textBox2.Text);
                 binstr.Write(checkBox1.Checked);
                 binstr.Close();
                 return;
             }
             else if (checkBox1.Checked == false)
             {
                 File.Delete("config.dat");
             }
         }
         else
         {
             label5.Text = "Sai Tài Khoản Hoặc Mật Khẩu";
             textBox2.Clear();
         }
     conn.Close();
 }