Example #1
0
        protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var sql = string.Format(@"update T_F_GuaranteeLetterApply set Status='Terminate',Terminator='{1}',TerminatorName='{2}',TerminateDate=getdate() 
                where ID = '{0}' and FlowPhase='End' ", dic.GetValue("GuaranteeLetterID"), dic.GetValue("Terminator"), dic.GetValue("TerminatorName"));

            MarketSQLDB.ExecuteNonQuery(sql);
        }
Example #2
0
        protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var sql = string.Format(@"update S_EP_UserLoan set RefundValueTotal=(select ISNULL(sum(RefundValue),0) from S_EP_UserRefund where LoanID='{0}') 
where ID='{0}' ", dic.GetValue("LoanID"));

            SQLDB.ExecuteNonQuery(sql);
        }
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            string sql = "select count(0) from S_SP_SupplierContract  where SerialNumber ='{0}' and ID!='{1}'";
            var    obj = this.MarketSQLDB.ExecuteScalar(String.Format(sql, dic.GetValue("SerialNumber"), dic.GetValue("ContractID")));

            if (Convert.ToInt32(obj) > 0)
            {
                throw new Formula.Exceptions.BusinessValidationException("合同编号【" + dic.GetValue("SerialNumber") + "】已经存在,不能重复,请重新编号");
            }
            #region 供应商修改时,要校验是否有发票和付款
            string contractID      = dic.GetValue("ContractID");
            var    oldContract     = BusinessEntities.Set <S_SP_SupplierContract>().Find(contractID);
            string oldSupplierID   = oldContract.Supplier ?? "";
            string oldSupplierName = oldContract.SupplierName ?? "";
            if (BusinessEntities.Set <S_SP_Invoice>().Any(a => a.Supplier == oldSupplierID && a.SupplierContract == contractID) && oldSupplierID != dic.GetValue("Supplier"))
            {
                throw new Formula.Exceptions.BusinessException("供应商【" + oldSupplierName + "】已经有发票登记信息,不能修改供应商");
            }
            else if (BusinessEntities.Set <T_SP_PaymentApply>().Any(a => a.Supplier == oldSupplierID && a.Contract == contractID) &&
                     oldSupplierID != dic.GetValue("Supplier"))
            {
                throw new Formula.Exceptions.BusinessException("付款方【" + oldSupplierName + "】已经有付款申请信息,不能修改供应商");
            }
            else if (BusinessEntities.Set <S_SP_Payment>().Any(a => a.Supplier == oldSupplierID && a.Contract == contractID) &&
                     oldSupplierID != dic.GetValue("Supplier"))
            {
                throw new Formula.Exceptions.BusinessException("付款方【" + oldSupplierName + "】已经有付款信息,不能修改供应商");
            }
            #endregion
        }
 protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     if (SysParams.Params.GetValue("SubContractConfirmMethod") == "PaymentConfirm")//委外登记确认
     {
         ToCostInfo(dic);
     }
 }
        protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var sql = string.Format(@"update S_EP_WorkHourUser set WorkHour={1} where ID='{0}' ",
                                    dic.GetValue("WorkHourUserID"), Convert.ToDecimal(dic.GetValue("WorkHour")));

            SQLDB.ExecuteNonQuery(sql);
        }
