public frmAddTaiSanExist(DonVi obj) { InitializeComponent(); loadData(); objDonVi = obj; isTaiSan = true; }
public frmAddTaiSan(DonVi obj = null) { InitializeComponent(); //loadData(); init(); ucComboBoxDonVi_DonViN.DonVi = ucComboBoxDonVi1.DonVi = obj; }
public frmReport() { InitializeComponent(); this.Size = new System.Drawing.Size(this.Size.Width, HeightNormal); comboBoxEdit_LoaiBaoCao.SelectedIndex = 0; dateEdit_TuNgay.DateTime = DateTime.Today.Date; dateEdit_DenNgay.DateTime = DateTime.Today.Date; dateEdit_Nam.DateTime = DateTime.Today.Date; ucComboBoxLoaiTS_LoaiTaiSan.showCheck(); ucComboBoxLoaiTS_LoaiTaiSan.DataSource = LoaiTSHienThi.Convert(LoaiTaiSan.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten)); DonVi objNULL = new DonVi(); ListDonVi = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); objNULL.id = Guid.Empty; objNULL.ten = "[Không có đơn vị]"; objNULL.parent = null; ListDonVi.Insert(0, objNULL); ucComboBoxDonVi_ChonDonVi.DataSource = ListDonVi; ucComboBoxDonVi_ChonDonVi.DonVi = objNULL; checkedComboBoxEdit_ChonCoSo.Properties.DataSource = CoSo.getQuery().OrderBy(c => c.order).ToList(); }
public void loadData() { try { List<DonVi> list = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); DonVi objNULL = new DonVi(); objNULL.id = Guid.Empty; objNULL.ten = "[Không có đơn vị]"; objNULL.parent = null; list.Insert(0, objNULL); ucComboBoxDonVi1.DataSource = list; ucComboBoxViTri1.init(false, true); List<ViTriHienThi> listPhong = ViTriHienThi.getAllHavePhong(); ViTriHienThi objPhongNULL = new ViTriHienThi(); objPhongNULL.id = Guid.Empty; objPhongNULL.ten = "[Không có phòng]"; objPhongNULL.loai = typeof(Phong).Name; objPhongNULL.parent_id = Guid.Empty; listPhong.Insert(0, objPhongNULL); ucComboBoxViTri1.DataSource = listPhong; List<ViTriHienThi> listViTri = ViTriHienThi.getAll(); ViTriHienThi objViTriNULL = new ViTriHienThi(); objViTriNULL.id = Guid.Empty; objViTriNULL.ten = "[Không có vị trí]"; objViTriNULL.loai = typeof(CoSo).Name; objViTriNULL.parent_id = Guid.Empty; listViTri.Insert(0, objViTriNULL); ucComboBoxViTri2.DataSource = listViTri; } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData:" + ex.Message); } }
public XtraReport_BienBanGiaoNhanTSCD(CTTaiSan _CTTaiSan, ChungTu _ChungTu, DonVi _DonVi) { InitializeComponent(); this.objCTTaiSan = _CTTaiSan; this.objChungTu = _ChungTu; this.objDonVi = _DonVi; IntReport(); }
public bool themDonVi(DonVi donvi) { try { DonVi dv = new DonVi { MaDonVi = donvi.MaDonVi, TenDonVi = donvi.TenDonVi, MaLoai = donvi.MaLoai, DiaChi = donvi.DiaChi, DienThoai = donvi.DienThoai, NamThanhLap = donvi.NamThanhLap, ChucNang = donvi.ChucNang, NhiemVu = donvi.NhiemVu }; db.DonVis.Add(dv); db.SaveChanges(); return true; } catch { return false; } }
public void loadData() { loadLayout(); gridControlTaiSan.DataSource = null; ucComboBoxLoaiTS1.DataSource = null; ucComboBoxLoaiTS1.DataSource = LoaiTSHienThi.Convert(LoaiTaiSan.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten)); checkedComboBoxCoSo.Properties.DataSource = CoSo.getQuery().OrderBy(c => c.order).ToList(); List<DonVi> list = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); DonVi objNULL = new DonVi(); objNULL.id = Guid.Empty; objNULL.ten = "[Đại học Sài Gòn]"; objNULL.parent = null; list.Insert(0, objNULL); ucComboBoxDonVi1.DataSource = null; ucComboBoxDonVi1.DataSource = list; }
public void loadData() { try { //DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false); //DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu..."); //gridControlTaiSan.DataSource = TaiSanHienThi.getAllNoDonVi(); //DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); ucComboBoxLoaiTS1.DataSource = LoaiTSHienThi.Convert(LoaiTaiSan.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten)); List<DonVi> list = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); DonVi objNULL = new DonVi(); objNULL.id = Guid.Empty; objNULL.ten = "[Không có đơn vị]"; objNULL.parent = null; list.Insert(0, objNULL); ucComboBoxDonVi1.DataSource = list; ucComboBoxDonVi1.DonVi = objNULL; List<ViTriHienThi> listViTri = ViTriHienThi.getAllHavePhong(); ViTriHienThi objNULL2 = new ViTriHienThi(); objNULL2.id = Guid.Empty; objNULL2.ten = "[Không có vị trí]"; objNULL2.parent_id = Guid.Empty; objNULL2.loai = typeof(Phong).Name; listViTri.Insert(0, objNULL2); ucComboBoxViTri1.DataSource = listViTri; checkedCbxTinhTrang.Properties.DataSource = TinhTrang.getQuery().OrderBy(c => c.order).ToList(); //ucComboBoxDonVi2.DonVi = objNULL; ucGridControlTaiSan1.DataSource = null; barBtnSuaTaiSan.Enabled = false; barBtnXoaTaiSan.Enabled = false; btnSua_r.Enabled = false; btnXoa_r.Enabled = false; btnClear.PerformClick(); loadSearchXml(this.Name); Search(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData:" + ex.Message); } }
public List <DonVi> DSDV() { SqlDataReader d = DALHelper.ExecuteReader(DALHelper.ConnectionString, CommandType.StoredProcedure, "tblDonVi_DS", null); List <DonVi> mylist = new List <DonVi>(); while (d.Read()) { DonVi dv = new DonVi(); dv.MaDonVi = d[0].ToString(); dv.TenDonVI = d[1].ToString(); dv.DiaChi = d[2].ToString(); dv.SoDienThoai = d[3].ToString(); dv.TruongDonVI = d[4].ToString(); dv.EMail = d[5].ToString(); dv.Website = d[6].ToString(); mylist.Add(dv); } d.Dispose(); return(mylist); }
public ActionResult Edit(DonVi donvi) { if (ModelState.IsValid) { var dao = new DonViDao(); var result = dao.Update(donvi); if (result) { SetAlert("Chỉnh sửa đơn vị thành công", "success"); return(RedirectToAction("Index", "DonVi")); } else { ModelState.AddModelError("", "cập nhật không thành công"); } } return(View("Index")); }
public void DeleteDonVi(DonVi donvi) { DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString); conn.Open(); try { List <DbParameter> para = new List <DbParameter>(); para.Add(_DbHelper.CreateParameter(FIELD_ID, donvi.ID, false)); _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[DonVi_Delete]", para.ToArray()); } catch (Exception) { throw; } finally { conn.Close(); } }
public void loadData() { try { loadLayout(); //DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false); //DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu..."); //gridControlTaiSan.DataSource = TaiSanHienThi.getAllNoDonVi(); //DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); checkedCbxTinhTrang.Properties.DataSource = TinhTrang.getQuery().OrderBy(c => c.order).ToList(); ucComboBoxLoaiTS1.DataSource = LoaiTSHienThi.Convert(LoaiTaiSan.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten)); List <DonVi> list = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); DonVi objNULL = new DonVi(); objNULL.id = Guid.Empty; objNULL.ten = "[Không có đơn vị]"; objNULL.parent = null; list.Insert(0, objNULL); ucComboBoxDonVi1.DataSource = list; ucComboBoxDonVi1.DonVi = objNULL; List <ViTriHienThi> listViTri = ViTriHienThi.getAllHavePhong(); ViTriHienThi objNULL2 = new ViTriHienThi(); objNULL2.id = Guid.Empty; objNULL2.ten = "[Không có vị trí]"; objNULL2.parent_id = Guid.Empty; objNULL2.loai = typeof(Phong).Name; listViTri.Insert(0, objNULL2); ucComboBoxViTri1.DataSource = listViTri; gridControlHaoMon.DataSource = null; //loadSearchXml(this.Name); //Search(); btnClear.PerformClick(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData:" + ex.Message); } }
public int Sua(DonVi dv) { SqlParameter[] parm = new SqlParameter[] { new SqlParameter(PARM_MADONVI, SqlDbType.NVarChar, 30), new SqlParameter(PARM_TENDONVI, SqlDbType.NVarChar, 30), new SqlParameter(PARM_DIACHI, SqlDbType.NVarChar, 50), new SqlParameter(PARM_SODIENTHOAI, SqlDbType.NVarChar, 30), new SqlParameter(PARM_TRUONGDONVI, SqlDbType.NVarChar, 30), new SqlParameter(PARM_EMAIL, SqlDbType.NVarChar, 40), new SqlParameter(PARM_WEBSITE, SqlDbType.NVarChar, 40) }; parm[0].Value = dv.MaDonVi; parm[1].Value = dv.TenDonVI; parm[2].Value = dv.DiaChi; parm[3].Value = dv.SoDienThoai; parm[4].Value = dv.TruongDonVI; parm[5].Value = dv.EMail; parm[6].Value = dv.Website; return(DALHelper.ExecuteNonQuery(DALHelper.ConnectionString, CommandType.StoredProcedure, "tblDonVi_Sua", parm)); }
public async Task <ActionResult <DonVi> > PostDonVi(DonVi donVi) { _context.DonVi.Add(donVi); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (DonViExists(donVi.MaDonVi)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetDonVi", new { id = donVi.MaDonVi }, donVi)); }
public IActionResult Post([FromBody] DonVi cb) { cb.TrangThai = true; try { DonVi tour = new DonVi() { MaDonVi = cb.MaDonVi, TenDonVi = cb.TenDonVi, DienThoai = cb.DienThoai, TrangThai = cb.TrangThai }; _db.DonVi.Add(tour); _db.SaveChanges(); return(Ok("Them thanh cong")); } catch (Exception) { return(BadRequest()); } }
public HttpResponseMessage Put([FromBody] DonVi DonVi, int id) { var DonViCheck = _repository.Get(id); try { if (DonViCheck != null) { _repository.Update(DonVi, id); return(Request.CreateResponse(HttpStatusCode.OK, DonVi)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "DonVi Not Found")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Lỗi không xác định", ex)); } }
private void lb_ChinhSua_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (lb_ChinhSua.Text == "Chỉnh sửa") { ConvertInfo(true); lb_ChinhSua.Text = "Lưu"; } else { ConvertInfo(false); DonVi donvi = new DonVi(); donvi.TenDonVi = txt_TenDonVi_value.Text; donvi.Website = txt_Website_value.Text; donvi.Facebook = txt_Facebook_value.Text; donvi.DiaChi = txt_DiaChi_value.Text; donvi.SoDienThoai = txt_SoDienThoai_value.Text; donvi.Email = txt_Email_value.Text; donvi.Fax = txt_Fax_value.Text; donvi.MaSoThue = txt_MaSoThue_value.Text; donvi.SoTaiKhoan = txt_SoTaiKhoan_value.Text; donvi.NganHang = txt_NganHang_value.Text; try { if (donvi_client.DonVi_UpdateInfo(donvi)) { MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Cập nhật thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } lb_ChinhSua.Text = "Chỉnh sửa"; LoadData(); } }
public void Search() { DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu..."); try { //String ten = checkTen.Checked ? txtTen.Text : null; //String ten = txtTen.Text; List <Guid> tinhtrangs = CheckedComboBoxEditHelper.getCheckedValueArray(checkedCbxTinhTrang); LoaiTaiSan loai = checkLoaiTS.Checked ? ucComboBoxLoaiTS1.LoaiTS : null; DonVi DVQL = ucComboBoxDonVi1.DonVi; ViTri vitri = ucComboBoxViTri1.ViTri; Phong phong = ucComboBoxViTri1.Phong; bool isViTri = true; if (vitri == null) { isViTri = false; } List <TaiSanHienThi> list = TaiSanHienThi.Convert(CTTaiSanSF.search(null, loai, checkDonVi.Checked, DVQL, false, null, isViTri && checkViTri.Checked, vitri, !isViTri && checkViTri.Checked, phong, checkTinhTrang.Checked ? tinhtrangs : null, (cbxEquationDonGia.EditValue != null && checkDonGia.Checked) ? cbxEquationDonGia.EditValue.ToString() : null, (spinDonGia.EditValue != null && checkDonGia.Checked) ? (long?)long.Parse(spinDonGia.EditValue.ToString()) : null, (cbxEquationNgaySD.EditValue != null && checkNgaySuDung.Checked) ? cbxEquationNgaySD.EditValue.ToString() : null, (dateNgaySD.EditValue != null && checkNgaySuDung.Checked) ? (DateTime?)dateNgaySD.DateTime : null)); //ucGridControlTaiSan1.DataSource = list; gridControlTaiSan.DataSource = list; taisans = list; //bool isEnabled = list.Count > 0; //barBtnSuaTaiSan.Enabled = isEnabled; //barBtnXoaTaiSan.Enabled = isEnabled; //btnSua_r.Enabled = isEnabled; //btnXoa_r.Enabled = isEnabled; //saveSearchXml(this.Name); //ucGridControlTaiSan1.CollapseAllGroups(); gridViewTaiSan.CollapseAllGroups(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->Search:" + ex.Message); } DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); }
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 async Task <ActionResult <BaseResponse> > PostDonVi(DonVi donVi) { try { _context.DonVis.Add(donVi); await _context.SaveChangesAsync(); return(new BaseResponse { Message = "Thêm mới thành công", Data = donVi }); } catch { return(new BaseResponse { ErrorCode = 1, Message = "Thêm mới thất bại" }); } }
public DonVi LayDV(string Ma) { SqlParameter[] parm = new SqlParameter[] { new SqlParameter(PARM_MADONVI, SqlDbType.NVarChar, 30) }; parm[0].Value = Ma; SqlDataReader d = DALHelper.ExecuteReader(DALHelper.ConnectionString, CommandType.StoredProcedure, "tblDonVi_Lay1", parm); DonVi dv = new DonVi(); if (d.Read()) { dv.MaDonVi = d[0].ToString(); dv.TenDonVI = d[1].ToString(); dv.DiaChi = d[2].ToString(); dv.SoDienThoai = d[3].ToString(); dv.TruongDonVI = d[4].ToString(); dv.EMail = d[5].ToString(); dv.Website = d[6].ToString(); } return(dv); }
public void setData(CTTaiSan _objCTTaiSan, DonVi _objDonVi) { try { objCTTaiSan = _objCTTaiSan; //objChungTu = objCTTaiSan.chungtu; txtMaTS.Text = objCTTaiSan.subId; txtTenTS.Text = objCTTaiSan.taisan.ten; //dateNgayGhi.EditValue = objCTTaiSan.ngay; //dateNgay_CT.EditValue = objCTTaiSan.chungtu != null ? objCTTaiSan.chungtu.ngay : null; //txtSoHieu_CT.Text = objCTTaiSan.chungtu != null ? objCTTaiSan.chungtu.sohieu : ""; ucComboBoxDonVi1.DonVi = _objDonVi; txtSoLuong.Properties.MinValue = 1; txtSoLuong.Properties.MaxValue = objCTTaiSan.soluong; txtSoLuong.EditValue = objCTTaiSan.soluong; lbltxtDonViTinh.Text = objCTTaiSan.taisan.loaitaisan.donvitinh != null ? objCTTaiSan.taisan.loaitaisan.donvitinh.ten : ""; } catch (Exception ex) { Debug.WriteLine(this.Name + "->setData:" + ex.Message); } }
public bool Suadonvi(DonVi donvi) { QuanLyLuongEntities csdl = new QuanLyLuongEntities(); try { DonVi dv = csdl.DonVis.SingleOrDefault(n => n.MaDonVi == donvi.MaDonVi); dv.TenDonVi = donvi.TenDonVi; dv.MaLoai = donvi.MaLoai; dv.DienThoai = donvi.DienThoai; dv.DiaChi = donvi.DiaChi; dv.ChucNang = donvi.ChucNang; dv.NhiemVu = donvi.NhiemVu; dv.NamThanhLap = dv.NamThanhLap; csdl.SaveChanges(); } catch { return(false); } return(true); }
protected void btnSave_Click(object sender, EventArgs e) { DonVi dv = new DonVi(); dv.MaDonVi = txtMaDonVi.Text; dv.TenDonVI = txtTenDV.Text; dv.SoDienThoai = txtSDT.Text; dv.TruongDonVI = txtTruongDonVi.Text; dv.Website = txtWeb.Text; dv.DiaChi = txtDiaChi.Text; dv.EMail = txtEmail.Text; if (editType.Value == "add") { int t = d.Them(dv); LoadDV(); } else { d.Sua(dv); LoadDV(); EditState.Value = "hide"; } }
public bool Suadonvi(DonVi donvi) { QuanLyLuongEntities csdl = new QuanLyLuongEntities(); try { DonVi dv = csdl.DonVis.SingleOrDefault(n => n.MaDonVi == donvi.MaDonVi); dv.TenDonVi = donvi.TenDonVi; dv.MaLoai = donvi.MaLoai; dv.DienThoai = donvi.DienThoai; dv.DiaChi = donvi.DiaChi; dv.ChucNang = donvi.ChucNang; dv.NhiemVu = donvi.NhiemVu; dv.NamThanhLap = dv.NamThanhLap; csdl.SaveChanges(); } catch { return false; } return true; }
public void UpdateDonVi(DbTransaction transaction, DonVi donvi) { try { List <DbParameter> para = new List <DbParameter>(); para.Add(_DbHelper.CreateParameter(FIELD_ID, donvi.ID, false)); para.Add(_DbHelper.CreateParameter(FIELD_TENDV, donvi.TenDV, false)); para.Add(_DbHelper.CreateParameter(FIELD_DIACHI, donvi.DiaChi, false)); para.Add(_DbHelper.CreateParameter(FIELD_EMAIL, donvi.Email, false)); para.Add(_DbHelper.CreateParameter(FIELD_PARENTID, donvi.ParentID, false)); para.Add(_DbHelper.CreateParameter(FIELD_PHANLOAI, donvi.PhanLoai, false)); para.Add(_DbHelper.CreateParameter(FIELD_TINH, donvi.Tinh, false)); para.Add(_DbHelper.CreateParameter(FIELD_HUYEN, donvi.Huyen, false)); para.Add(_DbHelper.CreateParameter(FIELD_XA, donvi.Xa, false)); _DbHelper.ExecuteNonQuery(transaction, Common.DatabaseSchema + "[DonVi_Update]", para.ToArray()); } catch (Exception ex) { throw new Exception(String.Format("DonViDataAccess.Update: {0}", ex.Message)); } }
public void Search() { DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu..."); try { //String ten = checkTen.Checked ? txtTen.Text : null; String ten = txtTen.Text; LoaiTaiSan loai = checkLoai.Checked ? ucComboBoxLoaiTS1.LoaiTS : null; DonVi DVQL = ucComboBoxDonVi1.DonVi; ViTri vitri = ucComboBoxViTri1.ViTri; Phong phong = ucComboBoxViTri1.Phong; bool isViTri = true; if (vitri == null) { isViTri = false; } List <Guid> tinhtrangs = CheckedComboBoxEditHelper.getCheckedValueArray(checkedCbxTinhTrang); List <TaiSanHienThi> list = TaiSanHienThi.Convert(CTTaiSanSF.search(checkTenTS.Checked ? ten : "", checkLoai.Checked ? loai : null, checkDVQL.Checked, DVQL, false, null, isViTri && checkViTri.Checked, vitri, !isViTri && checkViTri.Checked, phong, checkTinhTrang.Checked ? tinhtrangs : null)); ucGridControlTaiSan1.DataSource = list; bool isEnabled = list.Count > 0; barBtnSuaTaiSan.Enabled = isEnabled; barBtnXoaTaiSan.Enabled = isEnabled; btnSua_r.Enabled = isEnabled; btnXoa_r.Enabled = isEnabled; saveSearchXml(this.Name); ucGridControlTaiSan1.CollapseAllGroups(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->Search:" + ex.Message); } DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); }
private void loadData() { try { loadDataTinhTrang(); loadDataLoaiTS(); List <DonVi> list = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); DonVi objNULL = new DonVi(); objNULL.id = Guid.Empty; objNULL.ten = "[Không có đơn vị]"; objNULL.parent = null; list.Insert(0, objNULL); ucComboBoxDonVi_DonViN.DataSource = ucComboBoxDonVi1.DataSource = list; ucComboBoxViTri1.init(false, true); ucComboBoxViTri_PhongN.init(false, true); List <ViTriHienThi> listPhong = ViTriHienThi.getAllHavePhong(); ViTriHienThi objPhongNULL = new ViTriHienThi(); objPhongNULL.id = Guid.Empty; objPhongNULL.ten = "[Không có phòng]"; objPhongNULL.loai = typeof(Phong).Name; objPhongNULL.parent_id = Guid.Empty; listPhong.Insert(0, objPhongNULL); ucComboBoxViTri_PhongN.DataSource = ucComboBoxViTri1.DataSource = listPhong; List <ViTriHienThi> listViTri = ViTriHienThi.getAll(); ViTriHienThi objViTriNULL = new ViTriHienThi(); objViTriNULL.id = Guid.Empty; objViTriNULL.ten = "[Không có vị trí]"; objViTriNULL.loai = typeof(CoSo).Name; objViTriNULL.parent_id = Guid.Empty; listViTri.Insert(0, objViTriNULL); ucComboBoxViTri_ViTriN.DataSource = ucComboBoxViTri2.DataSource = listViTri; } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData:" + ex.Message); } }
void LoadTTDV(int maDV) { DonVi dv = this.kho.TimDonVi(maDV); if (dv != default(DonVi)) { //header: lblMaDV.Text = dv.MaDV.ToString(); lblDiaChiDV.Text = dv.DiaChi; lblFaxDV.Text = dv.Fax; lblEmailDV.Text = dv.Email; lblDienThoaiDV.Text = dv.DienThoai; lblTenDV.Text = dv.TenDV; lblWebsite.Text = dv.Website; //thong tin don vi: txtTenDV.Text = dv.TenDV; txtWebsite.Text = dv.Website; txtFax.Text = dv.Fax; txtEmail.Text = dv.Email; txtDC.Text = dv.DiaChi; txtDT.Text = dv.DienThoai; txtWebsite.Text = dv.Website; if (MyUtility.ChuoiHopLe(dv.Logo)) { imgLogo.ImageUrl = string.Format(@"~/images/LogoDV/{0}", dv.Logo); } //load thong tin admin don vi: if (dv.AdminDV != null) { lblHoTenAdmin.Text = dv.AdminDV.HoTen; lblEmailAdmin.Text = dv.AdminDV.Email; lblTenDN.Text = dv.AdminDV.TenDN; lblDienThoaiAdmin.Text = dv.AdminDV.DienThoai; lblGioiTinh.Text = (bool)dv.AdminDV.GioiTinh ? "Nam" : "Nữ"; } } }
protected void btnUpdatePass_Click(object sender, EventArgs e) { //cap nhat mat khau: DonVi dv = this.LayDonViTuQS(); if (dv != default(DonVi) && dv.AdminDV != default(AdminDV)) { if (!txtPass.Text.Equals(txtRePass.Text)) { lblMatKhau.Text = ThongBao.MatKhauKhongTrung; return; } ; dv.AdminDV.MatKhauMD = txtPass.Text; if (!kho.Luu()) { lblMatKhau.Text = ThongBao.SuaKhongThanhCong; } else { lblMatKhau.Text = ThongBao.ThanhCong; } } }
protected void Page_Load(object sender, EventArgs e) { DonVi dv = kho.TimDonVi(1);//test btnCreate.Enabled = !dv.HetTaiKhoan; if (dv.HetTaiKhoan) { lblThongBao.Text = ThongBao.HetSoLuong; return; } if (!this.IsPostBack) { ILEN.View.LoadTrangThai(rblTT); ILEN.View.LoadGioiTinh(rblGT); ILEN.View.Load2DDL(kho.LayDanhSachBoPhanTheoDonVi(1), ddlBP); this.ddlBP_SelectedIndexChanged(null, null); ILEN.View.LoadGioiTinh(rblGT); ILEN.View.Load2DDL(kho.LayDanhSachVaiTro(1), ddlVaiTro); //maDV = 1 (demo) ILEN.View.Load2DDL(kho.LayDanhSachChuyenMon(1), ddlChuyenMon); //maDV = 1 //sinh ma cho tu dong cho nhan vien: string maNV = kho.SinhMaNhanVien(); txtMaNV.Text = maNV; } }
protected void grvDV_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow gvr; try { gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); } catch { return; } int index = gvr.RowIndex; if (e.CommandName == "Sua") { DonVi dv = new DonVi(); GridViewRow gvrow = grvDV.Rows[index]; txtMaDonVi.Enabled = false; txtMaDonVi.Text = HttpUtility.HtmlDecode(gvrow.Cells[0].Text).ToString(); dv = d.LayDV(txtMaDonVi.Text); txtDiaChi.Text = dv.DiaChi; txtEmail.Text = dv.EMail; txtTenDV.Text = dv.TenDonVI; txtWeb.Text = dv.Website; txtTruongDonVi.Text = dv.TruongDonVI; txtSDT.Text = dv.SoDienThoai; EditState.Value = "edit"; editType.Value = "edit"; } if (e.CommandName == "Xoa") { GridViewRow gvrow = grvDV.Rows[index]; string id = HttpUtility.HtmlDecode(gvrow.Cells[0].Text).ToString(); idDelete.Value = id; EditState.Value = "delete"; } }
public bool SuaDonVi(DonVi dv) { try { var kq = TimDonVi(dv.MaDV); if (kq == default(DonVi)) { return(false); } kq.TenDV = dv.TenDV; kq.DiaChi = dv.DiaChi; kq.DienThoai = dv.DienThoai; kq.Fax = dv.Fax; kq.Email = dv.Email; kq.TenDVEN = dv.TenDVEN; kq.TrangThai = dv.TrangThai; kq.Website = dv.Website; return(true); } catch { return(false); } }
private void listB_SangDV_SelectedIndexChanged(object sender, EventArgs e) { if (listB_SangDV.SelectedIndex != -1) { int index = listB_SangDV.SelectedIndex; DonVi dv = new DonVi(); dv = dsDonVi_new[index]; txt_TenDV.Text = dv.TenDonVi; txt_TenDVTat.Text = dv.TenDVVietTat; if (dv.DVChaID != null) { comb_DVTrucThuoc.SelectedValue = dv.DVChaID; } else { comb_DVTrucThuoc.SelectedValue = 0; } if (dv.TuNgay != null) { dTP_NgayHieuLuc.Value = dv.TuNgay.Value; } else { dTP_NgayHieuLuc.Checked = false; } rTB_GhiChu.Text = dv.GhiChu; string ho_ten_nv = ds_tenCNVC[index]; string[] nv_arr = ho_ten_nv.Split(';'); listB_DSNV.Items.Clear(); foreach (string item in nv_arr) { listB_DSNV.Items.Add(item); } } }
public void reloadData() { DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false); DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu..."); try { obj = ucTreeDonVi1.DonVi; //gridControlTaiSan.DataSource = TaiSanHienThi.getAllByDonVi(obj); if (obj != null && obj.id != Guid.Empty) { list = TaiSanHienThi.Convert(obj.getAllCTTaiSanRecursive()); ucGridControlTaiSan1.DataSource = list; bool isEnabled = list.Count > 0; barBtnThemTaiSan.Enabled = true; barBtnSuaTaiSan.Enabled = barBtnXoaTaiSan.Enabled = barBtnChuyen.Enabled = barBtnChuyenTinhTrang.Enabled = isEnabled; } else { ucGridControlTaiSan1.DataSource = null; list = TaiSanHienThi.Convert(CTTaiSan.getQuery().Where(c => c.donviquanly == null && c.soluong > 0)); ucGridControlTaiSan1.DataSource = list; bool isEnabled = list.Count > 0; barBtnThemTaiSan.Enabled = true; barBtnSuaTaiSan.Enabled = barBtnXoaTaiSan.Enabled = barBtnChuyen.Enabled = barBtnChuyenTinhTrang.Enabled = isEnabled; //barBtnThemTaiSan.Enabled = barBtnSuaTaiSan.Enabled = barBtnXoaTaiSan.Enabled = barBtnChuyen.Enabled = barBtnChuyenTinhTrang.Enabled = false; } ucGridControlTaiSan1.CollapseAllGroups(); } catch (Exception ex) { Debug.WriteLine(this.Name + "->reloadData: " + ex.Message); } DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false); }
private void button3_Click(object sender, EventArgs e) { this.Close(); DonVi dv = new DonVi(); dv.Show(); }
protected void Page_Load(object sender, EventArgs e) { var id = Request["ID"]; Item = string.IsNullOrEmpty(id) ? new DonVi() : DonViDal.SelectById(Convert.ToInt32(id)); Add1.Item = Item; }
private void btnOK_Click(object sender, EventArgs e) { try { if (checkInput()) { switch (function) { case "add": objDonVi = new DonVi(); setDataObj(); if (objDonVi.add() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Thêm đơn vị thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Guid id = objDonVi.id; reLoadAndSelectNode(id); } else { XtraMessageBox.Show("Thêm đơn vị không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "edit": setDataObj(); if (objDonVi.update() > 0 && DBInstance.commit() > 0) { XtraMessageBox.Show("Sửa đơn vị thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Guid id = objDonVi.id; reLoadAndSelectNode(id); } else { XtraMessageBox.Show("Sửa đơn vị 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 setDataView() { try { dxErrorProviderInfo.ClearErrors(); if (!function.Equals("view")) editGUI("view"); if (treeListDonVi.Nodes.Count > 0) { if (treeListDonVi.FocusedNode != null && treeListDonVi.GetDataRecordByNode(treeListDonVi.FocusedNode) != null) { objDonVi = treeListDonVi.GetDataRecordByNode(treeListDonVi.FocusedNode) as DonVi; if (objDonVi != null) { txtMa.Text = objDonVi.subId; txtTen.Text = objDonVi.ten; txtMoTa.Text = objDonVi.mota; gridLookUpLoai.EditValue = objDonVi.loaidonvi != null ? objDonVi.loaidonvi.id : Guid.Empty; if (objDonVi.parent != null) _ucComboBoxDonVi.DonVi = objDonVi.parent; else _ucComboBoxDonVi.DonVi = new DonVi(); } else { clearText(); objDonVi = new DonVi(); } } else { clearText(); objDonVi = new DonVi(); } } else { enableButton(false); clearText(); objDonVi = new DonVi(); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->setDataView: " + ex.Message); } }
private void btn_Nhap_Click(object sender, EventArgs e) { if (thongTinQuyetDinh1.txt_MaQD.Text != "") { Business.HDQD.QuyetDinh quyetdinh = new Business.HDQD.QuyetDinh(); quyetdinh.Ma_Quyet_Dinh = thongTinQuyetDinh1.txt_MaQD.Text; quyetdinh.Ten_Quyet_Dinh = thongTinQuyetDinh1.txt_TenQD.Text; quyetdinh.Loai_QuyetDinh_ID = Convert.ToInt16(thongTinQuyetDinh1.comB_Loai.SelectedValue); quyetdinh.Ngay_Ky = thongTinQuyetDinh1.dTP_NgayKy.Value; quyetdinh.Ngay_Hieu_Luc = thongTinQuyetDinh1.dTP_NgayHieuLuc.Value; if (thongTinQuyetDinh1.dTP_NgayHetHan.Checked == true) { quyetdinh.Ngay_Het_Han = thongTinQuyetDinh1.dTP_NgayHetHan.Value; } else { quyetdinh.Ngay_Het_Han = null; } quyetdinh.MoTa = thongTinQuyetDinh1.rTB_MoTa.Text; if (is_Tach_DV == true) // tach don vi { #region Tách đơn vị try { int count = dsDonVi_new.Count; string[] ten_don_vi_moi = new string[count]; string[] ten_dv_viet_tat = new string[count]; int[] dv_cha_id = new int[count]; string[] tu_ngay = new string[count]; string[] ghi_chu = new string[count]; string[] ma_nv = new string[count]; for (int i = 0; i < dsDonVi_new.Count; i++) { DonVi dv = new DonVi(); dv = dsDonVi_new[i]; ten_don_vi_moi[i] = dv.TenDonVi; ten_dv_viet_tat[i] = dv.TenDVVietTat; if (dv.DVChaID != null) { dv_cha_id[i] = dv.DVChaID.Value; } else { dv_cha_id[i] = 0; } tu_ngay[i] = dv.TuNgay.Value.ToString("d", CultureInfo.CreateSpecificCulture("vi-VN")); ma_nv[i] = dsCNVC[i]; } int[] tu_don_vi = new int[1]; ComboBox cbo_DonVi = (ComboBox)tableLP_ComboTuDV.Controls[0]; if (cbo_DonVi.Text != "") { tu_don_vi[0] = Convert.ToInt16(cbo_DonVi.SelectedValue); } else { MessageBox.Show("Vui lòng chọn một đơn vị.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } bool result = quyetdinh.MA_Tach_DonVi(tu_don_vi, ten_don_vi_moi, ten_dv_viet_tat, dv_cha_id, tu_ngay, ghi_chu, ma_nv); if (result == true) { MessageBox.Show("Nhập quyết định tách đơn vị thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Nhập quyết định tách đơn vị không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("Nhập quyết định tách đơn vị không thành công.\r\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } #endregion } else // gộp đơn vị { #region Gộp đơn vị try { int[] tu_don_vi_id = new int[tableLP_ComboTuDV.RowCount]; for (int i = 0; i < tableLP_ComboTuDV.RowCount; i++) { tu_don_vi_id[i] = Convert.ToInt16(((ComboBox)tableLP_ComboTuDV.Controls[i * 2]).SelectedValue); } DonVi dv = new DonVi(); dv = dsDonVi_new[0]; string ten_dv_moi = dv.TenDonVi; string ten_dv_viet_tat = dv.TenDVVietTat; int? dv_cha_id = dv.DVChaID; //if (comb_DVTrucThuoc.Text != "") // dv_cha_id = Convert.ToInt16(comb_DVTrucThuoc.SelectedValue); string tu_ngay = dv.TuNgay.Value.ToString("d", CultureInfo.CreateSpecificCulture("vi-VN")); string ghi_chu = dv.GhiChu; bool result = quyetdinh.MA_Gop_DonVi(tu_don_vi_id, ten_dv_moi, ten_dv_viet_tat, dv_cha_id, tu_ngay, ghi_chu); if (result == true) { MessageBox.Show("Nhập quyết định gộp đơn vị thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Nhập quyết định gộp đơn vị không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("Nhập quyết định gộp đơn vị không thành công.\r\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } #endregion } } else { MessageBox.Show("Vui lòng nhập đầy đủ thông tin.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAddDonVi_Click(object sender, EventArgs e) { DonVi donvi = new DonVi(); donvi.ShowDialog(); LoadDonVi(); }
public void loadData() { try { editGUI("view"); listDonVi = DonVi.getQuery().OrderBy(c => c.parent_id).ThenBy(c => c.ten).ToList(); treeListDonVi.DataSource = listDonVi; loadLoaiDonVi(); DonVi DonViNULL = new DonVi(); DonViNULL.id = Guid.Empty; DonViNULL.ten = "[Đại học Sài Gòn]"; DonViNULL.parent = null; List<DonVi> listDonViParent = new List<DonVi>(listDonVi); listDonViParent.Insert(0, DonViNULL); _ucComboBoxDonVi.DataSource = listDonViParent; if (listDonVi.Count == 0) { enableButton(false); } } catch (Exception ex) { Debug.WriteLine(this.Name + "->loadData:" + ex.Message); } }
protected override void BindOtherValue() { DonVi.BindData(DepartmentServices.GetList().ToList <object>(), "DepartmentID", "DepartmentName", "DepartmentGroupName"); }
public static bool ImportDonVi(String fileName, String sheetDonVi) { try { DonVi objDonVi = null; System.Data.DataTable dt = new System.Data.DataTable(); const int STT = 0; const int SUBID = 1; const int TEN = 2; const int PARENT = 3; const int LOAI = 4; const int PASS = 5; dt = OpenFile(fileName, sheetDonVi); if (dt != null) { foreach (System.Data.DataRow row in dt.Rows) { if (row[PASS] == DBNull.Value || !row[PASS].Equals("Pass")) { if (row[SUBID] != DBNull.Value && row[TEN] != DBNull.Value && row[LOAI] != DBNull.Value) { try { String _subId = row[SUBID].ToString().Trim().ToUpper(); DonVi obj2 = DonVi.getQuery().Where(c => c.subId.ToUpper().Equals(_subId)).FirstOrDefault(); if (obj2 == null) { DonVi obj = new DonVi(); obj.subId = row[SUBID] != DBNull.Value ? row[SUBID].ToString().Trim() : null; obj.ten = row[TEN].ToString().Trim(); obj.parent = row[PARENT] != DBNull.Value ? getParent(row[PARENT].ToString()) : null; obj.loaidonvi = getLoaiDonVi(row[LOAI].ToString()); if (obj.add() > 0 && DBInstance.commit() > 0) { objDonVi = obj; WriteFile(fileName, sheetDonVi, row[STT].ToString().Trim(), "Pass"); } else { WriteFile(fileName, sheetDonVi, row[STT].ToString().Trim(), "Error"); } } else { objDonVi = obj2; WriteFile(fileName, sheetDonVi, row[STT].ToString().Trim(), "Exist"); } } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportDonVi: " + ex.Message); WriteFile(fileName, sheetDonVi, row[STT].ToString().Trim(), "Error"); } } else { WriteFile(fileName, sheetDonVi, row[STT].ToString().Trim(), "Error (Không đủ thông tin)"); } } } } return true; } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportDonVi: " + ex.Message); return false; } }
public int Update(DonVi dv1) { return(dv.Update(dv1)); }
public int ThemDV(DonVi dv1) { return(dv.ThemDV(dv1)); }
public static bool ImportTaiSan(String fileName, String sheet, DonVi objDonVi = null) { try { int line = 0; System.Data.DataTable dt = new System.Data.DataTable(); const int STT = 0; const int SUBID = 1; const int TEN = 2; const int NSX = 3; const int NGAY = 4; const int DONGIA = 5; const int PASS = 6; const int PHONG = 7; LoaiTaiSan objLoaiTS = null; 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("Đang Import... " + String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.00}", (line * 1.0 / lines) * 100) + "%"); if (row[PASS] == DBNull.Value || !row[PASS].Equals("Pass")) { if (row[TEN] != DBNull.Value && !String.IsNullOrWhiteSpace(row[TEN].ToString())) { if (row[SUBID] == DBNull.Value || String.IsNullOrWhiteSpace(row[SUBID].ToString())) { objLoaiTS = getLoai(row[TEN].ToString()); } else { try { if (objDonVi == null) { TaiSan obj = new TaiSan(); obj.subId = row[SUBID].ToString().Trim(); obj.ten = row[TEN].ToString().Trim(); obj.nuocsx = row[NSX] != DBNull.Value ? row[NSX].ToString().Trim() : ""; String str = row[DONGIA].ToString().Trim().Replace(" ", ""); long dongia = long.Parse(str); obj.dongia = dongia; obj.loaitaisan = objLoaiTS; CTTaiSan objCTTaiSan = new CTTaiSan(); objCTTaiSan.chungtu = new ChungTu(); objCTTaiSan.taisan = obj; objCTTaiSan.ngay = row[NGAY] != DBNull.Value ? (DateTime?)Convert.ToDateTime(row[NGAY]) : null; if (TinhTrang.getQuery().FirstOrDefault(c => c.value.Equals("Đang sử dụng")) == null) { TinhTrang objTinhTrang = new TinhTrang(); objTinhTrang.value = "Đang sử dụng"; objTinhTrang.add(); DBInstance.commit(); } objCTTaiSan.tinhtrang = TinhTrang.getQuery().FirstOrDefault(c => c.value.Equals("Đang sử dụng")); objCTTaiSan.soluong = 1; if (objCTTaiSan.add() > 0 && DBInstance.commit() > 0) { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass"); } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error"); } } else { String subId = row[SUBID].ToString().Trim().ToUpper(); TaiSan obj = TaiSan.getQuery().Where(c => c.subId.ToString().ToUpper().Equals(subId)).FirstOrDefault(); if (obj != null) { CTTaiSan objCTTaiSan2 = CTTaiSan.getQuery().Where(c => c.taisan_id == obj.id).FirstOrDefault(); if (objCTTaiSan2 != null) { Phong objPhong = null; ViTri objViTri = null; if(row[PHONG] != DBNull.Value) { string phong = row[PHONG].ToString().Trim(); objPhong = Phong.getQuery().Where(c => c.ten.Equals(phong)).FirstOrDefault(); if (objPhong == null) { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có phòng)"); continue; } else objViTri = objPhong.vitri; } if (objCTTaiSan2.chuyenDonVi(objDonVi, null, objViTri, objPhong, objCTTaiSan2.parent, objCTTaiSan2.chungtu, objCTTaiSan2.soluong, "", objCTTaiSan2.ngay) != null && DBInstance.commit() > 0) { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass"); } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error"); } } else { CTTaiSan objCTTaiSan = new CTTaiSan(); objCTTaiSan.taisan = obj; objCTTaiSan.chungtu = new ChungTu(); objCTTaiSan.ngay = row[NGAY] != DBNull.Value ? (DateTime?)Convert.ToDateTime(row[NGAY]) : null; if (TinhTrang.getQuery().FirstOrDefault(c => c.value.Equals("Đang sử dụng")) == null) { TinhTrang objTinhTrang = new TinhTrang(); objTinhTrang.value = "Đang sử dụng"; objTinhTrang.add(); DBInstance.commit(); } objCTTaiSan.tinhtrang = TinhTrang.getQuery().FirstOrDefault(c => c.value.Equals("Đang sử dụng")); objCTTaiSan.soluong = 1; if (objCTTaiSan.add() > 0) { Phong objPhong = null; ViTri objViTri = null; if (row[PHONG] != DBNull.Value) { string phong = row[PHONG].ToString().Trim(); objPhong = Phong.getQuery().Where(c => c.ten.Equals(phong)).FirstOrDefault(); if (objPhong == null) { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có phòng)"); continue; } else objViTri = objPhong.vitri; } if (objCTTaiSan.chuyenDonVi(objDonVi, null, objViTri, objPhong, objCTTaiSan.parent, objCTTaiSan.chungtu, objCTTaiSan.soluong, "", objCTTaiSan.ngay) != null && 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"); } } } else { obj = new TaiSan(); obj.subId = row[SUBID].ToString().Trim(); obj.ten = row[TEN].ToString().Trim(); obj.nuocsx = row[NSX] != DBNull.Value ? row[NSX].ToString().Trim() : ""; String str = row[DONGIA].ToString().Trim().Replace(" ", ""); long dongia = long.Parse(str); obj.dongia = dongia; obj.loaitaisan = objLoaiTS; CTTaiSan objCTTaiSan = new CTTaiSan(); objCTTaiSan.taisan = obj; objCTTaiSan.ngay = row[NGAY] != DBNull.Value ? (DateTime?)Convert.ToDateTime(row[NGAY]) : null; if (TinhTrang.getQuery().FirstOrDefault(c => c.value.Equals("Đang sử dụng")) == null) { TinhTrang objTinhTrang = new TinhTrang(); objTinhTrang.value = "Đang sử dụng"; objTinhTrang.add(); DBInstance.commit(); } objCTTaiSan.tinhtrang = TinhTrang.getQuery().FirstOrDefault(c => c.value.Equals("Đang sử dụng")); objCTTaiSan.soluong = 1; if (objCTTaiSan.add() > 0) { Phong objPhong = null; ViTri objViTri = null; if (row[PHONG] != DBNull.Value) { string phong = row[PHONG].ToString().Trim(); objPhong = Phong.getQuery().Where(c => c.ten.Equals(phong)).FirstOrDefault(); if (objPhong == null) { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có phòng)"); continue; } else objViTri = objPhong.vitri; } if (objCTTaiSan.chuyenDonVi(objDonVi, null, objViTri, objPhong, objCTTaiSan.parent, objCTTaiSan.chungtu, objCTTaiSan.soluong, "", objCTTaiSan.ngay) != null && 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"); } } } } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportTaiSan: " + ex.Message); WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error"); } } } else { WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không đủ thông tin)"); } } } } return true; } catch (Exception ex) { Debug.WriteLine("ExcelDataBaseHelper->ImportTaiSan: " + ex.Message); return false; } }
private Object GetData_SoTheoDoiTaiSanCoDinhTaiNoiSuDung(Guid DonViId) { ResetDbContext(); int Year = DateTime.Today.Year; DonVi DonViSelected = MyNewDbContext.DONVIS.Find(DonViId); if (Object.Equals(DonViSelected, null)) { return(null); } var IQueryable = DonViSelected.getAllCTTaiSanRecursive_All(); IQueryable = IQueryable.Where(item => Object.Equals(item.ngay, null) == false); IQueryable = IQueryable.Where(item => ((DateTime)item.ngay).Year <= Year); var DataFiltered_Groups = IQueryable.OrderByDescending(item => item.date_create).GroupBy(item => item.taisan_id).ToList(); List <TSCD.DataFilter.ReportFilter.SoTheoDoiTaiSanCoDinhTaiNoiSuDung_DataFilter> Data = new List <TSCD.DataFilter.ReportFilter.SoTheoDoiTaiSanCoDinhTaiNoiSuDung_DataFilter>(); foreach (var _Group in DataFiltered_Groups) { int intCount = _Group.Count(); TSCD.DataFilter.ReportFilter.SoTheoDoiTaiSanCoDinhTaiNoiSuDung_DataFilter item = new TSCD.DataFilter.ReportFilter.SoTheoDoiTaiSanCoDinhTaiNoiSuDung_DataFilter(); if (intCount == 1) { //CTTS nay la tang tai san, neu la giam thi ... -_- item.sohieu_ct = _Group.ElementAt(0).chungtu != null?_Group.ElementAt(0).chungtu.sohieu : ""; item.ngay_ct = _Group.ElementAt(0).chungtu != null?_Group.ElementAt(0).chungtu.ngay : null; item.ten = _Group.ElementAt(0).taisan.ten; item.donvitinh = _Group.ElementAt(0).taisan.loaitaisan.donvitinh != null?_Group.ElementAt(0).taisan.loaitaisan.donvitinh.ten : ""; if (_Group.ElementAt(0).tinhtrang.giam_taisan) { item.soluong_giam = (int?)_Group.ElementAt(0).soluong; item.dongia_giam = (long?)_Group.ElementAt(0).taisan.dongia; item.thanhtien_giam = (long?)_Group.ElementAt(0).soluong *_Group.ElementAt(0).taisan.dongia; item.ghichu = _Group.ElementAt(0).mota; } item.soluong_tang = (int?)_Group.ElementAt(0).soluong; item.dongia_tang = (long?)_Group.ElementAt(0).taisan.dongia; item.thanhtien_tang = (long?)_Group.ElementAt(0).soluong *_Group.ElementAt(0).taisan.dongia; Data.Add(item); } else if (intCount > 1) { int intSoLuongGiam = 0, intSoLuongTang = 0; foreach (var CTTS in _Group) { if (CTTS.tinhtrang.giam_taisan) { intSoLuongGiam += CTTS.soluong; } else { intSoLuongTang += CTTS.soluong; } } //Cung la 1 tai san nen lay o vi tri 0 item.sohieu_ct = _Group.ElementAt(0).chungtu != null?_Group.ElementAt(0).chungtu.sohieu : ""; item.ngay_ct = _Group.ElementAt(0).chungtu != null?_Group.ElementAt(0).chungtu.ngay : null; item.ten = _Group.ElementAt(0).taisan.ten; item.donvitinh = _Group.ElementAt(0).taisan.loaitaisan.donvitinh != null?_Group.ElementAt(0).taisan.loaitaisan.donvitinh.ten : ""; if (intSoLuongTang > 0) { item.soluong_tang = intSoLuongTang; item.dongia_tang = (long?)_Group.ElementAt(0).taisan.dongia; item.thanhtien_tang = (long?)intSoLuongTang * _Group.ElementAt(0).taisan.dongia; } if (intSoLuongGiam > 0) { item.soluong_giam = intSoLuongGiam; item.dongia_giam = (long?)_Group.ElementAt(0).taisan.dongia; item.thanhtien_giam = (long?)intSoLuongGiam * _Group.ElementAt(0).taisan.dongia; } item.ghichu = _Group.ElementAt(0).tinhtrang.giam_taisan ? _Group.ElementAt(0).mota : ""; Data.Add(item); } } return(Data.OrderBy(item => item.ngay_ct).ToList()); }