Пример #1
0
        private void button_LOGIN_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text.Equals("") || txtPassword.Text.Equals(""))
            {
                return;
            }
            else
            {
                dbDangNhap.Decrypt(txtUsername.Text.Trim());

                DataSet ds = dbDangNhap.FindUser(txtUsername.Text, txtPassword.Text);
                dbDangNhap.Encrypt(txtUsername.Text.Trim());

                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataSet ds1 = dbNhanVien.LayChucVuNV(txtUsername.Text);
                    if (ds1.Tables[0].Rows.Count > 0)
                    {
                        Program.ChucVuUser = ds1.Tables[0].Rows[0].ItemArray[0].ToString();
                        Program.UserName   = txtUsername.Text;
                        this.Hide();

                        User us = new User();
                        us.MaNV = txtUsername.Text.Trim();
                        Form1 mainform = new Form1(us.MaNV);
                        mainform.ShowDialog();
                        this.Close();
                        //this.ShowInTaskbar = false;
                    }
                    else
                    {
                        MessageBox.Show("Đăng nhập thât bại", "Thông báo!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
        }