示例#1
0
        private void btTongDai_Click(object sender, EventArgs e)
        {
            HoatDongTongDai td = new HoatDongTongDai();

            this.Hide();
            td.ShowDialog();
            this.Show();
        }
示例#2
0
        private void btDangNhap_Click(object sender, EventArgs e)
        {
            string userName = tbDangNhap.Text;
            string passWord = tbPass.Text;

            connection = new SqlConnection(connectinonST);
            connection.Open();

            string query = "SELECT COUNT(*) FROM TAI_KHOAN WHERE UserName = '******' and PassWord = '******'";

            command = new SqlCommand(query, connection);
            int x = (int)command.ExecuteScalar();

            if (x > 0) // đăng nhập thành công
            {
                string     query2   = "SELECT LoaiTaiKhoan FROM TAI_KHOAN WHERE UserName = '******' and PassWord = '******'";
                SqlCommand command2 = new SqlCommand(query2, connection);
                int        x2       = (int)command2.ExecuteScalar();
                //phân loại tài khoản
                if (x2 == 3)
                {
                    GiaoDienChinh gd = new GiaoDienChinh();
                    this.Hide();
                    gd.Message1 = userName;
                    gd.ShowDialog();
                    this.Show();
                }
                else if (x2 == 2)
                {
                    HoatDongTongDai hdtd = new HoatDongTongDai();
                    this.Hide();
                    hdtd.Message21 = userName;
                    hdtd.ShowDialog();
                    this.Show();
                }
                else if (x2 == 1)
                {
                    BoPhanQuanLy bpql = new BoPhanQuanLy();
                    this.Hide();
                    bpql.Message31 = userName;
                    bpql.ShowDialog();
                    this.Show();
                }
                else if (x2 == 4)
                {
                    QuanLyNhanVien qlnv = new QuanLyNhanVien();
                    this.Hide();
                    qlnv.ShowDialog();
                    this.Show();
                }
            }
            else
            {
                MessageBox.Show("Sai Tên Đăng Nhập Hoặc Mật Khẩu!", "Lỗi Đăng Nhập", MessageBoxButtons.OK);
            }
            connection.Close();
        }