private void Thoat_Click(object sender, EventArgs e)
        {
            this.Hide();
            NhanVienQuanLy n = new NhanVienQuanLy();

            n.Show();
            this.Close();
        }
        private void btnThoat_Click(object sender, EventArgs e)
        {
            Hide();
            NhanVienQuanLy n = new NhanVienQuanLy();

            n.Show();
            Close();
        }
        private void btnSuaKhachSan_Click(object sender, EventArgs e)
        {
            this.Hide();

            NhanVienQuanLy n = new NhanVienQuanLy();

            n.Show();
            this.Close();
        }
Exemple #4
0
        private void btn_LogIn_Click(object sender, EventArgs e)
        {
            if (txt_UserName.Text == "" || txt_PassWord.Text == "")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông báo");
                return;
            }

            SqlConnection conn;

            conn = DataProvider.OpenConnection();

            int temp;

            if (checkBoxNhanVien.Checked)
            {
                temp = 1;
            }
            else
            {
                temp = 0;
            }

            string     proc = "DangNhapHeThong";
            SqlCommand cmd  = new SqlCommand(proc);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = conn;

            try
            {
                cmd.CommandType = CommandType.StoredProcedure;
                //cmd.Connection = cn;
                cmd.Parameters.Add("@tenDangNhap", SqlDbType.NVarChar).Value = txt_UserName.Text;
                cmd.Parameters.Add("@matKhau", SqlDbType.VarChar).Value      = txt_PassWord.Text;
                cmd.Parameters.Add("@isNhanVien", SqlDbType.Int).Value       = temp;
                //Doc du lieu cua Procedure
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    MessageBox.Show("Đăng nhập thành công!\nXin chào " + (string)(reader[1]));
                    Program.username = txt_UserName.Text;
                    if (checkBoxNhanVien.Checked)
                    {
                        this.Hide();
                        NhanVienQuanLy nvql = new NhanVienQuanLy();
                        nvql.ShowDialog();
                        DataProvider.CloseConnection(conn);
                        this.Close();
                    }

                    else
                    {
                        if (txt_UserName.Text != "admin")
                        {
                            this.Hide();
                            TimKiemKhachSan tkks = new TimKiemKhachSan();
                            tkks.ShowDialog();
                            DataProvider.CloseConnection(conn);

                            this.Close();
                        }

                        else
                        {
                            this.Hide();
                            Admin ad = new Admin();
                            ad.ShowDialog();
                            DataProvider.CloseConnection(conn);
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Thông tin đăng nhập không đúng.Vui lòng kiểm tra lại", "Lỗi Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txt_PassWord.Text = "";
                    txt_UserName.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message);
            }
        }