Example #6
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            dic.SetValue("FullID", dic.GetValue("ContractID"));
            if (dic.GetValue("IsSubContract") == true.ToString().ToUpper())
            {
                dic.SetValue("FullID", dic.GetValue("ParentContract") + "." + dic.GetValue("ContractID"));
            }

            if (!string.IsNullOrEmpty(GetQueryString("State")))
            {
                dic.SetValue("ContractState", GetQueryString("State"));
            }
            var ContractAmount = 0.0m;

            decimal.TryParse(dic.GetValue("ContractAmount"), out ContractAmount);
            var contractID = dic.GetValue("ContractID");
            //验证合同金额不能超过已付款金额
            var sumApplyValue = this.EPCEntites.Set <S_P_Payment>().Where(a => a.ContractInfo == contractID).ToList().Sum(a => a.PaymentValue);                         //s表

            sumApplyValue += this.EPCEntites.Set <T_P_PaymentApply>().Where(a => a.ContractInfo == contractID && a.FlowPhase != "End").ToList().Sum(a => a.ApplyValue); //流程
            if (ContractAmount < sumApplyValue)
            {
                throw new Formula.Exceptions.BusinessValidationException("原币种合同额不能小于已付款金额【" + sumApplyValue + "】");
            }
            var invoiceApplyValue = this.EPCEntites.Set <S_P_Invoice>().Where(a => a.ContractInfo == contractID).ToList().Sum(a => a.InvoiceValue);

            if (ContractAmount < invoiceApplyValue)
            {
                throw new Formula.Exceptions.BusinessValidationException("原币种合同额不能小于收票金额【" + invoiceApplyValue + "】");
            }
        }
        protected override void BeforeSave(Dictionary<string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                dic.SetValue("FlowPhase", "End");
                dic.SetValue("EngineeringInfoID", dic.GetValue("EngineeringInfo"));
                dic.SetValue("MessageCompany", string.Empty);
                dic.SetValue("MessageCompanyName", string.Empty);
                dic.SetValue("Status", "Add");
            }
            else
            {
                string sql = string.Format("select * from T_C_WorkingContact where ID='{0}' ", dic.GetValue("ID"));
                var dt = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                    throw new Formula.Exceptions.BusinessValidationException("联系单不存在,请确认!");

                string actionType = Request["actionType"];
                if (!string.IsNullOrEmpty(actionType) && actionType == "Resolve")
                {
                    var status = dt.Rows[0]["Status"].ToString();
                    if (!string.IsNullOrEmpty(status) && status == "Receive")
                    {
                        dic.SetValue("Status", "Resolve");
                        dic.SetValue("ResolveDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
                    }
                    else
                    {
                        throw new Formula.Exceptions.BusinessValidationException("只有已接收的联系单才能处理,请确认!");
                    }
                }

            }
        }
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var strContractAmount        = dic.GetValue("ContractAmount");
            var strContractID            = dic.GetValue("ContractID");
            var strID                    = dic.GetValue("ID");
            var strThisTimePaymentAmount = dic.GetValue("ThisTimePaymentAmount");
            var thisTimePaymentAmount    = 0.0M;

            if (!string.IsNullOrWhiteSpace(strThisTimePaymentAmount))
            {
                thisTimePaymentAmount = Convert.ToDecimal(strThisTimePaymentAmount);
            }
            var alreadyPaymentAmount = this.BusinessEntities.Set <T_TM_ExternalPaymentApply>().Where(c => c.ContractID == strContractID && c.ID != strID).Sum(c => c.ThisTimePaymentAmount);
            var contractAmount       = 0.0M;

            if (!string.IsNullOrWhiteSpace(strContractAmount))
            {
                contractAmount = Convert.ToDecimal(strContractAmount);
            }
            if (alreadyPaymentAmount + thisTimePaymentAmount > contractAmount)
            {
                throw new Formula.Exceptions.BusinessException("本次付款金额+已付款金额超过合同额,请修改!");
            }
            base.BeforeSave(dic, formInfo, isNew);
        }
 protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     if (isNew)
     {
         ValidateNodeRevert(dic.GetValue("SubContractDetailID"), dic.GetValue("SubContractConfirmID"));
     }
 }
Example #10
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            string sectionStr = dic.GetValue("Section");
            string sql        = "select Name from S_I_Section where ID = '" + sectionStr + "'";
            var    name       = this.EPCSQLDB.ExecuteScalar(sql);

            dic.SetValue("SectionName", name.ToString());
        }
