public void loadData(List<ViTriHienThi> list, NhanVienPT nhanvien) { try { treeListPhong.BeginUnboundLoad(); treeListPhong.DataSource = list; treeListPhong.EndUnboundLoad(); List<Phong> _list = nhanvien.phongs.ToList(); foreach (Phong p in _list) { if (!p.id.Equals(Guid.Empty)) { TreeListNode node = treeListPhong.FindNodeByKeyID(p.id); if (node != null) { treeListPhong.SetNodeCheckState(node, CheckState.Checked, true); node.Selected = true; } } } if (treeListPhong.Nodes.Count > 0) treeListPhong.FocusedNode = treeListPhong.Nodes[0]; } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
public void loadData(List <ViTriHienThi> list, NhanVienPT nhanvien) { try { treeListPhong.BeginUnboundLoad(); treeListPhong.DataSource = list; treeListPhong.EndUnboundLoad(); List <Phong> _list = nhanvien.phongs.ToList(); foreach (Phong p in _list) { if (!p.id.Equals(Guid.Empty)) { TreeListNode node = treeListPhong.FindNodeByKeyID(p.id); if (node != null) { treeListPhong.SetNodeCheckState(node, CheckState.Checked, true); node.Selected = true; } } } if (treeListPhong.Nodes.Count > 0) { treeListPhong.FocusedNode = treeListPhong.Nodes[0]; } } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
public void LoadData() { _ucCollectionPager_DanhSachPhong.CollectionPager_Object.QueryStringKey = "PageRoom"; listNhanVienPT = NhanVienPT.getQuery().OrderBy(c => c.hoten).ToList(); if (listNhanVienPT.Count > 0) { SearchFunction(); if (Request.QueryString["id"] != null) { Guid id = Guid.Empty; try { id = GUID.From(Request.QueryString["id"]); } catch { Response.Redirect(Request.Url.AbsolutePath); } objNhanVienPT = NhanVienPT.getById(id); if (objNhanVienPT != null) { PanelThongTinNhanVienPhuTrach.Visible = true; Label_MaNhanVien.Text = objNhanVienPT.subId; _ucNhanVien_BreadCrumb.Label_TenNhanVien.Text = Label_HoTen.Text = objNhanVienPT.hoten; Label_SoDienThoai.Text = objNhanVienPT.sodienthoai; Libraries.ImageHelper.LoadImageWeb(objNhanVienPT.hinhanhs.ToList(), _ucASPxImageSlider_Mobile.ASPxImageSlider_Object); List <PTB.Entities.Phong> ListPhong = objNhanVienPT.phongs.ToList(); var list = ListPhong.Select(a => new { id = a.id, ten = string.Format("{0}{1}", a.ten, !Object.Equals(getVitri(a), "") ? " " + getVitri(a) : ""), url = string.Format("http://{0}/Phong.aspx?Search={1}", HttpContext.Current.Request.Url.Authority, a.id.ToString()) }).ToList(); _ucCollectionPager_DanhSachPhong.CollectionPager_Object.DataSource = list; _ucCollectionPager_DanhSachPhong.CollectionPager_Object.BindToControl = RepeaterDanhSachPhong; RepeaterDanhSachPhong.DataSource = _ucCollectionPager_DanhSachPhong.CollectionPager_Object.DataSourcePaged; RepeaterDanhSachPhong.DataBind(); } else { Response.Redirect(Request.Url.AbsolutePath); } } else { PanelDanhSachNhanVienPhuTrach.Visible = true; BindData(); } } else { ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true; ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có nhân viên"; } }
public void LoadData() { _ucCollectionPager_DanhSachPhong.CollectionPager_Object.QueryStringKey = "PageRoom"; listNhanVienPT = NhanVienPT.getQuery().OrderBy(c => c.hoten).ToList(); if (listNhanVienPT.Count > 0) { SearchFunction(); if (Request.QueryString["id"] != null) { Guid id = Guid.Empty; try { id = GUID.From(Request.QueryString["id"]); } catch { Response.Redirect(Request.Url.AbsolutePath); } objNhanVienPT = NhanVienPT.getById(id); if (objNhanVienPT != null) { PanelThongTinNhanVienPhuTrach.Visible = true; Label_MaNhanVien.Text = objNhanVienPT.subId; _ucNhanVien_BreadCrumb.Label_TenNhanVien.Text = Label_HoTen.Text = objNhanVienPT.hoten; Label_SoDienThoai.Text = objNhanVienPT.sodienthoai; Libraries.ImageHelper.LoadImageWeb(objNhanVienPT.hinhanhs.ToList(), _ucASPxImageSlider_Mobile.ASPxImageSlider_Object); List<PTB.Entities.Phong> ListPhong = objNhanVienPT.phongs.ToList(); var list = ListPhong.Select(a => new { id = a.id, ten = string.Format("{0}{1}", a.ten, !Object.Equals(getVitri(a), "") ? " " + getVitri(a) : ""), url = string.Format("http://{0}/Phong.aspx?Search={1}", HttpContext.Current.Request.Url.Authority, a.id.ToString()) }).ToList(); _ucCollectionPager_DanhSachPhong.CollectionPager_Object.DataSource = list; _ucCollectionPager_DanhSachPhong.CollectionPager_Object.BindToControl = RepeaterDanhSachPhong; RepeaterDanhSachPhong.DataSource = _ucCollectionPager_DanhSachPhong.CollectionPager_Object.DataSourcePaged; RepeaterDanhSachPhong.DataBind(); } else { Response.Redirect(Request.Url.AbsolutePath); } } else { PanelDanhSachNhanVienPhuTrach.Visible = true; BindData(); } } else { ucThongBaoLoi.Panel_ThongBaoLoi.Visible = true; ucThongBaoLoi.Label_ThongBaoLoi.Text = "Chưa có nhân viên"; } }
private void button1_Click(object sender, EventArgs e) { XtraReport1 report = new XtraReport1(); //// Add bounded labels to the Detail band of the report. report._bindData(); report._group(); report.DataSource = NhanVienPT.getAll(); ReportPrintTool printTool = new ReportPrintTool(report); printTool.ShowRibbonPreview(); }
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 = ""; }
public void loadData() { try { checkPermission(); editGUI("view"); layout.load(gridViewNhanVien); NhanVienPTs = NhanVienPT.getQuery().OrderBy(c => c.hoten).ToList(); gridControlNhanVien.DataSource = NhanVienPTs; if (NhanVienPTs.Count == 0) { enableButton(false); barBtnThemNhanVien.Enabled = true; } } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
private void setDataView() { try { dxErrorProvider1.ClearErrors(); if (!function.Equals("view")) { editGUI("view"); } if (gridViewNhanVien.RowCount > 0) { if (gridViewNhanVien.FocusedRowHandle > -1 && gridViewNhanVien.GetFocusedRow() != null) { objNhanVienPT = gridViewNhanVien.GetFocusedRow() as NhanVienPT; txtMa.Text = objNhanVienPT.subId; txtTen.Text = objNhanVienPT.hoten; txtSodt.Text = objNhanVienPT.sodienthoai; listPhong = objNhanVienPT.phongs.ToList(); listBoxPhong.DataSource = listPhong; listHinhs = objNhanVienPT.hinhanhs.ToList(); reloadImage(); } else { clearText(); objNhanVienPT = new NhanVienPT(); } } else { enableButton(false); barBtnThemNhanVien.Enabled = true && canAdd; clearText(); objNhanVienPT = new NhanVienPT(); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->setDataView: " + ex.Message); } }
// Load dữ liệu public void loadData() { try { //load layout layout.load(gridViewPhong); canAdd = Permission.canAdd <Phong>(); listVitris = ViTriHienThi.getAll().ToList(); _ucTreeViTri.loadData(listVitris); _ucComboBoxViTri.DataSource = listVitris; _ViTriHienTai = _ucTreeViTri.getVitri(); listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty); gridControlPhong.DataSource = listPhong; if (listPhong.Count() == 0) { deleteData(); enableEdit(false); enableBar(false); } else { getThongTinPhong(true); enableEdit(false); enableBar(true); } listNhanVienPT = NhanVienPT.getAll(); NhanVienPT NhanVienPTNULL = new NhanVienPT(); NhanVienPTNULL.hoten = "[Không có]"; NhanVienPTNULL.id = Guid.Empty; listNhanVienPT.Insert(0, NhanVienPTNULL); searchLookUpEditNhanVienPT.Properties.DataSource = listNhanVienPT; } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
//Xóa hết dữ liệu form thông tin phòng + nhân viên private void deleteData() { setTextGroupControl("Chi tiết phòng", Color.Empty); function = ""; errorProvider1.Clear(); imgPhong.Images.Clear(); listHinhAnhPhong = new List <HinhAnh>(); txtMaPhong.Text = ""; txtTenPhong.Text = ""; txtMoTaPhong.Text = ""; if (listVitris.Count > 0) { _ucComboBoxViTri.ViTri = _ViTriHienTai; } searchLookUpEditNhanVienPT.EditValue = -1; objNhanVienPT = null; imgNhanVien.Images.Clear(); listHinhAnhNhanVien = null; txtMaNhanVien.Text = ""; txtTenNhanVien.Text = ""; txtSoDienThoai.Text = ""; }
private void searchLookUpEditNhanVienPT_EditValueChanged(object sender, EventArgs e) { try { if (searchLookUpEditNhanVienPT.EditValue != null && !searchLookUpEditNhanVienPT.EditValue.Equals(-1)) { Guid id = GUID.From(searchLookUpEditNhanVienPT.EditValue); if (id != Guid.Empty) { objNhanVienPT = NhanVienPT.getById(id); } else { objNhanVienPT = null; } if (objNhanVienPT != null) { txtMaNhanVien.Text = objNhanVienPT.subId; txtTenNhanVien.Text = objNhanVienPT.hoten; txtSoDienThoai.Text = objNhanVienPT.sodienthoai; listHinhAnhNhanVien = objNhanVienPT.hinhanhs.ToList(); reloadImageNhanVienPT(); } else { imgNhanVien.Images.Clear(); txtMaNhanVien.Text = ""; txtTenNhanVien.Text = ""; txtSoDienThoai.Text = ""; } } } catch (Exception ex) { System.Console.WriteLine(this.Name + ": " + ex.Message); } }
//Xóa hết dữ liệu form thông tin phòng + nhân viên private void deleteData() { setTextGroupControl("Chi tiết phòng", Color.Empty); function = ""; errorProvider1.Clear(); imgPhong.Images.Clear(); listHinhAnhPhong = new List<HinhAnh>(); txtMaPhong.Text = ""; txtTenPhong.Text = ""; txtMoTaPhong.Text = ""; if (listVitris.Count > 0) _ucComboBoxViTri.ViTri = _ViTriHienTai; searchLookUpEditNhanVienPT.EditValue = -1; objNhanVienPT = null; imgNhanVien.Images.Clear(); listHinhAnhNhanVien = null; txtMaNhanVien.Text = ""; txtTenNhanVien.Text = ""; txtSoDienThoai.Text = ""; }
// Load dữ liệu public void loadData() { try { //load layout layout.load(gridViewPhong); canAdd = Permission.canAdd<Phong>(); listVitris = ViTriHienThi.getAll().ToList(); _ucTreeViTri.loadData(listVitris); _ucComboBoxViTri.DataSource = listVitris; _ViTriHienTai = _ucTreeViTri.getVitri(); listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty); gridControlPhong.DataSource = listPhong; if (listPhong.Count() == 0) { deleteData(); enableEdit(false); enableBar(false); } else { getThongTinPhong(true); enableEdit(false); enableBar(true); } listNhanVienPT = NhanVienPT.getAll(); NhanVienPT NhanVienPTNULL = new NhanVienPT(); NhanVienPTNULL.hoten = "[Không có]"; NhanVienPTNULL.id = Guid.Empty; listNhanVienPT.Insert(0, NhanVienPTNULL); searchLookUpEditNhanVienPT.Properties.DataSource = listNhanVienPT; } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData: " + ex.Message); } }
private void Function(String _function) { try { if (_function.Equals("edit")) { objNhanVienPT.subId = txtMa.Text; objNhanVienPT.hoten = txtTen.Text; objNhanVienPT.sodienthoai = txtSodt.Text; objNhanVienPT.hinhanhs = listHinhs; if (objNhanVienPT.update() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Sửa nhân viên thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //reLoad(); reLoadAndFocused(objNhanVienPT.id); } else { XtraMessageBox.Show("Sửa nhân viên không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (_function.Equals("add")) { NhanVienPT objNew = new NhanVienPT(); objNew.subId = txtMa.Text; objNew.hoten = txtTen.Text; objNew.sodienthoai = txtSodt.Text; objNew.hinhanhs = listHinhs; if (objNew.add() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Thêm nhân viên thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //reLoad(); reLoadAndFocused(objNew.id); } else { XtraMessageBox.Show("Thêm nhân viên không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (_function.Equals("phancong")) { Guid id = objNhanVienPT.id; try { objNhanVienPT.phongs.Clear(); objNhanVienPT.phongs = listPhong; ////Quan hệ 0 - n nên không thể gán list //List<Phong> listToRemove = objNhanVienPT.phongs.Except(listPhong).ToList(); //List<Phong> listToAdd = listPhong.Except(objNhanVienPT.phongs).ToList(); //foreach (Phong objToRemove in listToRemove) //{ // objToRemove.nhanvienpt = null; // objToRemove.update(); //} //foreach (Phong objToAdd in listToAdd) //{ // objToAdd.nhanvienpt = objNhanVienPT; // objToAdd.update(); //} if (DBInstance.commit() > 0) { XtraMessageBox.Show("Phân công nhân viên thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); editGUI("view"); reLoadAndFocused(id); } else { XtraMessageBox.Show("Phân công nhân viên không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->Function-PhanCong: " + ex.Message); } } } catch (Exception ex) { Debug.WriteLine(this.Name + "->Function: " + ex.Message); } }
private void setDataView() { try { dxErrorProvider1.ClearErrors(); if (!function.Equals("view")) editGUI("view"); if (gridViewNhanVien.RowCount > 0) { if (gridViewNhanVien.FocusedRowHandle > -1 && gridViewNhanVien.GetFocusedRow() != null) { objNhanVienPT = gridViewNhanVien.GetFocusedRow() as NhanVienPT; txtMa.Text = objNhanVienPT.subId; txtTen.Text = objNhanVienPT.hoten; txtSodt.Text = objNhanVienPT.sodienthoai; listPhong = objNhanVienPT.phongs.ToList(); listBoxPhong.DataSource = listPhong; listHinhs = objNhanVienPT.hinhanhs.ToList(); reloadImage(); } else { clearText(); objNhanVienPT = new NhanVienPT(); } } else { enableButton(false); barBtnThemNhanVien.Enabled = true && canAdd; clearText(); objNhanVienPT = new NhanVienPT(); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->setDataView: " + ex.Message); } }
private void Function(String _function) { try { if (_function.Equals("edit")) { objNhanVienPT.subId = txtMa.Text; objNhanVienPT.hoten = txtTen.Text; objNhanVienPT.sodienthoai = txtSodt.Text; objNhanVienPT.hinhanhs = listHinhs; if (objNhanVienPT.update() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Sửa nhân viên thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //reLoad(); reLoadAndFocused(objNhanVienPT.id); } else { XtraMessageBox.Show("Sửa nhân viên không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (_function.Equals("add")) { NhanVienPT objNew = new NhanVienPT(); objNew.subId = txtMa.Text; objNew.hoten = txtTen.Text; objNew.sodienthoai = txtSodt.Text; objNew.hinhanhs = listHinhs; if (objNew.add() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Thêm nhân viên thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //reLoad(); reLoadAndFocused(objNew.id); } else { XtraMessageBox.Show("Thêm nhân viên không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (_function.Equals("phancong")) { Guid id = objNhanVienPT.id; try { objNhanVienPT.phongs.Clear(); objNhanVienPT.phongs = listPhong; ////Quan hệ 0 - n nên không thể gán list //List<Phong> listToRemove = objNhanVienPT.phongs.Except(listPhong).ToList(); //List<Phong> listToAdd = listPhong.Except(objNhanVienPT.phongs).ToList(); //foreach (Phong objToRemove in listToRemove) //{ // objToRemove.nhanvienpt = null; // objToRemove.update(); //} //foreach (Phong objToAdd in listToAdd) //{ // objToAdd.nhanvienpt = objNhanVienPT; // objToAdd.update(); //} if (DBInstance.commit() > 0) { XtraMessageBox.Show("Phân công nhân viên thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); editGUI("view"); reLoadAndFocused(id); } else { XtraMessageBox.Show("Phân công nhân viên không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->Function-PhanCong: " + ex.Message); } } } catch (Exception ex) { Debug.WriteLine(this.Name + "->Function: " + ex.Message); } }
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 searchLookUpEditNhanVienPT_EditValueChanged(object sender, EventArgs e) { try { if (searchLookUpEditNhanVienPT.EditValue != null && !searchLookUpEditNhanVienPT.EditValue.Equals(-1)) { Guid id = GUID.From(searchLookUpEditNhanVienPT.EditValue); if (id != Guid.Empty) objNhanVienPT = NhanVienPT.getById(id); else objNhanVienPT = null; if (objNhanVienPT != null) { txtMaNhanVien.Text = objNhanVienPT.subId; txtTenNhanVien.Text = objNhanVienPT.hoten; txtSoDienThoai.Text = objNhanVienPT.sodienthoai; listHinhAnhNhanVien = objNhanVienPT.hinhanhs.ToList(); reloadImageNhanVienPT(); } else { imgNhanVien.Images.Clear(); txtMaNhanVien.Text = ""; txtTenNhanVien.Text = ""; txtSoDienThoai.Text = ""; } } } catch (Exception ex) { System.Console.WriteLine(this.Name + ": " + ex.Message); } }
public static bool ImportNhanVien(String fileName, String sheet) { try { int line = 0; System.Data.DataTable dt = new System.Data.DataTable(); const int STT = 0; const int MANHANVIEN = 1; const int TENNHANVIEN = 2; const int SODIENTHOAI = 3; const int NGAYTAO = 4; const int HINHANH = 5; const int PASS = 6; 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 Nhân viên... " + String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.0}", (line * 1.0 / lines) * 100) + "%"); if (!row[PASS].Equals("Pass")) { if (row[TENNHANVIEN] != DBNull.Value) { if (NhanVienPT.getAll().FirstOrDefault(c => c.hoten.ToUpper() == row[TENNHANVIEN].ToString().Trim().ToUpper()) == null) { try { NhanVienPT obj = new NhanVienPT(); obj.subId = row[MANHANVIEN] != DBNull.Value ? row[MANHANVIEN].ToString().Trim() : null; obj.hoten = row[TENNHANVIEN].ToString().Trim(); obj.date_create = row[NGAYTAO] != DBNull.Value ? (DateTime?)Convert.ToDateTime(row[NGAYTAO]) : DateTime.Now; obj.sodienthoai = row[SODIENTHOAI].ToString().Trim(); if (row[HINHANH] != DBNull.Value) { String[] file_names = row[HINHANH].ToString().Trim().Split(','); obj.hinhanhs = AddImage(fileName, file_names); } 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 : ImportNhanVien : " + 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 : ImportNhanVien : "+ ex.Message); return false; } }