public void loadData(DonVi donvi = null, Phong phong = null) { try { List <DonViHienThi> list = DonViHienThi.Convert(DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten)); DonViHienThi objNULL = new DonViHienThi(); objNULL.id = Guid.Empty; objNULL.ten = "[Không có đơn vị]"; list.Add(objNULL); ucTreeDonVi1.DataSource = list; //ucTreeDonVi1.DataSource = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); if (donvi != null) { ucTreeDonVi1.DonVi = donvi; } reloadData(); if (phong != null) { ucGridControlTaiSan1.ExpandGroupRow(phong.ten); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
public ActionResult Add(Phong model) { if (ModelState.IsValid) { try { var obj = Db.Phongs.FirstOrDefault(x => x.TenPhong == model.TenPhong); if (obj == null) { model.TrangThai = "Chưa sử dụng"; Db.Phongs.Add(model); Db.SaveChanges(); TempData["notice"] = "Thêm thành công!"; return(RedirectToAction("Index")); } else { TempData["notice"] = "Tên phòng đã tồn tại! Vui lòng chọn tên khác!"; } } catch { TempData["notice"] = "Thêm không thành công!"; } } return(View(model)); }
private void bunifuThinButton21_Click(object sender, EventArgs e) { if (txtMaPhong.Text == "") { txtMaPhong.Text = ""; txtMaPhong.Focus(); MessageBox.Show("Bạn chưa điền đầy đủ thông tin phía trên"); return; } else { PhongBUS phongBUS = new PhongBUS(); Phong phong = new Phong(); phong.maPhong = txtMaPhong.Text; phong.loaiPhong = -1; phong.tinhTrang = -1; if (!phongBUS.KiemTraMaPhong(phong)) { txtMaPhong.Text = ""; txtMaPhong.Focus(); MessageBox.Show("Phòng cần xóa không tồn tại trong danh sách!! Xin nhập lại"); } else { phongBUS.XoaPhong(phong); this.Close(); } } }
public IHttpActionResult PutPhong(int id, Phong phong) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != phong.MaPhong) { return(BadRequest()); } db.Entry(phong).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PhongExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void loadData(Phong obj = null) { try { layout.load(gridViewSuCo); List <PTB.DataFilter.ViTriHienThi> listViTri = PTB.DataFilter.ViTriHienThi.getAllHavePhong(); _ucTreeViTri.loadData(listViTri); List <TinhTrang> listTinhTrang = TinhTrang.getAllForSUCOPHONG(); lookUpEditTinhTrang.Properties.DataSource = listTinhTrang; if (obj == null) { objPhong = _ucTreeViTri.getPhong(); } else { objPhong = obj; _ucTreeViTri.setPhong(objPhong); } loadDataByPhong(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
private void rdChuaDat_CheckedChanged(object sender, EventArgs e) { pnButton.Controls.Clear(); int Size = db.Phongs.Count(); int x = 20, y = 2; for (int i = 0; i < Size; i++) { Button bt = new Button(); Phong phong = db.Phongs.ToList()[i]; List <ChiTietPhong> cp = db.ChiTietPhongs.Where(c => c.MaPhong == phong.MaPhong).ToList(); string phongso = phong.MaPhong.ToString(); bt.Click += Bt_Click; bool available = false; foreach (ChiTietPhong item in cp) { if (item.TrangThaiPhong == true) { available = true; } } if (available == false) { bt.Location = new Point(x, y); bt.BackColor = Color.LightBlue; bt.Text = phongso; bt.Size = new System.Drawing.Size(150, 75); pnButton.Controls.Add(bt); x += bt.Width + 10; } } }
public static List <TaiSan_ThongKe> getAll(List <Guid> list_coso = null, List <Guid> list_loaitaisan = null, DonVi donvi = null) { IQueryable <CTTaiSan> query = CTTaiSan.getQuery(); query = query.Where(x => x.soluong > 0); if (donvi != null) { List <Guid> list_donviquanly = donvi.getAllChildsRecursive().Select(x => x.id).ToList(); query = query.Where(x => x.donviquanly != null && list_donviquanly.Contains(x.donviquanly.id)); } //LTB if (list_loaitaisan != null && list_loaitaisan.Count > 0) { query = query.Where(x => x.taisan.loaitaisan == null || list_loaitaisan.Contains(x.taisan.loaitaisan.id)); } //COSO if (list_coso != null && list_coso.Count > 0) { List <Guid> list_phong = Phong.getQuery().Where(x => list_coso.Contains(x.vitri.coso.id)).Select(c => c.id).ToList(); //query = query.Where(x => x.vitri.coso == null || list_coso.Contains(x.vitri.coso.id)); query = query.Where(x => list_coso.Contains(x.vitri.coso.id) || list_phong.Contains(x.phong.id)); } //FINAL SELECT List <TaiSan_ThongKe> re = query.Select(x => new TaiSan_ThongKe { id = x.id, ngay = x.ngay, sohieu_ct = x.chungtu != null ? x.chungtu.sohieu : "", ngay_ct = x.chungtu != null ? x.chungtu.ngay : null, ten = x.taisan.ten, loaits = x.taisan.loaitaisan.ten, donvitinh = x.taisan.loaitaisan.donvitinh != null ? x.taisan.loaitaisan.donvitinh.ten : "", soluong_tang = !x.tinhtrang.giam_taisan ? (int?)x.soluong : null, dongia_tang = !x.tinhtrang.giam_taisan ? (long?)x.taisan.dongia : null, thanhtien_tang = !x.tinhtrang.giam_taisan ? (long?)x.soluong * x.taisan.dongia : null, soluong_giam = x.tinhtrang.giam_taisan ? (int?)x.soluong : null, dongia_giam = x.tinhtrang.giam_taisan ? (long?)x.taisan.dongia : null, thanhtien_giam = x.tinhtrang.giam_taisan ? (long?)x.soluong * x.taisan.dongia : null, sohieu_ct_tang = !x.tinhtrang.giam_taisan ? (x.chungtu != null ? x.chungtu.sohieu : "") : "", ngay_ct_tang = !x.tinhtrang.giam_taisan ? (x.chungtu != null ? x.chungtu.ngay : null) : null, sohieu_ct_giam = x.tinhtrang.giam_taisan ? (x.chungtu != null ? x.chungtu.sohieu : "") : "", ngay_ct_giam = x.tinhtrang.giam_taisan ? (x.chungtu != null ? x.chungtu.ngay : null) : null, nuocsx = x.taisan.nuocsx, nguongoc = x.nguongoc, tinhtrang = x.tinhtrang.value, ghichu = x.mota, childs = x.childs, phong = x.phong != null ? x.phong.ten : "", vitri = x.vitri != null ? (x.vitri.coso != null ? x.vitri.coso.ten + (x.vitri.day != null ? " - " + x.vitri.day.ten + (x.vitri.tang != null ? " - " + x.vitri.tang.ten : "") : "") : "") : "", dvquanly = x.donviquanly != null ? x.donviquanly.ten : "", dvsudung = x.donvisudung != null ? x.donvisudung.ten : "", phantramhaomon_32 = Object.Equals(x.taisan, null) ? 0 : Object.Equals(x.taisan.loaitaisan, null) ? 0 : x.taisan.loaitaisan.phantramhaomon_32 * 100, sotientrongmotnam = Object.Equals(x.taisan, null) ? 0 : Object.Equals(x.taisan.loaitaisan, null) ? 0 : (long)(x.taisan.dongia * x.taisan.loaitaisan.phantramhaomon_32), } ).ToList(); return(re); }
public void Init() { hitInfo = new HitInfo(); hitInfo.hasHit = true; hitInfo.hitObject = new Sphere(new Point3D(-50, 0, 60), 30, new Metal(new ColorRGB(1, 0, 0))); testPhong = new Phong(); ambLight = new AmbientLight(new ColorRGB(0, 1, 0)); }
public JsonResult ThanhToan(int?sohd) { Phong p = db.ChiTietHDs.Find(sohd).PhongThue.Phong; p.TinhTrang = false; db.SaveChanges(); return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(int?id) { Phong phong = db.Phongs.Find(id); db.Phongs.Remove(phong); db.SaveChanges(); return(RedirectToAction("Index")); }
public static Phong LoadPhong(int id) { string query = string.Format("exec pro_LoadPhong '{0}'", id); DataTable dt = DataProvider.Instance.ExcuteQuery(query); Phong phong = new Phong(dt.Rows[0]); return(phong); }
public ActionResult Create(Phong model) { if (ModelState.IsValid) { var dao = new RoomDao(); } return(View(model)); }
public ActionResult DeleteConfirmed(int id) { Phong phong = db.DbSetPhong.Find(id); db.DbSetPhong.Remove(phong); db.SaveChanges(); return(RedirectToAction("Index")); }
public Phong getPhong(int id) { using (var db = new ManageHotelEntities()) { Phong result = db.Phongs.Where(x => x.ID == id).FirstOrDefault(); return(result); } }
public bool XoaPhong(string soPhong) { Phong Phong = db.Phongs.Single(x => x.SoPhong == soPhong); db.Phongs.DeleteOnSubmit(Phong); db.SubmitChanges(); return(true); }
//xử lý public void setNguoiDung(NguoiDung nd, Phong p) { this.nguoiDung = nd; this.phongModel = p; keToan = new KeToanController(nguoiDung, phongModel, 2); loadView(); TT = TrangThai.isView; }
private void phongEditValueChanged() { Phong obj = ucComboBoxViTri1.Phong; if (obj != null && obj.vitri != null) { ucComboBoxViTri2.ViTri = obj.vitri; } }
public Phong LoadPhongTheoMaPhong(string ma) { string query = "EXECUTE DANHSACHPHONGTHEOMA @id"; List <Phong> danhsachphong1 = new List <Phong>(); DataTable data = DataProvider.Instance.ExecuteQuery(query, new object[] { ma }); Phong phong = new Phong(data.Rows[0]); return(phong); }
public void LoadData(DataTable DTP) { LoadTinhTrang(); LoadGia(); LoadSoNguoi(); LoadMoTa(); LoadKhuyenMai(); try { Button oldbtn = new Button() { Width = 0, Location = new Point(0, 0) }; foreach (DataRow dr in DTP.Rows) { Button btn = new Button() { Width = 110, Height = 110, Location = new Point(oldbtn.Location.X + 110, oldbtn.Location.Y) }; oldbtn = btn; Phong Phong = new Phong(); Phong.Ma_Phong = (string)dr.ItemArray[0]; Phong.TinhTrang = (string)dr.ItemArray[3]; btn.Text = "Phòng: " + Phong.Ma_Phong + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Phong.TinhTrang; btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); btn.BackgroundImage = Properties.Resources.phongicon3; btn.BackgroundImageLayout = ImageLayout.Zoom; btn.Click += btn_Click; btn.Tag = Phong; btn.BackColor = Color.White; switch (Phong.TinhTrang.Length) { case 2: btn.ForeColor = Color.Green; break; default: { btn.ForeColor = Color.Red; break; } } fplPhong.Controls.Add(btn); } } catch (SqlException) { MessageBox.Show("Không lấy được nội dung trong bảng PHONG. Lỗi rồi!!!"); } }
//[ValidateInput(false)] public ActionResult ThemMoi(Phong phong) { if (ModelState.IsValid) { db.Phongs.Add(phong); db.SaveChanges(); } return(RedirectToAction("PhongTro")); }
public void updateroom1(long sophong, Phong room) { using (QLKhachsanEntities entity = new QLKhachsanEntities()) { var em = entity.Phongs.FirstOrDefault(e => e.Sophong.Equals(sophong)); em.Tinhtrang = room.Tinhtrang; entity.SaveChanges(); } }
private void btnDatPhong_Click(object sender, EventArgs e) { if (!kiemTraNhapRong(txtMaHopDong.Text, txtCMND.Text, txtTenKhachHang.Text, txtSoNguoi.Text)) { MessageBox.Show("Nhập thông tin không đầy đủ !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { string strMaHopDong = txtMaHopDong.Text.Trim(); string strMaPhong = txtMaPhong.Text; string strCMND = txtCMND.Text.Trim(); string strTenKhachHang = txtTenKhachHang.Text.Trim(); int soNguoi = int.Parse(txtSoNguoi.Text.Trim()); DateTime ngayDatPhong = dtpNgayDatPhong.Value; string strMaNhanVien = txtMaNhanVien.Text.Trim(); PhongDat objPhongDat = new PhongDat(strMaHopDong, strMaPhong, strCMND, strTenKhachHang, soNguoi, ngayDatPhong, strMaNhanVien); if (phongDatService.datPhong(objPhongDat)) { MessageBox.Show("Đặt phòng thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); kiemTraAnNut = true; //thay đổi trạng thái của phòng khi đã đặt phòng thành công List <Phong> lstPhong = phongService.timPhongTheoMaPhong(strMaPhong); Phong objPhong = new Phong(); objPhong.MaPhong = lstPhong[0].MaPhong; objPhong.TinhTrang = "Đang được thuê"; phongService.capNhatTinhTrangPhong(objPhong); // this.Hide(); frmTrangChu f = new frmTrangChu(); f.strTenNhanVien = strTenNhanVien; f.flagHienThiMenu = flagHienThiMenu; f.strMaNhanVien = strMaNhanVien; f.ShowDialog(); this.Close(); } else { MessageBox.Show("Đặt phòng không thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Thông tin nhập vào không đúng.Mời nhập lại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnXacNhanThue_Click_1(object sender, EventArgs e) { int dem = 0; // số phòng mà khách chọn foreach (DataGridViewRow row in dgvThuePhong.Rows) { if (row.Cells[0].Value != null) { if ((Boolean)row.Cells[0].Value == true) { dem++; } } } if (dem > 0) { //Thêm khách hàng mới KhachHang kh = new KhachHang(); kh.TenKH = txtTenKH.Text; kh.GioiTinh = cboGioiTinh.Text; kh.SDT = txtSDT.Text; kh.Email = txtEmail.Text; kh.CMND = txtCMND.Text; dal_khachhang.ThemKhachHang(kh); string str_MaKHVuaThem = dal_khachhang.LayMaKHVuaThem(); //Thêm vào bảng Phiếu thuê mã khách hàng, ngày đén ngày đi, hình thức thuê PhieuThue PT = new PhieuThue(); PT.MaKH = str_MaKHVuaThem; PT.NgayDen = dateNgayDen.Value; PT.NgayDi = dateNgayDi.Value; PT.HinhThucThue = cboHinhThucThue.Text; dal_phieuthue.ThemPhieuThue(PT); string str_MaPTVuaThem = dal_phieuthue.LayMaPTVuaThem(); //Update bảng phòng foreach (DataGridViewRow row in dgvThuePhong.Rows) { if (row.Cells[0].Value != null) { if ((Boolean)row.Cells[0].Value == true) { Phong P = new Phong(); P.MaPhong = row.Cells[1].Value.ToString().Trim(); P.TrangThai = "Đã bị thuê"; P.MaPT = str_MaPTVuaThem; dal_phong.SuaPhongSauKhiThue(P); } } } MessageBox.Show("Thuê phòng thành công"); this.Close(); } else { MessageBox.Show("Bạn cần chọn phòng"); } }
public ActionResult Diennuoctieuthu(string soHieuPhong) { var db = new DB(); List <HoaDonDienNuoc> hoaDonDienNuocs = db.HoaDonDienNuocs.Where(x => x.SoHieuPhong == soHieuPhong).OrderByDescending(x => x.ThangGhi).ToList(); Phong phong = db.Phongs.FirstOrDefault(x => x.SoHieuPhong == soHieuPhong); ViewData["phong"] = phong; ViewData["hoaDonDienNuocs"] = hoaDonDienNuocs; return(View()); }
//[ValidateInput(false)] public ActionResult Sua(Phong phong) { if (ModelState.IsValid) { //Thực hiện cập nhật trong model db.Entry(phong).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("PhongTro")); }
public ActionResult Edit([Bind(Include = "MaPhong,TenPhong")] Phong phong) { if (ModelState.IsValid) { db.Entry(phong).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(phong)); }
public ActionResult Edit(int?id) { Phong obj = id > 0 ? db.Phongs.Find(id) : new Phong(); if (obj == null) { return(HttpNotFound()); } return(View(obj)); }
public void DataGridViewClick(object obj) { var phong = (Phong)obj; this.phong = new Phong { Map = phong.Map, TenP = phong.TenP }; form.setObject(this.phong); controlForm.setState(StateForm.Show); }
public Phong getPhongFromMa(string ma) { Phong rs = qlks.Phongs.Where(t => t.MaPhong == ma).FirstOrDefault(); if (rs != null) { return(rs); } return(null); }
public frmAddThietBi(Phong obj, bool _loaichung) { InitializeComponent(); loaichung = _loaichung; _ucQuanLyThietBi.Dock = DockStyle.Fill; _ucQuanLyThietBi.loadData(loaichung); panelControl1.Controls.Add(_ucQuanLyThietBi); objPhong = obj; dateEdit1.DateTime = DateTime.Now; }
public void xoaPhong(int id) { Phong phong = (from p in datacontext.Phongs where p.ID == id select p).FirstOrDefault(); if (phong != null) { datacontext.Phongs.DeleteOnSubmit(phong); datacontext.SubmitChanges(); } }
public void loadData(DonVi donvi = null, Phong phong = null) { try { List<DonViHienThi> list = DonViHienThi.Convert(DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten)); DonViHienThi objNULL = new DonViHienThi(); objNULL.id = Guid.Empty; objNULL.ten = "[Không có đơn vị]"; list.Add(objNULL); ucTreeDonVi1.DataSource = list; //ucTreeDonVi1.DataSource = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); if (donvi != null) ucTreeDonVi1.DonVi = donvi; reloadData(); if (phong != null) ucGridControlTaiSan1.ExpandGroupRow(phong.ten); } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
// Load dữ liệu public void loadData(Phong obj = null) { try { layout.load(gridViewCTThietBi); working = false; enableEdit(false); List<LoaiThietBi> listLoai = LoaiThietBi.getAll(); _ucTreeLoaiTB.loadData(listLoai); List<ViTriHienThi> listVitris = ViTriHienThi.getAllHavePhong(); _ucTreeViTri.loadData(listVitris); if (obj != null) { objPhong = obj; _ucTreeViTri.setPhong(objPhong); } else { objPhong = _ucTreeViTri.getPhong(); } gridControlCTThietBi.DataSource = null; listCTThietBis = ChiTietTBHienThi.getAllByPhongId(objPhong.id); gridControlCTThietBi.DataSource = listCTThietBis; editGUI(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData:" + ex.Message); } }
public void setData(Guid _phongid) { DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitForm1), true, true, false); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu..."); try { objPhong = Phong.getById(_phongid); gridControlCTThietBi.DataSource = null; listCTThietBis = ChiTietTBHienThi.getAllByPhongId(_phongid); gridControlCTThietBi.DataSource = listCTThietBis; editGUI(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->setData:" + ex.Message); } DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); }
private void btnOk_Click(object sender, EventArgs e) { try { if (checkInput()) { switch (function) { case "add": objPhong = new Phong(); setDataObj(); if (objPhong.add() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Thêm phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Guid id = objPhong.id; reloadAndFocused(id); } else { XtraMessageBox.Show("Thêm phòng không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "edit": setDataObj(); if (objPhong.update() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Sửa phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Guid id = objPhong.id; reloadAndFocused(id); } else { XtraMessageBox.Show("Sửa phòng không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } } } catch (Exception ex) { Debug.WriteLine(this.Name + "->btnOk_Click: " + ex.Message); } }
private void CRUD() { try { switch (function) { case "add": objPhong = new Phong(); setDataObj(); if (objPhong.add() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Thêm phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); reLoadAndFocused(objPhong.id); function = ""; } else XtraMessageBox.Show("Có lỗi trong khi thêm"); break; case "edit": if (objPhong != null) { setDataObj(); if (objPhong.update() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Sửa phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); reLoadAndFocused(objPhong.id); enableEdit(false); function = ""; } else XtraMessageBox.Show("Có lỗi trong khi sửa"); } break; case "delete": if (objPhong != null) { if (XtraMessageBox.Show("Bạn có chắc là muốn xóa phòng?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.Yes) { int reee = objPhong.delete(); if (reee > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Xóa phòng thành công!"); reLoad(); } else if (reee == -2) { XtraMessageBox.Show("Có thiết bị trong phòng. Vui lòng xóa thiết bị trước!"); } else if (reee == -3) { XtraMessageBox.Show("Xóa sự cố trong phòng trước!"); } else { XtraMessageBox.Show("Lỗi trong khi xóa phòng!"); } } } break; } } catch (Exception ex) { Debug.WriteLine(this.Name + "->CRUD: " + ex.Message); } }
public void loadDataById(Guid id) { objPhong = Phong.getById(id); loadDataByPhong(); }
public void loadData(Phong obj = null) { try { layout.load(gridViewSuCo); List<PTB.DataFilter.ViTriHienThi> listViTri = PTB.DataFilter.ViTriHienThi.getAllHavePhong(); _ucTreeViTri.loadData(listViTri); List<TinhTrang> listTinhTrang = TinhTrang.getAllForSUCOPHONG(); lookUpEditTinhTrang.Properties.DataSource = listTinhTrang; if (obj == null) { objPhong = _ucTreeViTri.getPhong(); } else { objPhong = obj; _ucTreeViTri.setPhong(objPhong); } loadDataByPhong(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
public void AddToPhongs(Phong phong) { base.AddObject("Phongs", phong); }
public static Phong CreatePhong(int maPhong) { Phong phong = new Phong(); phong.MaPhong = maPhong; return phong; }
public void setPhong(Phong obj) { try { if (obj != null && !obj.id.Equals(Guid.Empty)) { TreeListNode node = treeListViTri.FindNodeByKeyID(obj.id); if (node != null) { treeListViTri.CollapseAll(); node.Selected = true; } } } catch (Exception ex) { Debug.WriteLine(this.Name + "->setPhong: " + ex.Message); } }
private void loadDataByPhong(Phong obj, String type) { open = true; objPhong = obj; if (type.Equals("thietbi")) { ribbonMain.SelectedPage = ribbonMain.Pages.GetPageByName("rbnPagePhongThietbi_Home"); } else if (type.Equals("suco")) { ribbonMain.SelectedPage = ribbonMain.Pages.GetPageByName("rbnPageSuCoPhong"); } open = false; }
public static bool ImportPhong(String fileName, String sheet) { try { int line = 0; System.Data.DataTable dt = new System.Data.DataTable(); const int STT = 0; const int MAPHONG = 1; const int TENPHONG = 2; const int MOTA = 3; const int COSO = 4; const int DAY = 5; const int TANG = 6; const int NHANVIENPT = 7; const int MANHANVIEN = 8; const int NGAYTAO = 9; const int HINHANH = 10; const int PASS = 11; dt = OpenFile(fileName, sheet); if (dt != null) { int lines = dt.Rows.Count; foreach (System.Data.DataRow row in dt.Rows) { line++; DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Import Phòng... " + String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.0}", (line * 1.0 / lines) * 100) + "%"); bool ok = false; if (!row[PASS].Equals("Pass")) { if (row[TENPHONG] != DBNull.Value) { if (Phong.getAll().FirstOrDefault(c => c.ten.ToUpper() == row[TENPHONG].ToString().Trim().ToUpper()) == null) { try { ViTri objViTri = new ViTri(); CoSo objCoSo = new CoSo(); Dayy objDay = new Dayy(); Tang objTang = new Tang(); if(row[COSO] != DBNull.Value) { objCoSo = CoSo.getAll().Where(c => c.ten.ToUpper().Equals(row[COSO].ToString().Trim().ToUpper())).FirstOrDefault(); if (objCoSo != null && objCoSo.id != Guid.Empty) { if (row[DAY] != DBNull.Value && objCoSo.days.Count > 0) { objDay = objCoSo.days.Where(c => c.ten.ToUpper().Equals(row[DAY].ToString().Trim().ToUpper())).FirstOrDefault(); if (objDay != null && objDay.id != Guid.Empty) { if (row[TANG] != DBNull.Value && objDay.tangs.Count > 0) { objTang = objDay.tangs.Where(c => c.ten.ToUpper().Equals(row[TANG].ToString().Trim().ToUpper())).FirstOrDefault(); if (objTang != null && objTang.id != Guid.Empty) { objViTri.coso = objCoSo; objViTri.day = objDay; objViTri.tang = objTang; ok = true; } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)"); } } else if (row[TANG] == DBNull.Value) { objViTri.coso = objCoSo; objViTri.day = objDay; objViTri.tang = null; ok = true; } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)"); } } else if (row[DAY] == DBNull.Value) { objViTri.coso = objCoSo; objViTri.day = null; objViTri.tang = null; ok = true; } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có cơ sở)"); } } if (ok) { Phong obj = new Phong(); obj.subId = row[MAPHONG] != DBNull.Value ? row[MAPHONG].ToString().Trim() : null; obj.vitri = objViTri; obj.ten = row[TENPHONG].ToString().Trim(); obj.date_create = row[NGAYTAO] != DBNull.Value ? (DateTime?)Convert.ToDateTime(row[NGAYTAO]) : DateTime.Now; obj.mota = row[MOTA].ToString().Trim(); if (row[HINHANH] != DBNull.Value) { String[] file_names = row[HINHANH].ToString().Trim().Split(','); obj.hinhanhs = AddImage(fileName, file_names); } if(row[NHANVIENPT] != DBNull.Value) { if (NhanVienPT.getAll().Where(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper()).Count() == 1) { obj.nhanvienpt = NhanVienPT.getAll().FirstOrDefault(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper()); } else if (NhanVienPT.getAll().Where(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper()).Count() > 1) { if (row[MANHANVIEN] != DBNull.Value) { if (NhanVienPT.getAll().Where(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper() && c.subId.ToUpper() == row[MANHANVIEN].ToString().Trim().ToUpper()).Count() == 1) { obj.nhanvienpt = NhanVienPT.getAll().FirstOrDefault(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper() && c.subId.ToUpper() == row[MANHANVIEN].ToString().Trim().ToUpper()); } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass - Error (Mã nhân viên không đúng)"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass - Error (Nhân viên trùng tên nhưng không có mã)"); } } } if (obj.add() > 0 && DBInstance.commit() > 0) { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass"); } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error"); } } else { //WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Vị trí lỗi)"); } } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message); WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Exist"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không đủ thông tin)"); } } } } return true; } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message); return false; } }
public static bool ImportPhong(String fileName, String sheet) { try { int line = 0; System.Data.DataTable dt = new System.Data.DataTable(); const int STT = 0; const int MAPHONG = 1; const int TENPHONG = 2; const int LOAIPHONG = 3; //const int SOCHONGOI = 4; const int MOTA = 5; const int COSO = 6; const int DAY = 7; const int TANG = 8; const int PASS = 9; dt = OpenFile(fileName, sheet); if (dt != null) { int lines = dt.Rows.Count; foreach (System.Data.DataRow row in dt.Rows) { line++; DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Import Phòng... " + String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.0}", (line * 1.0 / lines) * 100) + "%"); bool ok = false; if (!row[PASS].Equals("Pass")) { if (row[TENPHONG] != DBNull.Value) { if (Phong.getAll().FirstOrDefault(c => c.ten.ToUpper() == row[TENPHONG].ToString().Trim().ToUpper()) == null) { try { ViTri objViTri = new ViTri(); CoSo objCoSo = new CoSo(); Dayy objDay = new Dayy(); Tang objTang = new Tang(); LoaiPhong objLoai = new LoaiPhong(); if (row[COSO] != DBNull.Value) { objCoSo = CoSo.getAll().Where(c => c.ten.ToUpper().Equals(row[COSO].ToString().Trim().ToUpper())).FirstOrDefault(); if (objCoSo != null && objCoSo.id != Guid.Empty) { if (row[DAY] != DBNull.Value && objCoSo.days.Count > 0) { objDay = objCoSo.days.Where(c => c.ten.ToUpper().Equals(row[DAY].ToString().Trim().ToUpper())).FirstOrDefault(); if (objDay != null && objDay.id != Guid.Empty) { if (row[TANG] != DBNull.Value && objDay.tangs.Count > 0) { objTang = objDay.tangs.Where(c => c.ten.ToUpper().Equals(row[TANG].ToString().Trim().ToUpper())).FirstOrDefault(); if (objTang != null && objTang.id != Guid.Empty) { objViTri.coso = objCoSo; objViTri.day = objDay; objViTri.tang = objTang; ok = true; } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)"); } } else if (row[TANG] == DBNull.Value) { objViTri.coso = objCoSo; objViTri.day = objDay; objViTri.tang = null; ok = true; } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)"); } } else if (row[DAY] == DBNull.Value) { objViTri.coso = objCoSo; objViTri.day = null; objViTri.tang = null; ok = true; } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có cơ sở)"); } } if (row[LOAIPHONG] != DBNull.Value) { objLoai = LoaiPhong.getAll().Where(c => c.ten.ToUpper().Equals(row[LOAIPHONG].ToString().Trim().ToUpper())).FirstOrDefault(); if (objLoai == null || objLoai.id == Guid.Empty) { objLoai = new LoaiPhong(); objLoai.ten = row[LOAIPHONG].ToString().Trim(); objLoai.mota = row[LOAIPHONG].ToString().Trim(); //ok = false; //WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có loại phòng)"); } } else { ok = false; WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có loại phòng)"); } if (ok) { Phong obj = new Phong(); obj.subId = row[MAPHONG] != DBNull.Value ? row[MAPHONG].ToString().Trim() : null; obj.vitri = objViTri; obj.ten = row[TENPHONG].ToString().Trim(); //obj.sochongoi = row[SOCHONGOI] != DBNull.Value ? Convert.ToInt32(row[SOCHONGOI].ToString()) : 0; obj.mota = row[MOTA].ToString().Trim(); obj.loaiphong = objLoai; if (obj.add() > 0 && DBInstance.commit() > 0) { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass"); } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error"); } } } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message); WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Exist"); } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không đủ thông tin)"); } } } } return true; } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message); return false; } }
private void getThongTinPhong(Boolean first) { if (listPhong.Count() > 0) { int row = 0; if (!first) row = gridViewPhong.FocusedRowHandle; if (row >= 0 && row < listPhong.Count()) { //int id = (gridViewPhong.GetRow(row) as Phong).id; //objPhong = Phong.getById(id); objPhong = gridViewPhong.GetRowCellValue(row, colphong) as Phong; if (objPhong != null) { if (objPhong.nhanvienpt != null) { objNhanVienPT = objPhong.nhanvienpt; //objNhanVienPT = NhanVienPT.getById(objPhong.nhanvienpt.id); } setData(); enableBar(true); } } else { deleteData(); enableBar(false); } } else { deleteData(); enableBar(false); } rbnGroupPhong.Enabled = true; barButtonThemPhong.Enabled = true && canAdd; btnR_Them.Enabled = true && canAdd; enableEdit(false); function = ""; }
private void setDataView() { try { dxErrorProviderInfo.ClearErrors(); editGUI("view"); if (gridViewPhong.RowCount > 0) { if (gridViewPhong.GetFocusedRowCellValue(colphong) != null) { objPhong = gridViewPhong.GetFocusedRowCellValue(colphong) as Phong; txtTen.Text = objPhong.ten; txtMoTa.Text = objPhong.mota; txtSoChoNgoi.EditValue = objPhong.sochongoi; gridLookUpLoai.EditValue = objPhong.loaiphong_id; _ucComboBoxViTri.ViTri = objPhong.vitri; } else { clearText(); objPhong = new Phong(); } } else { enableButton(false); clearText(); objPhong = new Phong(); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->setDataView: " + ex.Message); } }