public bool xoaNhanVien(string maNhanVien)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string     strQuery = "DELETE FROM nhanvien WHERE manhanvien='" + maNhanVien + "'";
            SqlCommand command  = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();
            return(isSuccess);
        }
Esempio n. 2
0
        public bool xoaPhongDat(string maHopDong)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string     strQuery = "DELETE FROM phongdat WHERE mahopdong='" + maHopDong + "'";
            SqlCommand command  = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();
            return(isSuccess);
        }
        public int demSoPhongDuocThue()
        {
            int           ketQua = 0;
            SqlConnection conn   = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string     strQuery = "SELECT COUNT (tinhtrang) FROM phong WHERE tinhtrang=N'Đang được thuê'";
            SqlCommand command  = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            ketQua = (int)command.ExecuteScalar();

            conn.Close();

            return(ketQua);
        }
        public bool capNhatTinhTrangPhong(Phong objPhong)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string strQuery = "UPDATE phong SET tinhtrang=N'"
                              + objPhong.TinhTrang + "'WHERE maphong='" + objPhong.MaPhong + "'";
            SqlCommand command = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();

            return(isSuccess);
        }
        public bool capNhatNhanVien(NhanVien objNhanVien)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string strQuery = "UPDATE nhanvien SET matkhau=N'"
                              + objNhanVien.MatKhau + "',quyenhan=N'"
                              + objNhanVien.QuyenHan + "',hoten=N'"
                              + objNhanVien.HoTen + "'WHERE manhanvien='" + objNhanVien.MaNhanVien + "'";
            SqlCommand command = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();
            return(isSuccess);
        }
        public bool themNhanVien(NhanVien objNhanVien)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string strQuery = "INSERT INTO nhanvien VALUES(N'"
                              + objNhanVien.MaNhanVien + "',N'" + objNhanVien.MatKhau
                              + "',N'" + objNhanVien.QuyenHan + "',N'"
                              + objNhanVien.HoTen + "')";
            SqlCommand command = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();
            return(isSuccess);
        }
        public bool themNhatKy(NhatKyDangNhap obj)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string strQuery = "INSERT INTO nhatkydangnhap VALUES('"
                              + obj.MaNhanVien + "',N'"
                              + obj.QuyenHan + "',N'"
                              + obj.HoTen + "','"
                              + obj.ThoiGianDangNhap + "')";
            SqlCommand command = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();
            return(isSuccess);
        }
        public bool capNhatThongTinPhong(Phong objPhong)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string strQuery = "UPDATE phong SET tang='"
                              + objPhong.Tang + "',loaiphong=N'"
                              + objPhong.LoaiPhong + "',mota=N'"
                              + objPhong.MoTa + "',giatien=N'"
                              + objPhong.GiaTien + "'WHERE maphong='" + objPhong.MaPhong + "'";
            SqlCommand command = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();

            return(isSuccess);
        }
Esempio n. 9
0
        public bool datPhong(PhongDat objPhongDat)
        {
            bool          isSuccess = false;
            SqlConnection conn      = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string strQuery = "INSERT INTO phongdat VALUES('"
                              + objPhongDat.MaHopDong + "','"
                              + objPhongDat.MaPhong + "','"
                              + objPhongDat.Cmnd + "',N'"
                              + objPhongDat.TenKhachHang + "','"
                              + objPhongDat.SoNguoi + "','"
                              + objPhongDat.NgayDatPhong + "','"
                              + objPhongDat.MaNhanVien + "')";
            SqlCommand command = conn.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = strQuery;
            isSuccess           = command.ExecuteNonQuery() > 0;

            conn.Close();
            return(isSuccess);
        }
        public List <NhanVien> layDanhSachQuyenHanNhanVien()
        {
            List <NhanVien> lstNhanVien = new List <NhanVien>();
            SqlConnection   conn        = null;

            conn = DataAccessConnection.getConnection();
            conn.Open();
            string        strQuery = "SELECT manhanvien,matkhau,quyenhan,hoten FROM nhanvien WHERE quyenhan=N'Nhân viên'";
            SqlDataReader reader   = null;
            SqlCommand    command  = new SqlCommand(strQuery, conn);

            reader = command.ExecuteReader();
            while (reader.Read())
            {
                NhanVien objNhanVien = new NhanVien();
                objNhanVien.MaNhanVien = reader["manhanvien"].ToString();
                objNhanVien.MatKhau    = reader["matkhau"].ToString();
                objNhanVien.QuyenHan   = reader["quyenhan"].ToString();
                objNhanVien.HoTen      = reader["hoten"].ToString();
                lstNhanVien.Add(objNhanVien);
            }
            conn.Close();
            return(lstNhanVien);
        }