Example #11
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                var sql = string.Format(@"select * from S_F_DeptFundPlan where BelongYear={0} and BelongMonth={1} and ChargerDept='{2}'  order by VersionNumber desc",
                                        dic.GetValue("BelongYear"), dic.GetValue("BelongMonth"), dic.GetValue("ChargerDept"));
                var dt = this.EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    dic.SetValue("VersionNumber", "1");
                }
                else
                {
                    var list = FormulaHelper.DataTableToListDic(dt);
                    //if (list.Exists(d => d.GetValue("FlowPhase") != "End"))
                    //{
                    //    throw new Formula.Exceptions.BusinessValidationException(string.Format("部门【{0}】【{1}年{2}月】有正在审核中的计划编制,无法提交!", dic.GetValue("ChargerDeptName"), dic.GetValue("BelongYear"), dic.GetValue("BelongMonth")));
                    //}

                    var newVersionNumber = Convert.ToInt32(list[0].GetValue("VersionNumber")) + 1;
                    dic.SetValue("VersionNumber", newVersionNumber.ToString());
                }
            }

            if (string.IsNullOrWhiteSpace(dic.GetValue("Detail")))
            {
                dic.SetValue("ReceiveValue", "0");
                dic.SetValue("PaymentValue", "0");
            }
            else
            {
                var list         = JsonHelper.ToList(dic.GetValue("Detail"));
                var receiveValue = 0m;
                var paymentValue = 0m;
                var amount       = 0m;
                foreach (var item in list)
                {
                    amount = Convert.ToDecimal(item.GetValue("Amount"));
                    switch (item.GetValue("FundType"))
                    {
                    case "Receive":
                        receiveValue += amount;
                        break;

                    case "Payment":
                        paymentValue += amount;
                        break;

                    default:
                        break;
                    }
                }
                receiveValue = Math.Round(receiveValue, 2);
                paymentValue = Math.Round(paymentValue, 2);
                dic.SetValue("ReceiveValue", receiveValue.ToString());
                dic.SetValue("PaymentValue", paymentValue.ToString());
            }
        }
Example #12
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var workHour = 0m;

            if (!decimal.TryParse(dic.GetValue("WorkHour"), out workHour))
            {
                throw new Formula.Exceptions.BusinessValidationException("请填写工时!");
            }
        }
 protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     if (isNew)
     {
         dic.SetValue("State", EnumDocumentState.Passed.ToString());
         dic.SetValue("UpLoadDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
         dic.SetValue("PassDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
     }
 }
        /// <summary>
        ///  验证是否有采购明细
        /// </summary>
        /// <param name="dic"></param>
        /// <param name="formInfo"></param>
        /// <param name="isNew"></param>
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var pd = dic.GetValue("PurchaseDetail");

            if (string.IsNullOrEmpty(pd) || pd == "[]")
            {
                throw new Formula.Exceptions.BusinessValidationException("请填写采购明细!");
            }
        }
 protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     base.BeforeSave(dic, formInfo, isNew);
     if (isNew == true)
     {
         dic.SetValue("BelongYear", DateTime.Now.Year.ToString());
         dic.SetValue("BelongMonth", DateTime.Now.Month.ToString());
         dic.SetValue("BelongQuarter", (((DateTime.Now.Month) + 2) / 3).ToString());
     }
 }
