Ejemplo n.º 1
0
        /// <summary>
        /// Trước khi xóa
        /// </summary>
        private void BeforeDelete()
        {
            try
            {
                List <DataRowView> listDataRow = getListSeletedDataRow();

                if (listDataRow != null)
                {
                    if (listDataRow.Count == 0)
                    {
                        LMessage.ShowMessage("M.DungChung.ChuaChonBanGhi", LMessage.MessageBoxType.Warning);
                        return;
                    }
                    else
                    {
                        // Lấy danh sách dữ liệu cần xử lý
                        List <int> listId = new List <int>();
                        foreach (DataRowView dr in listDataRow)
                        {
                            int id = int.Parse(dr["id"].ToString());
                            listId.Add(id);
                        }

                        // Cảnh báo người dùng
                        MessageBoxResult ret = LMessage.ShowMessage("M.DungChung.HoiXoa", LMessage.MessageBoxType.Question);
                        if (ret == MessageBoxResult.Yes)
                        {
                            // Yêu cầu lock bản ghi cần xử lý
                            UtilitiesProcess process      = new UtilitiesProcess();
                            List <int>       listLockedId = new List <int>();

                            bool retLockData = process.LockData(DatabaseConstant.Module.NSTL,
                                                                DatabaseConstant.Function.NS_DM_DVI_TGIAN_DS,
                                                                DatabaseConstant.Table.NS_DM_DVI_TGIAN,
                                                                DatabaseConstant.Action.XOA,
                                                                listId);

                            // Nếu lock thành công >> cho phép xử lý
                            if (retLockData)
                            {
                                OnDelete(listId);
                            }
                            else
                            {
                                LMessage.ShowMessage("M.ResponseMessage.Common.LockDataInvalid", LMessage.MessageBoxType.Information);
                            }
                        }
                    }
                }
                else
                {
                    LMessage.ShowMessage("M.DungChung.LoiChonDuLieu", LMessage.MessageBoxType.Warning);
                    return;
                }
            }
            catch (Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
        }
        void Duyet()
        {
            if (!tlbApprove.IsEnabled)
            {
                return;
            }
            Cursor = Cursors.Wait;
            List <int>       lstID       = new List <int>();
            UtilitiesProcess process     = new UtilitiesProcess();
            bool             retLockData = false;

            try
            {
                if (raddgrHDTDDS.SelectedItems.Count > 0)
                {
                    if (LMessage.ShowMessage("M.DungChung.HoiDuyet", LMessage.MessageBoxType.Question) == MessageBoxResult.Yes)
                    {
                        List <TD_HDTDVM> lstHDTDVM = new List <TD_HDTDVM>();

                        List <string> lstSoGiaoDich = new List <string>();
                        foreach (DataRowView dr in raddgrHDTDDS.SelectedItems)
                        {
                            if (!lstSoGiaoDich.Contains(dr["SO_GDICH"].ToString()))
                            {
                                lstID.Add(Convert.ToInt32(dr["ID"]));
                                objHDTDVM.HDTD_VM           = new TD_HDTDVM();
                                objHDTDVM.HDTD_VM.ID        = Convert.ToInt32(dr["ID"]);
                                objHDTDVM.HDTD_VM.MA_HDTDVM = dr["MA_HDTDVM"].ToString();
                                objHDTDVM.HDTD_VM.TTHAI_NVU = dr["TTHAI_NVU"].ToString();
                                objHDTDVM.HDTD_VM.SO_GDICH  = dr["SO_GDICH"].ToString();
                                lstSoGiaoDich.Add(dr["SO_GDICH"].ToString());
                                lstHDTDVM.Add(objHDTDVM.HDTD_VM);
                            }
                        }
                        objHDTDVM.DSACH_HDTD_VM = lstHDTDVM.ToArray();
                        // Yêu cầu lock dữ liệu
                        retLockData = process.LockData(DatabaseConstant.Module.TDVM,
                                                       DatabaseConstant.Function.TDVM_CHI_TIET_HOP_DONG,
                                                       DatabaseConstant.Table.TD_HDTDVM,
                                                       DatabaseConstant.Action.DUYET,
                                                       lstID);
                        List <ClientResponseDetail> ResponseDetail = new List <ClientResponseDetail>();
                        int bResult = new TinDungProcess().DuyetHopDongTinDungViMo(objHDTDVM, ref ResponseDetail);
                        if (bResult == 1)
                        {
                            LoadData();
                        }
                        CommonFunction.ThongBaoKetQua(ResponseDetail);
                        // Yêu cầu Unlock dữ liệu
                        retLockData = process.UnlockData(DatabaseConstant.Module.TDVM,
                                                         DatabaseConstant.Function.TDVM_CHI_TIET_HOP_DONG,
                                                         DatabaseConstant.Table.TD_HDTDVM,
                                                         DatabaseConstant.Action.DUYET,
                                                         lstID);
                    }
                }
            }
            catch (Exception ex)
            {
                LMessage.ShowMessage("M.DungChung.LoiChung", LMessage.MessageBoxType.Error);
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            finally
            {
                // Yêu cầu Unlock dữ liệu
                retLockData = process.UnlockData(DatabaseConstant.Module.TDVM,
                                                 DatabaseConstant.Function.TDVM_CHI_TIET_HOP_DONG,
                                                 DatabaseConstant.Table.TD_HDTDVM,
                                                 DatabaseConstant.Action.DUYET,
                                                 lstID);
                Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 3
0
        private List <string> TuChoi(string pv_strListItem)
        {
            List <string> listResult = new List <string>();

            if (pv_strListItem != "")
            {
                List <GDICH_KSOAT> lstGdich = new List <GDICH_KSOAT>();
                List <int>         lstID    = GetListIdLock(pv_strListItem);
                string[]           str      = pv_strListItem.Split(';');
                if (str != null && str.Length > 0)
                {
                    for (int k = 0; k < str.Length; k++)
                    {
                        DataView v_dv = ListGiaoDich.DefaultView;
                        v_dv.RowFilter = "";
                        v_dv.RowFilter = "ID=" + str[k];
                        if (v_dv.Count > 0)
                        {
                            GDICH_KSOAT obj = new GDICH_KSOAT();
                            obj.DIEN_GIAI     = v_dv[0]["DIEN_GIAI"].ToString();
                            obj.ID_GDICH      = Convert.ToInt32(v_dv[0]["ID"]);
                            obj.LY_DO         = v_dv[0]["LY_DO"].ToString();
                            obj.MA_DVI        = v_dv[0]["MA_DVI"].ToString();
                            obj.MA_GDICH      = v_dv[0]["SO_GDICH"].ToString();
                            obj.MA_LOAI_GDICH = DatabaseConstant.layLoaiGiaoDich(v_dv[0]["MA_LOAI_GDICH"].ToString());
                            obj.MA_PHAN_HE    = DatabaseConstant.getModule(v_dv[0]["MA_PHAN_HE"].ToString());
                            obj.NGAY_GDICH    = v_dv[0]["NGAY_GIAO_DICH"].ToString();
                            obj.NGAY_CNHAT    = AppConfig.LoginedUser.NgayLamViecHienTai;
                            obj.NGUOI_CNHAT   = AppConfig.LoginedUser.UserName;
                            obj.NGUOI_NHAP    = v_dv[0]["NGUOI_NHAP"].ToString();
                            obj.NGAY_NHAP     = v_dv[0]["NGAY_NHAP"].ToString();
                            obj.MA_CNANG      = v_dv[0]["MA_CNANG"].ToString();
                            lstGdich.Add(obj);
                        }
                    }

                    List <ClientResponseDetail>        lstResponseDetail = new List <ClientResponseDetail>();
                    ApplicationConstant.ResponseStatus status            = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                    Presentation.Process.KeToanProcess process           = new Presentation.Process.KeToanProcess();
                    // Yêu cầu lock bản ghi cần xử lý
                    UtilitiesProcess Lockprocess = new UtilitiesProcess();
                    bool             ret         = Lockprocess.LockData(DatabaseConstant.Module.GDKT,
                                                                        DatabaseConstant.Function.KT_GIAO_DICH,
                                                                        DatabaseConstant.Table.KT_GIAO_DICH,
                                                                        DatabaseConstant.Action.TU_CHOI_DUYET,
                                                                        lstID);
                    bool retUnlockData = Lockprocess.UnlockData(DatabaseConstant.Module.GDKT,
                                                                DatabaseConstant.Function.KT_GIAO_DICH,
                                                                DatabaseConstant.Table.KT_GIAO_DICH,
                                                                DatabaseConstant.Action.TU_CHOI_DUYET,
                                                                lstID);

                    if (ret)
                    {
                        status = process.KiemSoatGiaoDich(lstGdich, DatabaseConstant.Action.TU_CHOI_DUYET, ref lstResponseDetail);
                        if (status == ApplicationConstant.ResponseStatus.THANH_CONG)
                        {
                            foreach (ClientResponseDetail cl in lstResponseDetail)
                            {
                                listResult.Add(LanguageEngine.Instance().GetContent(LanguageType.TypeMessage, cl.Result) + "#" + LanguageEngine.Instance().GetContent(LanguageType.TypeMessage, cl.Detail.Split('#')[0]));
                            }
                        }
                        else
                        {
                            listResult.Add("M.DungChung.DuyetKhongThanhCong#" + LanguageEngine.Instance().GetContent(LanguageType.TypeMessage, "M.DungChung.DuyetKhongThanhCong"));
                        }
                    }
                    else
                    {
                        listResult.Add("M.ResponseMessage.Common.LockDataInvalid#" + LanguageEngine.Instance().GetContent(LanguageType.TypeMessage, "M.ResponseMessage.Common.LockDataInvalid"));
                    }
                }
            }

            return(listResult);
        }