/// <summary> /// Đưa dữ liệu từ form vào object DM_PHAN_HE_GD /// </summary> /// <param name="banghi">Trạng thái bản ghi</param> /// <param name="nghiepvu">Trạng thái nghiệp vụ</param> /// <param name="nguoi_cnhap">Tên người cập nhật</param> /// <returns></returns> private Presentation.Process.DanhMucServiceRef.DM_PHAN_HE_GD LayDuLieu(BusinessConstant.TrangThaiNghiepVu nghiepvu, string nguoi_cnhat) { Presentation.Process.DanhMucServiceRef.DM_PHAN_HE_GD obj = new Presentation.Process.DanhMucServiceRef.DM_PHAN_HE_GD(); if (idPhanHeGD != 0) { obj.ID = idPhanHeGD; } obj.MA_LOAI_GDICH = txtMaLoaiGD.Text; obj.TEN_LOAI_GDICH = txtTenLoaiGD.Text; obj.TEN_TAT = txtTentat.Text; obj.MA_PHAN_HE = cmbPhanHe.SelectedValue.ToString(); obj.ID_PHAN_HE = 0; //obj.TTHAI_BGHI = cmbTrangThaiSDung.SelectedValue.ToString(); obj.TTHAI_NVU = BusinessConstant.layGiaTri(nghiepvu); obj.MA_DVI_TAO = Presentation.Process.Common.ClientInformation.MaDonVi; obj.MA_DVI_QLY = Presentation.Process.Common.ClientInformation.MaDonVi; if (!LString.IsNullOrEmptyOrSpace(nguoi_cnhat)) { obj.NGUOI_CNHAT = nguoi_cnhat; obj.NGAY_CNHAT = LDateTime.GetCurrentDate(ApplicationConstant.defaultDateTimeFormat); } else { obj.NGUOI_NHAP = Presentation.Process.Common.ClientInformation.TenDangNhap; obj.NGAY_NHAP = LDateTime.GetCurrentDate(ApplicationConstant.defaultDateTimeFormat); } return(obj); }
/// <summary> /// Lưu dữ liệu /// </summary> private void Luu(BusinessConstant.TrangThaiNghiepVu nghiepvu, string nguoi_cnhat) { if (Validation()) { DanhMucProcess danhmucProcess = new DanhMucProcess(); try { // Lấy dữ liệu từ giao diện đưa vào object Presentation.Process.DanhMucServiceRef.DM_PHAN_HE_GD obj = new Presentation.Process.DanhMucServiceRef.DM_PHAN_HE_GD(); obj = LayDuLieu(nghiepvu, nguoi_cnhat); // Lưu dữ liệu if (idPhanHeGD == 0) { if (!danhmucProcess.checkMaDonViDaSuDung(obj.MA_LOAI_GDICH)) { if (danhmucProcess.ThemPhanHeGD(obj) != null) { LMessage.ShowMessage("M.DanhMuc.ucPhanHeGDCT.LuuDuLieuThanhCong", LMessage.MessageBoxType.Information); idPhanHeGD = obj.ID; if (cbMultiAdd.IsChecked == true) { ResetForm(); idPhanHeGD = 0; } else { Dong(); } } else { LMessage.ShowMessage("M.DanhMuc.ucPhanHeGDCT.LuuDuLieuKoThanhCong", LMessage.MessageBoxType.Error); } } else { LMessage.ShowMessage("M.DanhMuc.ucPhanHeGDCT.MaDonViDaDuocSuDung", LMessage.MessageBoxType.Warning); txtMaLoaiGD.Focus(); } } else { if (danhmucProcess.SuaPhanHeGD(obj) != null) { LMessage.ShowMessage("M.DanhMuc.ucPhanHeGDCT.LuuDuLieuThanhCong", LMessage.MessageBoxType.Information); } else { LMessage.ShowMessage("M.DanhMuc.ucPhanHeGDCT.LuuDuLieuKoThanhCong", LMessage.MessageBoxType.Error); } Dong(); } } catch (System.Exception ex) { LMessage.ShowMessage("M.DanhMuc.ucPhanHeGDCT.LoiLuuDuLieu", LMessage.MessageBoxType.Error); LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); } finally { danhmucProcess = null; } } }