Example #16
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            //付款方已经有在开票信息中则不能删除
            if (!isNew)
            {
                Expenses.Logic.BusinessFacade.DataInterfaceFo.ValidateDataSyn("S_C_ManageContract", dic.GetValue("ID"));

                string contractID         = dic.GetValue("ID");
                var    oldContract        = this.BusinessEntities.Set <S_C_ManageContract>().Find(contractID);
                string oldCustomerIDs     = oldContract.PayerUnit ?? "";
                string oldCustomerIDNames = oldContract.PayerUnitName ?? "";

                string customerIDs = dic.GetValue("PayerUnit") ?? "";

                var oldCustomerIDArr   = oldCustomerIDs.Split(',').ToList();
                var oldCustomerNameArr = oldCustomerIDNames.Split(',').ToList();
                for (int i = 0; i < oldCustomerIDArr.Count; i++)
                {
                    string oldCustomerID = oldCustomerIDArr[i];
                    if (!customerIDs.Contains(oldCustomerID))
                    {
                        string customerName = oldCustomerID;
                        if (i < oldCustomerNameArr.Count)
                        {
                            customerName = oldCustomerNameArr[i];
                        }
                        if (BusinessEntities.Set <S_C_Invoice>().Any(a => a.PayerUnitID == oldCustomerID && a.ContractInfoID == contractID))
                        {
                            throw new Formula.Exceptions.BusinessException("付款方【" + customerName + "】已经有开票登记信息,不能删除");
                        }
                        if (BusinessEntities.Set <T_C_InvoiceApply>().Any(a => a.PayerUnit == oldCustomerID && a.Contract == contractID))
                        {
                            throw new Formula.Exceptions.BusinessException("付款方【" + customerName + "】已经有开票申请信息,不能删除");
                        }
                        if (BusinessEntities.Set <S_C_Receipt>().Any(a => a.CustomerID == oldCustomerID && a.ContractInfoID == contractID))
                        {
                            throw new Formula.Exceptions.BusinessException("付款方【" + customerName + "】已经有到款信息,不能删除");
                        }
                    }
                }

                //添加过补充协议的合同状态不能改成登记
                var hasSupp = this.BusinessEntities.Set <S_C_ManageContract_Supplementary>().Any(a => a.ContractInfoID == contractID);
                if (hasSupp && string.IsNullOrEmpty(dic.GetValue("SignDate")))
                {
                    throw new Formula.Exceptions.BusinessException("添加过补充协议的合同必须有签约日期");
                }
            }
            var PaymentDetail = JsonHelper.ToList(dic.GetValue("PaymentDetail"));

            if (PaymentDetail.Count == 0)
            {
                throw new Formula.Exceptions.BusinessException("请选择付款方");
            }
        }
Example #17
0
 protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     if (isNew)
     {
         LoggerHelper.InserLogger("S_A_ParticipantUser", isNew ? EnumOperaType.Add : EnumOperaType.Update, dic.GetValue("ID"), string.Empty, dic.GetValue("UserName"), "新增账号密码");
     }
     else
     {
         LoggerHelper.InserLogger("S_A_ParticipantUser", isNew ? EnumOperaType.Add : EnumOperaType.Update, dic.GetValue("ID"), string.Empty, dic.GetValue("UserName"), "修改账号信息");
     }
 }
Example #18
0
        protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var sqlCBSInfo = "select * from S_EP_CBSInfo where ID ='{0}' ";
            var cbsDt      = SQLDB.ExecuteDataTable(string.Format(sqlCBSInfo, dic["CBSInfoID"]));

            if (cbsDt.Rows.Count > 0)
            {
                var cbsInfo = new S_EP_CBSInfo(FormulaHelper.DataRowToDic(cbsDt.Rows[0]));
                cbsInfo.SummaryCostValue();
            }
        }
 protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     if (isNew)
     {
         dic.SetValue("FlowPhase", "End");
         dic.SetValue("EngineeringInfoID", dic.GetValue("EngineeringInfo"));
         dic.SetValue("MessageCompany", string.Empty);
         dic.SetValue("MessageCompanyName", string.Empty);
         dic.SetValue("Status", "Add");
     }
 }
