//Sửa chi tiết phiếu thuê public bool suactphieuthue(DTO_ChiTietPhieuThuePhong ctpt) { try { int result = DBConnect.Instance.ExecuteNonQuery("exec uspSuactPhieuThue @MAPHIEUTHUE , @MACHITIETPHIEUTHUE", new object[] { ctpt.CHITIETPHIEUTHUEPHONG_MAPHIEUTHUE, ctpt.CHITIETPHIEUTHUEPHONG_MACHITIETPHIEUTHUE }); return(result > 0); } catch (Exception) { } finally { } return(false); }
//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 suactphieuthue(DTO_ChiTietPhieuThuePhong ctpt) { return(dalHotel.suactphieuthue(ctpt)); }