예제 #1
0
        public void onSave()
        {
            this.Cursor = Cursors.Wait;
            try
            {
                if (ValidateValue())
                {
                    HT_TSO ret = null;
                    QuanTriHeThongProcess process = new QuanTriHeThongProcess();

                    // Nếu là thêm mới
                    if (id == 0)
                    {
                        //getObject(DatabaseConstant.Action.THEM);
                        //ret = process.ThemNSD(obj, lstIdNHNSD);
                        //afterAddNew(ret);
                    }
                    // Nếu là sửa
                    else
                    {
                        getObjectValue(DatabaseConstant.Action.SUA);
                        ret = process.capNhatGiaTriThamSo(obj);
                        afterModify(ret);
                    }
                }
            }
            catch (System.Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }
예제 #2
0
        public HT_TSO SuaGiaTriThamSo(HT_TSO obj)
        {
            HT_TSO    kq       = null;
            Entities  entities = ContextFactory.GetInstance();
            EntityKey key      = null;
            object    original = null;

            try
            {
                key = entities.CreateEntityKey(ENTITY_SET_NAME, obj);
                if (entities.TryGetObjectByKey(key, out original))
                {
                    entities.ApplyCurrentValues(key.EntitySetName, obj);
                }
                entities.SaveChanges();
                kq = obj;
            }
            catch (System.Exception ex)
            {
                kq = null;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #3
0
        public bool ThoaiDuyetListTheoID(List <int> listID)
        {
            bool     kq       = true;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    foreach (int id in listID)
                    {
                        HT_TSO obj = new HT_TSO();
                        obj           = entities.HT_TSO.FirstOrDefault(e => e.ID == id);
                        obj.TTHAI_NVU = BusinessConstant.TrangThaiNghiepVu.THOAI_DUYET.layGiaTri();
                        entities.SaveChanges();
                    }
                    trans.Complete();
                }
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #4
0
        public bool XoaListTheoID(List <int> listID)
        {
            bool     kq       = true;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    foreach (int id in listID)
                    {
                        HT_TSO obj = new HT_TSO();
                        obj = entities.HT_TSO.FirstOrDefault(e => e.ID == id);
                        entities.HT_TSO.DeleteObject(obj);
                        entities.SaveChanges();
                    }
                    trans.Complete();
                }
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #5
0
 public HT_TSO layThamSoDonVi(BusinessConstant.LoaiThamSo loaiThamSo, BusinessConstant.MaThamSo maThamSo, string maDonVi)
 {
     try
     {
         HT_TSO   htTso         = null;
         Entities entities      = ContextFactory.GetInstance();
         string   strLoaiThamSo = loaiThamSo.layGiaTri();
         string   strMaThamSo   = maThamSo.layGiaTri();
         //htTso = entities.HT_TSO.FirstOrDefault(e => e.MA_TSO_LOAI.Equals(strLoaiThamSo) && e.MA_TSO.Equals(strMaThamSo) && e.MA_DVI_QLY.Equals(maDonVi));
         htTso = entities.HT_TSO.Where(e => e.MA_TSO_LOAI.Equals(strLoaiThamSo) && e.MA_TSO.Equals(strMaThamSo) && e.MA_DVI_QLY.Equals(maDonVi)).ToList().FirstOrDefault();
         return(htTso);
     }
     catch (Exception ex)
     {
         // Ghi log
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
         throw ex;
     }
 }
예제 #6
0
        public HT_TSO GetByMa(string ma)
        {
            HT_TSO   kq       = null;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                kq = entities.HT_TSO.FirstOrDefault(e => e.MA_TSO.Equals(ma));
                return(kq);
            }
            catch (System.Exception ex)
            {
                kq = null;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #7
0
        /// <summary>
        /// Thêm đối tượng Tham số
        /// </summary>
        /// <param name="obj">Đối tượng Tham số</param>
        /// <returns>True nếu thành công, false ngược lại</returns>
        public bool Them(HT_TSO obj)
        {
            bool     kq       = true;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                entities.HT_TSO.AddObject(obj);
                entities.SaveChanges();
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #8
0
        /// <summary>
        /// Sau khi sửa
        /// </summary>
        /// <param name="ret"></param>
        private void afterModify(HT_TSO ret)
        {
            if (ret != null)
            {
                LMessage.ShowMessage("M.DungChung.CapNhatThanhCong", LMessage.MessageBoxType.Information);

                id       = ret.ID;
                TthaiNvu = ret.TTHAI_NVU;

                lblTrangThai.Content = BusinessConstant.layNgonNguSuDung(ret.TTHAI_BGHI);
                txtTrangThai.Text    = BusinessConstant.layNgonNguSuDung(ret.TTHAI_BGHI);
                raddtNgayNhap.Value  = LDateTime.StringToDate(obj.NGAY_NHAP, "yyyyMMdd");
                txtNguoiLap.Text     = obj.NGUOI_NHAP;
                raddtNgayCNhat.Value = LDateTime.StringToDate(obj.NGAY_CNHAT, "yyyyMMdd");
                txtNguoiCapNhat.Text = obj.NGUOI_CNHAT;
                CommonFunction.RefreshButton(Toolbar, DatabaseConstant.Action.XEM, tthaiNvu, mnuMain, DatabaseConstant.Function.HT_THAM_SO);
                formCase = "XEM";
                HideControl();
            }
            else
            {
                LMessage.ShowMessage("M.DungChung.CapNhatKoThanhCong", LMessage.MessageBoxType.Error);
            }

            // Yêu cầu Unlock bản ghi cần sửa
            UtilitiesProcess process    = new UtilitiesProcess();
            List <int>       listLockId = new List <int>();

            listLockId.Add(id);

            bool retUnlockData = process.UnlockData(DatabaseConstant.Module.QTHT,
                                                    DatabaseConstant.Function.HT_THAM_SO,
                                                    DatabaseConstant.Table.HT_TSO,
                                                    DatabaseConstant.Action.SUA,
                                                    listLockId);
        }
예제 #9
0
 public void getObject(DatabaseConstant.Action action)
 {
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj == null)
         {
             obj = new HT_TSO();
         }
         //obj.MA_TSO_LOAI = txtMaLoaiThamSo.Text;
         //obj.ID_TSO_LOAI = idLoai;
         obj.MA_TSO          = txtMaThamSo.Text;
         obj.TEN_TSO         = txtTenThamSo.Text;
         obj.PVI_AHUONG      = lstSourcePhamVi.ElementAt(cmbPhamViAHuong.SelectedIndex).KeywordStrings.First();
         obj.MO_TA           = txtMoTaThamSo.Text;
         obj.MA_DVI_QLY      = ClientInformation.MaDonVi;
         obj.MA_DVI_TAO      = ClientInformation.MaDonVi;
         obj.HTHI_DIEU_KHIEN = lstSourceLoaiControl.ElementAt(cmbHienThiTren.SelectedIndex).KeywordStrings.First();
         obj.HTHI_GTRI_MDINH = txtGiaTriMacDinh.Text;
         obj.GIA_TRI         = txtGiaTri.Text;
         //if (rbtCodeQuery.IsChecked == true)
         //{
         //    obj.HTHI_POPUP = BusinessConstant.CoKhong.CO.layGiaTri();
         //    obj.HTHI_SDUNG_TVAN = BusinessConstant.CoKhong.CO.layGiaTri();
         //}
         //else
         //{
         obj.HTHI_POPUP      = BusinessConstant.CoKhong.KHONG.layGiaTri();
         obj.HTHI_SDUNG_TVAN = BusinessConstant.CoKhong.KHONG.layGiaTri();
         //}
         //if (rbtSQLQuery.IsChecked == true)
         //    obj.HTHI_SQL = BusinessConstant.CoKhong.CO.layGiaTri();
         //else
         obj.HTHI_SQL = BusinessConstant.CoKhong.KHONG.layGiaTri();
         //obj.ID_PHAN_HE = Convert.ToInt32(lstSourcePhanHe.ElementAt(cmbThuocPhanHe.SelectedIndex).KeywordStrings.ElementAt(1));
         obj.MA_PHAN_HE   = lstSourcePhanHe.ElementAt(cmbThuocPhanHe.SelectedIndex).KeywordStrings.First();
         obj.KIEU_DU_LIEU = lstSourceKieuDL.ElementAt(cmbKieuDuLieu.SelectedIndex).KeywordStrings.First();
         obj.TTHAI_BGHI   = BusinessConstant.TrangThaiBanGhi.SU_DUNG.layGiaTri();
         obj.NGAY_CNHAT   = string.IsNullOrEmpty(raddtNgayCNhat.Value.ToString().Trim()) ? ((DateTime)raddtNgayCNhat.Value).ToString("yyyyMMdd") : (DateTime.Today).ToString("yyyyMMdd");
         if (obj.ID == 0)
         {
             obj.NGAY_NHAP  = string.IsNullOrEmpty(raddtNgayCNhat.Value.ToString().Trim()) ? ((DateTime)raddtNgayNhap.Value).ToString("yyyyMMdd") : (DateTime.Today).ToString("yyyyMMdd");
             obj.NGUOI_NHAP = ClientInformation.TenDangNhap;
         }
         obj.NGUOI_CNHAT  = ClientInformation.TenDangNhap;
         obj.NGUON_TAO_DL = "NSD";
         string strTTNV = string.Empty;
         if (obj.ID > 0)
         {
             strTTNV = obj.TTHAI_NVU;
         }
         obj.TTHAI_NVU  = CommonFunction.LayTrangThaiBanGhi(action, BusinessConstant.layTrangThaiNghiepVu(strTTNV));
         obj.TTHAI_BGHI = BusinessConstant.TrangThaiBanGhi.SU_DUNG.layGiaTri();
     }
     catch (System.Exception ex)
     {
         CommonFunction.ThongBaoLoi(ex);
         LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
     }
     Mouse.OverrideCursor = Cursors.Arrow;
 }