Example #20
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            string folderID = dic.GetValue("FolderID");
            var    ID       = dic.GetValue("ID");
            var    folder   = this.GetEntityByID <S_D_Folder>(folderID);

            this.EPCEntites.Set <S_D_Document_Attr>().Delete(c => c.DocumentID == ID);
            if (!String.IsNullOrEmpty(folder.AttrDefine))
            {
                var attrDefines = JsonHelper.ToList(folder.AttrDefine);
                foreach (var item in attrDefines)
                {
                    var value = dic.GetValue(item.GetValue("Code"));
                    if (!String.IsNullOrEmpty(value))
                    {
                        var attr = new S_D_Document_Attr();
                        attr.DocumentID = dic.GetValue("ID");
                        attr.ID         = FormulaHelper.CreateGuid();
                        attr.AttrName   = item.GetValue("Code");
                        attr.AttrValue  = value;
                        this.EPCEntites.Set <S_D_Document_Attr>().Add(attr);
                    }
                }
            }
            var CurrentVersion = String.IsNullOrEmpty(dic.GetValue("CurrentVersion")) ? 1 : Convert.ToDecimal(dic.GetValue("CurrentVersion"));
            var version        = this.EPCEntites.Set <S_D_Document_Version>().FirstOrDefault(c => c.DocumentID == ID && c.VersionNo == CurrentVersion);

            if (version == null)
            {
                version              = new S_D_Document_Version();
                version.ID           = FormulaHelper.CreateGuid();
                version.DocumentID   = dic.GetValue("ID");
                version.VersionName  = dic.GetValue("Name");
                version.VersionNo    = 1;
                version.CreateDate   = DateTime.Now;
                version.CreateUser   = this.CurrentUserInfo.UserName;
                version.CreateUserID = this.CurrentUserInfo.UserID;
                dic.SetValue("CurrentVersion", version.VersionNo.ToString());
                this.EPCEntites.Set <S_D_Document_Version>().Add(version);
            }
            version.MainFile    = dic.GetValue("MainFile");
            version.Attachments = dic.GetValue("Attachments");
            if (!String.IsNullOrEmpty(version.MainFile))
            {
                var fileInfos = version.MainFile.Split('_');
                if (fileInfos.Length > 1)
                {
                    var filename     = fileInfos[1];
                    var mainFileType = filename.Substring(filename.LastIndexOf('.'));
                    version.MainFileType = mainFileType.Replace(".", "");
                    dic.SetValue("MainFileType", version.MainFileType);
                }
            }
        }
        /// <summary>
        /// 验证报销单逻辑
        /// </summary>
        /// <param name="formDic">表单数据</param>
        /// <param name="formInfo">表单配置信息</param>
        /// <param name="isNew">是否新增数据</param>
        protected void Validate(Dictionary <string, string> formDic, S_UI_Form formInfo, bool isNew)
        {
            var advertiser     = formDic.GetValue("Advertiser");
            var advertiserName = formDic.GetValue("AdvertiserName");
            var ID             = formDic.GetValue("ID");

            ValidateGNFYJTF(ID, advertiser, advertiserName, formDic);
            ValidateLoanInfo(ID, advertiser, advertiserName, formDic);
            ValidateElectronicTicket(formDic);
            ValidateBudget(formDic);
        }
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (String.IsNullOrEmpty(dic.GetValue("ConfirmDate")))
            {
                throw new Formula.Exceptions.BusinessValidationException("必须填写完成日期");
            }
            var dateTime = String.IsNullOrEmpty(dic.GetValue("ConfirmDate")) ? DateTime.Now : Convert.ToDateTime(dic.GetValue("ConfirmDate"));

            CostFO.ValidatePeriodIsClosed(dateTime);
            ValidateStart(dic.GetValue("InvoiceID"));
        }
Example #23
0
 protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     if (!isNew)
     {
         var sql = string.Format(@"select SynID from {0} where ID='{1}' ", "S_EP_UserLoan", dic.GetValue("ID"));
         var db  = SQLHelper.CreateSqlHelper(ConnEnum.DataInterface);
         var obj = db.ExecuteScalar(sql);
         if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
         {
             throw new Formula.Exceptions.BusinessValidationException("数据已同步,不允许操作!");
         }
     }
 }
