public bool InsertKH(DTO_PhieuThuePhong PTP) { SqlCommand cmdKH = new SqlCommand("insert into KHACHHANG values ('" + PTP.MaPNG + "',N'" + PTP.HoTen + "', N'" + PTP.LoaiKH + "','" + PTP.CMND + "', N'" + PTP.DiaChi + "' )", sqlConnection); cmdKH.ExecuteNonQuery(); return(true); }
public bool UpdateKH(DTO_PhieuThuePhong PTP) { SqlCommand sqlCommandPT = new SqlCommand("insert into PHIEUTHUE values (@maphieu,@ngaythue,@makh,@mapng,@soluong,@loaikh,@thanhtoan)", sqlConnection); sqlCommandPT.Parameters.AddWithValue("@maphieu", PTP.MaPhieu); sqlCommandPT.Parameters.AddWithValue("@ngaythue", PTP.NgayThue); sqlCommandPT.Parameters.AddWithValue("@makh", PTP.MaKH); sqlCommandPT.Parameters.AddWithValue("@mapng", PTP.MaPNG); sqlCommandPT.Parameters.AddWithValue("@soluong", PTP.SoLuong); sqlCommandPT.Parameters.AddWithValue("@loaikh", PTP.LoaiKH); sqlCommandPT.Parameters.AddWithValue("@thanhtoan", PTP.ThanhToan); sqlCommandPT.ExecuteNonQuery(); return(true); }
//Thêm phiếu thuê phòng public bool lapPhieuThue(DTO_PhieuThuePhong pt) { try { int result = DBConnect.Instance.ExecuteNonQuery("exec uspLapPhieuThue @NGAYLAPPHIEU , @MAPHONG", new object[] { Convert.ToDateTime(pt.PHIEUTHUEPHONG_NGAYLAPPHIEU), pt.PHIEUTHUEPHONG_MAPHONG }); return(result > 0); } catch (Exception) { } finally { } return(false); }
public bool InsertKH(DTO_PhieuThuePhong cs) { return(PTP.InsertKH(cs)); }
public bool UpdateKH(DTO_PhieuThuePhong cs) { return(PTP.UpdateKH(cs)); }
public GUI_PhieuThuePhong() { InitializeComponent(); PTP_BUS = new BUS_PhieuThuePhong(); PTP_DTO = new DTO_PhieuThuePhong(); }
//Sửa phiếu thuê phòng, khách hàng, chi tiết phiếu thuê phòng private void btnSua_Click(object sender, EventArgs e) { if (txtName.Text != "" && txtCMND.Text != "" && txtDiachi.Text != "" && txtPhoneNumber.Text != "") { DTO_PhieuThuePhong lpt = new DTO_PhieuThuePhong(0, dtNgayLap.Text, cbP.SelectedValue.ToString()); DTO_PhieuThuePhong spt = new DTO_PhieuThuePhong(t, dtNgayLap.Text, (cbP.SelectedValue.ToString())); DTO_KhachHang skh = new DTO_KhachHang(d, Convert.ToInt32(cbK.SelectedValue.ToString()), txtName.Text, txtCMND.Text, txtDiachi.Text, txtPhoneNumber.Text, dtNgaySinh.Text); if (mp1 != mp) { if (busPhong.checkTinhTrangPhong(Convert.ToString(mp1))) { if (busctpt.countctphieuthue(Convert.ToInt32(busHotel.loadMaPhieuThue(Convert.ToInt32(cbP.SelectedValue.ToString())))) < 3) { DTO_ChiTietPhieuThuePhong sctpt = new DTO_ChiTietPhieuThuePhong(m, Convert.ToInt32(busHotel.loadMaPhieuThue(Convert.ToInt32(cbP.SelectedValue.ToString()))), d); if (busctpt.suactphieuthue(sctpt) && busKh.suaKhachHang(skh)) { MessageBox.Show("Sửa phiếu thuê thành công!"); dgvPT.DataSource = busHotel.getPhieuthue(Convert.ToInt32(id)); txtName.Text = "Họ tên"; txtPhoneNumber.Text = "Số điện thoại"; txtCMND.Text = "CMND"; txtDiachi.Text = "Địa chỉ"; //cbLP.Text = "A"; //cbP.Text = "101"; cbK.Text = "Trong nước"; dtNgayLap.Text = Convert.ToString(DateTime.Today); dtNgaySinh.Text = Convert.ToString(DateTime.Today); } else { MessageBox.Show("Sửa phiếu thuê không thành công!"); } } else { MessageBox.Show("Không thể thêm khách hàng vào phòng!"); } } else { if (busHotel.lapPhieuThue(lpt)) { DTO_ChiTietPhieuThuePhong sctpt = new DTO_ChiTietPhieuThuePhong(m, Convert.ToInt32(busHotel.loadMaPhieuThue(Convert.ToInt32(cbP.SelectedValue.ToString()))), d); if (busctpt.suactphieuthue(sctpt) && busKh.suaKhachHang(skh)) { MessageBox.Show("Sửa phiếu thuê thành công!"); string tt = "1"; busPhong.updateTinhTrangPhong(tt, mp1); dgvPT.DataSource = busHotel.getPhieuthue(Convert.ToInt32(id)); txtName.Text = "Họ tên"; txtPhoneNumber.Text = "Số điện thoại"; txtCMND.Text = "CMND"; txtDiachi.Text = "Địa chỉ"; //cbLP.Text = "A"; //cbP.Text = "101"; cbK.Text = "Trong nước"; dtNgayLap.Text = Convert.ToString(DateTime.Today); dtNgaySinh.Text = Convert.ToString(DateTime.Today); //int mpt = Convert.ToInt32(busHotel.loadMaPhieuThue(dtNgayLap.Text, Convert.ToInt32(cbP.SelectedValue.ToString()))); } else { MessageBox.Show("Sửa phiếu thuê không thành công!"); } } } } else if (busKh.suaKhachHang(skh)) { MessageBox.Show("Sửa phiếu thuê thành công!"); dgvPT.DataSource = busHotel.getPhieuthue(Convert.ToInt32(id)); txtName.Text = "Họ tên"; txtPhoneNumber.Text = "Số điện thoại"; txtCMND.Text = "CMND"; txtDiachi.Text = "Địa chỉ"; //cbLP.Text = "A"; //cbP.Text = "101"; cbK.Text = "Trong nước"; dtNgayLap.Text = Convert.ToString(DateTime.Today); dtNgaySinh.Text = Convert.ToString(DateTime.Today); } else { MessageBox.Show("Sửa phiếu thuê không thành công!"); } } else { MessageBox.Show("Vui lòng nhập đầy đủ thông tin!"); } t = 0; m = 0; d = 0; mp = 0; }
public bool lapPhieuThue(DTO_PhieuThuePhong pt) { return(dalHotel.lapPhieuThue(pt)); }