private void btnTimDoan_Click(object sender, EventArgs e) { DoanBUS dbus = new DoanBUS(); eDoan doan = new eDoan(); doan = dbus.getdoan_sdt(txtSdtDoan.Text.Trim()); txtTenDoan.Text = doan.TenDoan; txtDiaChi.Text = doan.DiaChi; txtTruongDoan.Text = doan.MaTruongDoan; }
private void btnTim_Click(object sender, EventArgs e) { DoanBUS dbus = new DoanBUS(); eDoan doan = new eDoan(); doan = dbus.getdoan_sdt(txtSdt.Text.Trim()); txtTruongDoan.Text = doan.MaTruongDoan; txtTenDoan.Text = doan.TenDoan; loadThuePhong_Doan(); }
private void btnLuu_Click(object sender, EventArgs e) { ThuePhongBUS tpbus = new ThuePhongBUS(); PhongBUS pbus = new PhongBUS(); LoaiPhongBUS lpbus = new LoaiPhongBUS(); eThuePhong tp = new eThuePhong(); NhanVienBUS nvbus = new NhanVienBUS(); DoanBUS dbus = new DoanBUS(); //Tao Doan eDoan doan = new eDoan(); doan.DiaChi = txtDiaChi.Text.Trim(); doan.MaTruongDoan = txtTruongDoan.Text.Trim(); doan.TenDoan = txtTenDoan.Text.Trim(); doan.Sdt = txtSdtDoan.Text.Trim(); if (dbus.getdoan_sdt(txtSdtDoan.Text.Trim()) == null) { int kqTaoDoan = dbus.insertDoan(doan); } tp.MaNV = nvbus.getmaNV_byEmail(emailNV); tp.MaDoan = dbus.getId_ByTenDoan(txtTenDoan.Text.Trim()); //ma doan int soLuongP = 0; for (int i = 0; i < gridViewLoaiPhong.RowCount; i++) { soLuongP += Convert.ToInt32(gridViewLoaiPhong.GetRowCellValue(i, gridViewLoaiPhong.Columns[3])); } tp.SoLuongPhong = soLuongP; tp.TrangThai = false; TimeSpan gioVao = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); TimeSpan gioRa = new TimeSpan(14, 00, 00); int a = tpbus.insertThuePhong(tp); eChiTietThuePhong cttp = new eChiTietThuePhong(); if (a == 1) { ChiTietThuePhongBUS cttpbus = new ChiTietThuePhongBUS(); foreach (eKhachHang item in ls) { cttp.MaThue = tpbus.getMaThueCuoi(); cttp.MaKhach = item.MaKH; cttp.MaPhong = pbus.maPhong_byTen(item.SoPhong); cttp.NgayRa = Convert.ToDateTime(dtmNgayRa.Text).Date; cttp.NgayVao = DateTime.Now.Date; cttp.GioRa = gioRa; cttp.GioVao = gioVao; cttp.TrangThai = false; cttpbus.insertCTTP(cttp); ePhong p = new ePhong(); p.MaPhong = pbus.maPhong_byTen(item.SoPhong); p.TinhTrang = true; int soPhong = 0; foreach (var kh in ls) { if (kh.SoPhong.Equals(item.SoPhong)) { soPhong++; } } p.SoNgHienTai = soPhong; pbus.updateTinhTrangPhong(p); } MessageBox.Show("Đặt phòng thành công"); this.Close(); } else { MessageBox.Show("Không thành công"); return; } }