Example #24
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            string sysName = dic.GetValue("SysName");

            if (string.IsNullOrEmpty(sysName))
            {
                throw new BusinessException("账号不能为空!");
            }

            string sql          = string.Format("select Count(ID) from S_A_ParticipantUser where SysName='{0}' and ID !='{1}' ", sysName, dic.GetValue("ID"));
            var    sysNameCount = Convert.ToInt32(EPCSQLDB.ExecuteScalar(sql));

            if (sysNameCount > 0)
            {
                throw new BusinessException(string.Format("用户名【{0}】已存在", sysName));
            }

            sql = string.Format("select * from S_A_ParticipantUser where Participant='{0}' and  IsAdmin='1' ", dic.GetValue("Participant"));
            var dtParticipant = EPCSQLDB.ExecuteDataTable(sql);

            if (isNew)
            {
                if (dtParticipant.Rows.Count > 0)
                {
                    throw new BusinessException(string.Format("参建方【{0}】已存在管理员账号【{1}】", dic.GetValue("ParticipantName"), sysName));
                }

                var password = dic.GetValue("Password");
                ValidatePwd(password);
                password = FormsAuthentication.HashPasswordForStoringInConfigFile(string.Format("{0}{1}", sysName.ToLower(), password), "SHA1");
                dic.SetValue("Password", password);
            }
            else
            {
                if (dtParticipant.Rows.Count == 1)
                {
                    if (dic.GetValue("ID") != dtParticipant.Rows[0]["ID"].ToString())
                    {
                        throw new BusinessException(string.Format("参建方【{0}】只能有一个管理员账号!", dic.GetValue("ParticipantName")));
                    }
                }
                else if (dtParticipant.Rows.Count > 1)
                {
                    throw new BusinessException(string.Format("参建方【{0}】只能有一个管理员账号!", dic.GetValue("ParticipantName")));
                }

                dic.Remove("Password");
            }

            dic.SetValue("IsAdmin", "true");
        }
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var engineeringInfoID = dic.GetValue("EngineeringInfoID");
            var section           = dic.GetValue("AssociationSegment");
            var tenderingInfo     = this.EPCEntites.Set <T_C_TenderingInfo>().Where(m => m.EngineeringInfoID == engineeringInfoID && m.AssociationSegment == section).FirstOrDefault();

            if (tenderingInfo != null)
            {
                if (tenderingInfo.SerialNumber != dic.GetValue("SerialNumber"))
                {
                    throw new Formula.Exceptions.BusinessValidationException("标段已有招标信息,请重新确认!");
                }
            }
        }
Example #26
0
        /// <summary>
        ///  判断子表是否有数据
        /// </summary>
        /// <param name="dic"></param>
        /// <param name="formInfo"></param>
        /// <param name="isNew"></param>
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var cp = dic.GetValue("ComPersonnel");
            var rr = dic.GetValue("ReviewRecords");

            if (string.IsNullOrEmpty(cp) || cp == "[]")
            {
                throw new Formula.Exceptions.BusinessValidationException("请填写参加单位及人员!");
            }
            if (string.IsNullOrEmpty(rr) || rr == "[]")
            {
                throw new Formula.Exceptions.BusinessValidationException("请填写会审记录!");
            }
        }
Example #27
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            //调整后的本期末确认产值不能超出计划总产值
            decimal CurrentConfirmValueTotalNew = 0;

            decimal.TryParse(dic.GetValue("CurrentConfirmValueTotalNew"), out CurrentConfirmValueTotalNew);
            decimal PlanProductionValue = 0;

            decimal.TryParse(dic.GetValue("PlanProductionValue"), out PlanProductionValue);
            if (CurrentConfirmValueTotalNew > PlanProductionValue)
            {
                throw new BusinessException("调整后的本期末累计确认产值不能超出计划总产值");
            }
        }
