Esempio n. 1
0
        // 14. bang nhan phong
        public string InsertNhanPhong(NhanPhong ttNhanPhong)
        {
            string        Message;
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("insert into NhanPhong(MaNP,TenKH,NgayNhan,GioNhan,MaPH,SoLuongNguoi,SoDienThoai) values(@maNP,@tenKH,@ngayNhan,@gioNhan,@maPH,@soLuongNguoi,@soDienThoai)", con);

            cmd.Parameters.AddWithValue("@maNP", ttNhanPhong.maNP);
            cmd.Parameters.AddWithValue("@tenKH", ttNhanPhong.tenKH);
            cmd.Parameters.AddWithValue("@ngayNhan", ttNhanPhong.ngayNhan);
            cmd.Parameters.AddWithValue("@gioNhan", ttNhanPhong.gioNhan);
            cmd.Parameters.AddWithValue("@maPH", ttNhanPhong.maPH);
            cmd.Parameters.AddWithValue("@soLuongNguoi", ttNhanPhong.soLuongNguoi);
            cmd.Parameters.AddWithValue("@soDienThoai", ttNhanPhong.soDienThoai);
            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                Message = "nhan phong thanh cong";
            }
            else
            {
                Message = "nhan phong khong thanh cong";
            }
            con.Close();
            return(Message);
        }
Esempio n. 2
0
        public bool DeleteNhanPhong(NhanPhong ttNhanPhong)
        {
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("delete from NhanPhong where MaNP=@idNP", con);

            cmd.Parameters.AddWithValue("@idNP", ttNhanPhong.maNP);
            cmd.ExecuteNonQuery();
            con.Close();
            return(true);
        }
Esempio n. 3
0
        public void UpdateNhanPhong(NhanPhong ttNhanPhong)
        {
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("update NhanPhong set TenKH=@tenKH, NgayNhan=@ngayNhan, GioNhan=@gioNhan, MaPH=@maPH, SoLuongNguoi=@soLuongNguoi, SoDienThoai=@soDienThoai  where MaNP=@maNP", con);

            cmd.Parameters.AddWithValue("@maNP", ttNhanPhong.maNP);
            cmd.Parameters.AddWithValue("@tenKH", ttNhanPhong.tenKH);
            cmd.Parameters.AddWithValue("@ngayNhan", ttNhanPhong.ngayNhan);
            cmd.Parameters.AddWithValue("@gioNhan", ttNhanPhong.gioNhan);
            cmd.Parameters.AddWithValue("@maPH", ttNhanPhong.maPH);
            cmd.Parameters.AddWithValue("@soLuongNguoi", ttNhanPhong.soLuongNguoi);
            cmd.Parameters.AddWithValue("@soDienThoai", ttNhanPhong.soDienThoai);
            cmd.ExecuteNonQuery();
            con.Close();
        }