Example #28
0
        public JsonResult CalculateFormExpressionWithItem(string TriggerField, string FormItemCode, string FormCode, string FormData)
        {
            if (String.IsNullOrEmpty(FormData))
            {
                throw new Formula.Exceptions.BusinessValidationException("输入的上下文数据内容不能为空");
            }
            var formDic  = JsonHelper.ToObject(FormData);
            var db       = SQLHelper.CreateSqlHelper(ConnEnum.Base);
            var defineDt = db.ExecuteDataTable(String.Format("SELECT * FROM S_UI_Form with(nolock) where Code='{0}'", FormCode));

            if (defineDt.Rows.Count == 0)
            {
                throw new Formula.Exceptions.BusinessValidationException(String.Format("没有找到编号为【{0}】的表单定义数据,请确认定义存在", FormCode));
            }
            var defineForm = defineDt.Rows[0];

            if (defineForm["CalItems"] == null || defineForm["CalItems"] == DBNull.Value || String.IsNullOrEmpty(defineForm["CalItems"].ToString()))
            {
                throw new Formula.Exceptions.BusinessValidationException("没有定义字段信息,无法进行公式计算");
            }
            var form = new S_UI_Form();

            FormulaHelper.UpdateEntity <S_UI_Form>(form, FormulaHelper.DataRowToDic(defineForm));
            var calculateItems = form.CalculateItems;

            if (!String.IsNullOrEmpty(TriggerField))
            {
                calculateItems = calculateItems.Where(c => c.TriggerFields.Contains(TriggerField)).ToList();
            }
            var formItemCodes = FormItemCode.Split(',');

            foreach (var formItemCode in formItemCodes)
            {
                var calItems = calculateItems.Where(c => c.FieldCode == formItemCode).ToList();
                if (calItems.Count == 0)
                {
                    continue;
                }
                //当设置为空时,或设置了默认值计算的计算项,才能进行计算
                foreach (var item in calItems)
                {
                    if (!String.IsNullOrEmpty(item.CalDefaultValue) && !item.CalDefaultValue.Split(',').Contains("FormCal"))
                    {
                        continue;
                    }
                    this.CalFo.CalculateCalItem(item, formDic);
                }
            }
            return(Json(formDic));
        }
Example #29
0
        protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var amount            = Convert.ToDecimal(dic.GetValue("Amount"));
            var returnAmountTotal = Convert.ToDecimal(dic.GetValue("ReturnAmountTotal"));
            var status            = "Return";

            if (returnAmountTotal == amount)
            {
                status = "Settle";
            }
            var sql = string.Format(@"update S_B_Bond set ReturnAmountTotal=(select ISNULL(sum(ReturnAmount),0) from S_B_BondReturn where BondID='{0}'), State='{1}' 
where ID='{0}' ", dic.GetValue("BondID"), status);

            MarketSQLDB.ExecuteNonQuery(sql);
        }
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var applyValue = 0m;

            if (!decimal.TryParse(dic.GetValue("ApplyValue"), out applyValue))
            {
                throw new Formula.Exceptions.BusinessValidationException("金额格式不正确!");
            }
            if (applyValue <= 0)
            {
                throw new Formula.Exceptions.BusinessValidationException("金额必须大于0!");
            }

            var applyDate = DateTime.Now.Date;

            if (!DateTime.TryParse(dic.GetValue("ApplyDate"), out applyDate))
            {
                throw new Formula.Exceptions.BusinessValidationException("请选择申请日期!");
            }
            CostFO.ValidatePeriodIsClosed(applyDate);

            dic.SetValue("BelongYear", applyDate.Year.ToString());
            dic.SetValue("BelongQuarter", ((applyDate.Month + 2) / 3).ToString());
            dic.SetValue("BelongMonth", applyDate.Month.ToString());

            if (isNew)
            {
                dic.SetValue("Source", "Input");
            }
            else
            {
                if (dic.GetValue("Source") == "Reimbursement")
                {
                    throw new Formula.Exceptions.BusinessValidationException("报销单费用不能修改!");
                }

                //是否已分摊
                if (ValidateCostApportion(dic.GetValue("ID")) != null)
                {
                    var apportionValue = Convert.ToDecimal(dic.GetValue("ApportionValue"));
                    if (applyValue < apportionValue)
                    {
                        throw new Formula.Exceptions.BusinessValidationException(string.Format("金额【{0}】必须大于已分摊金额【{1}】!",
                                                                                               applyValue, apportionValue));
                    }
                }
            }
        }