예제 #1
0
        private void IntelligentCaculate(Dictionary <string, List <FunctionExpression> > funcGrp, ExpressionVisitor expressionVisitor, IDictionary <string, BudgetDataEntities> dctArgs, ref Dictionary <FunctionExpression, object> dctFuncValue)
        {
            Kingdee.BOS.Context    ctx        = this.Context;
            Kingdee.BOS.KDSContext kDSContext = this.KDSContext;
            DataSet set = new BugdetDataFunctionService().GetBatchFunctionValue(ctx, kDSContext, dctArgs);
            IDictionary <FunctionExpression, BudgetDataEntities> dictionary = new Dictionary <FunctionExpression, BudgetDataEntities>();

            foreach (List <FunctionExpression> list in funcGrp.Values)
            {
                foreach (FunctionExpression expression in list)
                {
                    if (!dctFuncValue.ContainsKey(expression))
                    {
                        string[] args = new string[0];
                        dictionary.Add(expression, new BugdetDataFunctionArgs().ConvertToFunctionArgs(this.Context, args));
                    }
                }
            }
            foreach (KeyValuePair <string, List <FunctionExpression> > pair in funcGrp)
            {
                foreach (FunctionExpression expression2 in pair.Value)
                {
                    if (!dctFuncValue.ContainsKey(expression2))
                    {
                        DataTable dtSource = set.Tables[pair.Key];
                        decimal   num      = this.CaculFuncValue(dtSource, dictionary[expression2]);
                        dctFuncValue.Add(expression2, num);
                    }
                }
            }
        }
예제 #2
0
        public Dictionary <string, List <string> > GetScopeFilter(Kingdee.BOS.Context ctx, string dimissionInfo)
        {
            Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >();

            if (!string.IsNullOrWhiteSpace(dimissionInfo))
            {
                string[] strArray = dimissionInfo.Split(new char[] { '|' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    string[] strArray2 = strArray[i].Split(new char[] { '~' });
                    string   key       = strArray2[0];
                    if ((strArray2.Length == 2) && !string.IsNullOrWhiteSpace(strArray2[1]))
                    {
                        List <string> list = new List <string>();
                        foreach (string str2 in strArray2[1].Split(new char[] { ',' }))
                        {
                            if (!string.IsNullOrWhiteSpace(str2))
                            {
                                list.Add(str2);
                            }
                        }
                        if (list.Count > 0)
                        {
                            dictionary.Add(key, list);
                        }
                    }
                }
            }
            return(dictionary);
        }
예제 #3
0
        protected override object EvaluateFunction(object[] args)
        {
            if (((args == null) || (args.Length < this.MinArgs)) || (args.Length > this.MaxArgs))
            {
                return("#VALUE?");
            }
            List <string> list = new List <string>();

            foreach (object obj2 in args)
            {
                list.Add((string)obj2);
            }
            BugdetDataFunctionArgs args2 = new BugdetDataFunctionArgs();

            Kingdee.BOS.Context namedSlotData = KdsCalcCacheMananger.GetNamedSlotData("Context") as Kingdee.BOS.Context;
            List <string>       values        = BugdetDataFunctionArgs.Validate(args2.ConvertToFunctionArgs(namedSlotData, list.ToArray()), namedSlotData);

            if (values.Count > 0)
            {
                return(string.Format("#{0}", string.Join("", values)));
            }
            KdsCalcCacheMananger.GetNamedSlotData("KDSContext");
            KdsCalcCacheMananger.GetNamedSlotData("ReportProperty");
            KdsCalcCacheMananger.GetNamedSlotData("KDSCalContext");
            object obj3 = null;

            return(decimal.Parse(obj3.ToString()));
        }
예제 #4
0
        /// <summary>
        /// 来源单获取日期
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="billData"></param>
        /// <param name="para"></param>
        /// <returns></returns>
        public DynamicObjectCollection GetBillDataEntryDate(Kingdee.BOS.Context ctx,
                                                            DynamicObject billData,
                                                            JNQTYRatePara para)
        {
            var formKey   = billData["FBILLFORMID"].ToString();
            var lotFldKey = billData["FLOTFIELDKEY"].ToString();
            var billId    = billData["FBILLID"].ToString();
            var matFldKey = "FMaterialId";
            var lotid     = billData["flotid"].ToString();
            var matid     = billData["FMaterialId"].ToString();
            QueryBuilderParemeter qbPara = new QueryBuilderParemeter();

            qbPara.FormId = formKey;
            qbPara.FilterClauseWihtKey = string.Format(" fid ={0} And {1} ={2} And {3}.FNumber ='{4}' And FAuxPropId={5} ",
                                                       billId, lotFldKey, lotid, matFldKey, para.MaterialNumber, para.AuxPropId);
            qbPara.SelectItems = SelectorItemInfo.CreateItems("FPRODUCEDATE,FEXPIRYDATE");
            DynamicObjectCollection datas = null;

            try
            {
                datas = Kingdee.BOS.ServiceHelper.QueryServiceHelper.GetDynamicObjectCollection(ctx, qbPara);
            }
            catch (Exception ex)
            {
                return(datas);
            }
            return(datas);
        }
예제 #5
0
        /// <summary>
        /// 获取打开单据信息
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="info">单据模型</param>
        /// <param name="BillNo">单据编号</param>
        /// <returns></returns>
        public BillShowParameter GetShowParameter(Kingdee.BOS.Context ctx, FormMetadata info, string BillNo)
        {
            BillShowParameter parameter = new BillShowParameter();

            parameter.Status = OperationStatus.EDIT;
            string Billtable = info.BusinessInfo.Entrys[0].TableName;
            string sql       = string.Format("select top 1 fid from {0} where FbillNo='{1}'", Billtable, BillNo);
            var    Formdatas = DBUtils.ExecuteDynamicObject(ctx, sql);
            string FormId    = info.Id;

            parameter.FormId = Convert.ToString(FormId);
            parameter.PKey   = Convert.ToString(Formdatas[0][0]);
            return(parameter);
        }
예제 #6
0
        /// <summary>
        /// 取物料的单位换算的换算率
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="materialId"></param>
        /// <returns></returns>
        private decimal GetMatUnitRate(Kingdee.BOS.Context ctx, long materialId)
        {
            string sql = string.Format(@"select c.FStoreUnitID ,c.FAUXUNITID ,a.FCURRENTUNITID ,a.FDESTUNITID , 
		                            FConvertDenominator,FConvertNumerator, FConvertNumerator / FConvertDenominator as FRate  
                            from T_BD_UNITCONVERTRATE  a
                            inner join t_bd_material b on a.FMASTERID =b.FMASTERID  
                            inner join T_BD_MATERIALSTOCK c on b.FMATERIALID =c.FMATERIALId  and c.FStoreUnitID = a.FDESTUNITID and c.FAUXUNITID = a.FCurrentUnitId
                            where b.FMATERIALID = {0}
                            ", materialId);

            var rateData = DBUtils.ExecuteDynamicObject(ctx, sql);

            if (rateData != null && rateData.Count > 0)
            {
                return(Convert.ToDecimal(rateData[0]["FRate"]));
            }

            return(0);
        }
예제 #7
0
        public static List <string> Validate(BudgetDataEntities funcArgs, Kingdee.BOS.Context ctx)
        {
            List <string> list = new List <string>();

            if (funcArgs.SchemeId == 0)
            {
                list.Add("参数预算方案无效!");
            }
            if (funcArgs.Year <= 0)
            {
                list.Add(ResManager.LoadKDString("参数年度无效!", "003234000011765", SubSystemType.FIN, new object[0]));
            }
            if (funcArgs.StartYearPeriod <= 0)
            {
                list.Add(ResManager.LoadKDString("参数起始期间无效!", "003234000011766", SubSystemType.FIN, new object[0]));
            }
            if (funcArgs.EndYearPeriod <= 0)
            {
                list.Add(ResManager.LoadKDString("参数结束期间无效!", "003234000011767", SubSystemType.FIN, new object[0]));
            }
            return(list);
        }
예제 #8
0
        /// <summary>
        /// 来源单获取单位酶活
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="billData"></param>
        /// <param name="para"></param>
        /// <returns></returns>
        private decimal GetBillDataEntryRate(Kingdee.BOS.Context ctx,
                                             DynamicObject billData,
                                             JNQTYRatePara para)
        {
            var formKey   = billData["FBILLFORMID"].ToString();
            var lotFldKey = billData["FLOTFIELDKEY"].ToString();
            var billId    = billData["FBILLID"].ToString();
            var matFldKey = "FMaterialId";
            var lotid     = billData["flotid"].ToString();
            var matid     = billData["FMaterialId"].ToString();

            QueryBuilderParemeter qbPara = new QueryBuilderParemeter();

            qbPara.FormId = formKey;
            qbPara.FilterClauseWihtKey = string.Format(" fid ={0} And {1} ={2} And {3}.FNumber ='{4}' And FAuxPropId={5} ",
                                                       billId, lotFldKey, lotid, matFldKey, para.MaterialNumber, para.AuxPropId);
            //放到批号主档里过滤
            //if (para.OrgId > 0)
            //{
            //    qbPara.FilterClauseWihtKey +=string.Format ( " And {0}={1} ", GetOrgFldKey( ctx,formKey),para.OrgId );
            //}
            qbPara.SelectItems = SelectorItemInfo.CreateItems("FJNUnitEnzymes");
            try
            {
                DynamicObjectCollection datas = Kingdee.BOS.ServiceHelper.QueryServiceHelper.GetDynamicObjectCollection(ctx, qbPara);
                if (datas != null && datas.Count > 0)
                {
                    return(Convert.ToDecimal(datas[0]["FJNUnitEnzymes"]));
                }
            }
            catch (Exception ex)
            {
                return(0);
            }

            return(0);
        }
예제 #9
0
        /// <summary>
        /// 获取物料对应批次号的单位酶活量
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="materialId"></param>
        /// <param name="lotNo"></param>
        /// <returns></returns>
        public decimal MaterialUnitEnzymes(Kingdee.BOS.Context ctx, JNQTYRatePara para)
        {
            //批号跟踪里面取
            StringBuilder sql = new StringBuilder();

            sql.AppendLine("select a.FBILLFORMID ,a.FBILLNO,a.FBILLID ,a.FBILLENTRYID ,a.FLOTFIELDKEY,a.flotid,b.FMaterialId ");
            sql.AppendLine("from T_BD_LOTMASTERBILLTRACE a ");
            sql.AppendLine("inner join T_BD_LOTMASTER b on a.flotid=b.flotid ");
            sql.AppendLine("inner join T_BD_Material c on b.FMaterialId=c.FMaterialId ");
            sql.AppendFormat("where a.FSTOCKDIRECT=1 and c.FNumber ='{0}' and b.FNUMBER ='{1}' ", para.MaterialNumber, para.LotNumber);
            if (para.OrgId > 0)
            {
                sql.AppendFormat(" and b.FCreateOrgId={0} ", para.OrgId);
            }
            sql.AppendLine("order by finstockdatetmp desc");



            var traceData = DBUtils.ExecuteDynamicObject(ctx, sql.ToString());

            if (traceData != null && traceData.Count > 0)
            {
                decimal rate = 0;
                foreach (var item in traceData)
                {
                    rate = GetBillDataEntryRate(ctx, item, para);
                    if (rate > 0)
                    {
                        return(rate);
                    }
                }
            }

            //找不到就到物料的单位换算里面找
            return(GetMatUnitRate(ctx, para.MaterialId));
        }
예제 #10
0
 public DateTime GetRelativePeriod(Kingdee.BOS.Context ctx)
 {
     return(ServiceHelper.GetService <ITimeService>().GetSystemDateTime(ctx));
 }
예제 #11
0
        public BudgetDataEntities ConvertToFunctionArgs(Kingdee.BOS.Context ctx, string[] args)
        {
            this.Context = ctx;
            ReportProperty namedSlotData = KdsCalcCacheMananger.GetNamedSlotData("ReportProperty") as ReportProperty;
            bool           flag          = namedSlotData != null;
            bool           flag2         = false;

            if (flag)
            {
                flag2 = namedSlotData.AcctParameter != null;
            }
            BudgetDataEntities funcArgs = new BudgetDataEntities();
            int schemeIdByNumber        = this.GetSchemeIdByNumber(args[0]);

            if ((schemeIdByNumber == 0) && flag)
            {
                if (flag && (namedSlotData.AcctParameter.SchemeId > 0))
                {
                    schemeIdByNumber = namedSlotData.AcctParameter.SchemeId;
                }
                else
                {
                    schemeIdByNumber = namedSlotData.SchemeId;
                }
            }
            funcArgs.SchemeId = schemeIdByNumber;
            string str = args[1];

            if (!string.IsNullOrWhiteSpace(str))
            {
                this.GetOrgIdByNumber(str, funcArgs);
            }
            else if (flag && (namedSlotData.AcctParameter.OrgId > 0L))
            {
                funcArgs.OrgId   = namedSlotData.AcctParameter.OrgId;
                funcArgs.OrgType = namedSlotData.AcctParameter.OrgType;
            }
            else
            {
                funcArgs.OrgId   = namedSlotData.OrgId;
                funcArgs.OrgType = namedSlotData.OrgType;
            }
            string periodTypeByNumber = args[2];

            if (!string.IsNullOrWhiteSpace(periodTypeByNumber))
            {
                periodTypeByNumber = this.GetPeriodTypeByNumber(periodTypeByNumber);
            }
            else if (flag)
            {
                periodTypeByNumber = namedSlotData.CycleType;
            }
            funcArgs.PeriodType = periodTypeByNumber;
            int year        = args[3].IsNullOrEmptyOrWhiteSpace() ? 0 : Convert.ToInt32(args[3]);
            int startPeriod = args[4].IsNullOrEmptyOrWhiteSpace() ? 0 : Convert.ToInt32(args[4]);
            int endPeriod   = args[5].IsNullOrEmptyOrWhiteSpace() ? 0 : Convert.ToInt32(args[5]);

            if ((year == 0) && flag)
            {
                if (flag)
                {
                    year = namedSlotData.AcctParameter.Year;
                }
                if (year == 0)
                {
                    year = namedSlotData.Year;
                }
            }
            if ((startPeriod == 0) && flag)
            {
                if (flag)
                {
                    startPeriod = namedSlotData.AcctParameter.StartPeriod;
                }
                if (startPeriod == 0)
                {
                    startPeriod = namedSlotData.Period;
                }
            }
            if ((endPeriod == 0) && flag)
            {
                if (flag)
                {
                    endPeriod = namedSlotData.AcctParameter.EndPeriod;
                }
                if (endPeriod == 0)
                {
                    endPeriod = namedSlotData.Period;
                }
            }
            DateTime relativePeriod = this.GetRelativePeriod(ctx);

            switch (year)
            {
            case 0:
            case -1:
                year = relativePeriod.Year + year;
                break;
            }
            if ((startPeriod == 0) || (startPeriod == -1))
            {
                startPeriod = relativePeriod.Month + startPeriod;
            }
            if ((endPeriod == 0) || (endPeriod == -1))
            {
                endPeriod = startPeriod;
            }
            funcArgs.Year            = year;
            funcArgs.StartPeriod     = startPeriod;
            funcArgs.EndPeriod       = endPeriod;
            funcArgs.StartYearPeriod = (year * 0x3e8) + startPeriod;
            funcArgs.EndYearPeriod   = (year * 0x3e8) + endPeriod;
            string dimissionInfo = args[6];

            funcArgs.DicDimissionFilter = this.GetScopeFilter(ctx, dimissionInfo);
            funcArgs.BusinessType       = this.GetBusinessTypeIdByNumber(args[7]);
            int dataTypeIdByNumber = this.GetDataTypeIdByNumber(args[8]);

            if (dataTypeIdByNumber > 0)
            {
                switch (Convert.ToString(this.DicDataTypeInfo[args[8]]["FDATATYPE"]))
                {
                case "0":
                case "2":
                    funcArgs.IsAmount = true;
                    break;
                }
            }
            funcArgs.DataType   = dataTypeIdByNumber;
            funcArgs.ValueType  = args[9].IsNullOrEmptyOrWhiteSpace() ? 0 : Convert.ToInt32(args[9]);
            funcArgs.CurrencyId = this.GetCurrencyIdByNumber(args[10]);
            string amountUnitNumber = args[11].IsNullOrEmptyOrWhiteSpace() ? "JEDW01_SYS" : args[11];

            funcArgs.AmountUnitId = this.GetAmountUnitIdByNumber(amountUnitNumber);
            bool includeUnAuditReport = false;

            if (flag2)
            {
                includeUnAuditReport = namedSlotData.AcctParameter.IncludeUnAuditReport;
            }
            funcArgs.IncludeUnAuditReport = includeUnAuditReport;
            bool includeAuditAdjustData = false;

            if (flag2)
            {
                includeAuditAdjustData = namedSlotData.AcctParameter.IncludeAuditAdjustData;
            }
            funcArgs.IncludeAuditAdjustData = includeAuditAdjustData;
            funcArgs.CalcType = CalcType.Formula;
            return(funcArgs);
        }
예제 #12
0
        public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
        {
            Field billNoField = validateContext.BusinessInfo.GetBillNoField();

            if (dataEntities == null || dataEntities.Count() <= 0)
            {
                return;
            }

            List <long> lstFids = new List <long>();

            foreach (var data in dataEntities)
            {
                lstFids.Add(Convert.ToInt64(data.DataEntity["ID"]));
            }

            if (lstFids.Count() <= 0)
            {
                return;
            }

            SqlParam param = new SqlParam("@FID", KDDbType.udt_inttable, lstFids.ToArray());

            string sql = string.Format(@"                
                select a.FID,b.FEntryID,b.FSeq
                from T_SAL_ORDER a
                inner join TABLE(fn_StrSplit(@FID,',',1)) tb on a.Fid=tb.Fid
                inner join T_SAL_ORDERENTRY b on a.FID=b.FID 
                inner join t_BD_Stock d on b.FSTOCKID_MX=d.FStockId
                where not exists (select 1 from JN_T_SAL_ForecastBack c where a.FSALEORGID=c.FSALEORGID and c.FSALERID=a.FSALERID 
                                                                        and a.FSaleDeptId=c.FSALEDEPTID 
                                                                        and b.FMATERIALID=c.FMATERIALID and b.FAUXPROPID=c.FAUXPROPID 
                                                                        and b.FBaseUnitID=c.FUnitID)
                and d.FMasterId in (100313,100328)
                union all
                select b.Fid,c.FEntryID,c.FSeq
                from JN_T_SAL_ForecastBack a
                inner join T_SAL_ORDER b on a.FSALEORGID=b.FSALEORGID and a.FSALERID=b.FSALERID 
                and a.FSaleDeptId=b.FSALEDEPTID 
                inner join T_SAL_ORDERENTRY c on b.FID=c.FID and a.FMATERIALID=c.FMATERIALID 
                and a.FAUXPROPID=c.FAUXPROPID and c.FBASEUNITID=a.FUnitID
                inner join t_BD_Stock d on c.FSTOCKID_MX=d.FStockId
                where a.FQTY-c.FBASEUNITQTY<0 and d.FMasterId in (100313,100328)");

            DynamicObjectCollection docChecks = DBUtils.ExecuteDynamicObject(this.Context, sql, null, null, CommandType.Text, new SqlParam[] { param });

            if (docChecks == null || docChecks.Count() <= 0)
            {
                return;
            }

            foreach (var data in dataEntities)
            {
                List <DynamicObject> docSelect = docChecks.Where(p => Convert.ToInt64(data.DataEntity["ID"]) == Convert.ToInt64(p["FID"])).ToList();

                if (docSelect == null || docSelect.Count() <= 0)
                {
                    continue;
                }

                foreach (var item in docSelect)
                {
                    AddMsg(validateContext, data, billNoField.Key
                           , string.Format(@"第{0}行的结余数出现操作结果小于0,不能审核,请先做销售预测变更单进行调整结余数!", item["FSeq"]));
                }
            }
        }
 public void Run(Kingdee.BOS.Context ctx, Schedule schedule)
 {
     try
     {
         string sql = string.Empty;
         #region
         sql = string.Format(@"select  FID, F_YBG_WAREHOUSE ,F_YBG_SUPPLIER from  T_SAL_ORDER where FDOCUMENTSTATUS='C' or FDOCUMENTSTATUS='B' ");
         DataSet   ds = DBServiceHelper.ExecuteDataSet(ctx, sql);
         DataTable dt = ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             string upsql = "";
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string FID = dt.Rows[i]["FID"].ToString();
                 //供应商
                 string F_YBG_Supplier = dt.Rows[i]["F_YBG_SUPPLIER"].ToString();
                 //仓库
                 string F_YBG_Warehouse     = dt.Rows[i]["F_YBG_WAREHOUSE"].ToString();
                 string F_YBG_BUSINESSMODEL = ""; //其他仓库默认01
                 //仓库编码
                 sql = string.Format(@"select  FNumber from t_BD_Stock where FSTOCKID='{0}'", F_YBG_Warehouse);
                 string CKFNumber = DBServiceHelper.ExecuteScalar <string>(ctx, sql, "0", null);
                 //供应商编码 ---自营VEN00057  VEN00099 VEN00256
                 sql = string.Format(@"select  FNumber from t_BD_Supplier where FSUPPLIERID='{0}'", F_YBG_Supplier);
                 string SPFNUMBER = DBServiceHelper.ExecuteScalar <string>(ctx, sql, "0", null);
                 if (CKFNumber == "0" || SPFNUMBER == "0")
                 {
                 }
                 else
                 {
                     //非嘉里开头的
                     if (CKFNumber.StartsWith("ZF")) //挂靠01
                     {
                         F_YBG_BUSINESSMODEL = "01";
                         upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                     }
                     //嘉里开头
                     else if (CKFNumber.StartsWith("JLZF")) //04 挂靠自发
                     {
                         F_YBG_BUSINESSMODEL = "04";
                         upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                     }
                     //嘉里物流主仓 嘉里苏宁移动仓
                     else if (CKFNumber.StartsWith("JL002") || CKFNumber.StartsWith("JLSN001"))
                     {
                         // 是壹办公供应商或者自营供应商
                         if (SPFNUMBER.Contains("VEN00057") || SPFNUMBER.Contains("VEN00099") || SPFNUMBER.Contains("P451")) //自营 05
                         {
                             F_YBG_BUSINESSMODEL = "05";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                         else //代采 06
                         {
                             F_YBG_BUSINESSMODEL = "06";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                     }
                     //珠海仓
                     else if (CKFNumber.StartsWith("YBG001") || CKFNumber.StartsWith("YBG015") || CKFNumber.StartsWith("YBG017"))
                     {
                         F_YBG_BUSINESSMODEL = "07"; //珠海自营 07
                         upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                     }
                     // 观澜仓 车公庙仓
                     else if (CKFNumber.StartsWith("YBG002") || CKFNumber.StartsWith("YBG003"))
                     {
                         //壹办公供应商或者自营供应商
                         if (SPFNUMBER.Contains("VEN00057") || SPFNUMBER.Contains("VEN00099") || SPFNUMBER.Contains("P451")) //自营直发 05
                         {
                             F_YBG_BUSINESSMODEL = "02";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                         else //代采直发 03
                         {
                             F_YBG_BUSINESSMODEL = "03";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                     }
                     else //其他仓库默认01
                     {
                         //壹办公供应商或者自营供应商
                         if (SPFNUMBER.Contains("VEN00057") || SPFNUMBER.Contains("VEN00099") || SPFNUMBER.Contains("P451"))  //自营 05
                         {
                             F_YBG_BUSINESSMODEL = "05";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                         else
                         {
                             F_YBG_BUSINESSMODEL = "01";
                             upsql += string.Format(@"/*dialect*/ update T_SAL_ORDER set F_YBG_BUSINESSMODEL='{0}' where FID ={1}", F_YBG_BUSINESSMODEL, FID);
                         }
                     }
                 }
             }
             //更新业务模式
             DBServiceHelper.Execute(ctx, upsql);
         }
         #endregion
     }
     catch (Exception ex)
     {
         throw new Exception("更新报错:" + ex.ToString());
     }
 }
            public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
            {
                foreach (var dataEntity in dataEntities)
                {
                    string FID        = dataEntity["Id"].ToString();
                    string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID);
                    List <ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId);

                    var WFNode = routeCollection[routeCollection.Count - 1];
                    //客户管理员
                    if (WFNode.ActivityId == CustAdmin_NodeID)
                    {
                        Act_CtrlCustAdmin(dataEntity, validateContext, ctx, FID);
                    }
                    else if (WFNode.ActivityId == Contractor_NodeID)
                    {
                        Act_CtrlContractor(dataEntity, validateContext, ctx, FID);
                    }
                    else if (WFNode.ActivityId == Bomer_NodeID)
                    {
                        Act_CtrlBomer(dataEntity, validateContext, ctx, FID);
                    }
                }
            }
        public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
        {
            if (dataEntities == null || dataEntities.Length == 0)
            {
                return;
            }

            List <long> dictErrMaterialId = new List <long>();

            //取所有物料
            List <long> listMaterialId = new List <long>();

            foreach (ExtendedDataEntity entityObj in dataEntities)
            {
                DynamicObjectCollection collection = (DynamicObjectCollection)entityObj["Entity"];

                //取酶活量小于等于于零的
                var checkRows = collection.Where(f => Convert.ToDecimal(f["FJNUnitEnzymes"]) <= 0).ToList();
                if (checkRows == null || checkRows.Count() <= 0)
                {
                    continue;
                }

                foreach (DynamicObject rowObj in checkRows)
                {
                    listMaterialId.Add((long)rowObj["MaterialId_Id"]);
                }
            }
            if (listMaterialId.Count > 0)
            {
                string   sql   = "   select a.FMATERIALID from T_BD_MATERIAL a where exists (select 1 from TABLE(fn_StrSplit(@FMATERIALID, ',',1)) t where t.FID=a. FMATERIALID  and a.FISMEASURE='1' )  ";
                SqlParam param = new SqlParam("@FMATERIALID", KDDbType.udt_inttable, listMaterialId.Distinct().ToArray());
                using (IDataReader dr = DBUtils.ExecuteReader(this.Context, sql, param))
                {
                    while (dr.Read())
                    {
                        if (dr != null)
                        {
                            dictErrMaterialId.Add(Convert.ToInt64(dr["FMATERIALID"]));
                        }
                    }
                }
            }
            foreach (ExtendedDataEntity entityObj in dataEntities)
            {
                DynamicObjectCollection collection = (DynamicObjectCollection)entityObj["Entity"];
                foreach (DynamicObject rowObj in collection)
                {
                    if (dictErrMaterialId.Contains((long)rowObj["MaterialId_Id"]))
                    {
                        ValidationErrorInfo errinfo = new ValidationErrorInfo("FMATERIALID", Convert.ToString(entityObj.DataEntity["Id"]),
                                                                              entityObj.DataEntityIndex, Convert.ToInt32(rowObj["Id"]), "SubmitValidator", "第" + Convert.ToString(rowObj["Seq"]) + "行启用双计量,单位酶活必须大于0", "校验失败", ErrorLevel.Error);
                        validateContext.AddError(entityObj, errinfo);
                    }
                }
            }
        }
예제 #16
0
 public static bool ValidateDimissionFilter(Kingdee.BOS.Context ctx)
 {
     new CommonService().GetDimissionGroupInfo(ctx).ToDictionary <DynamicObject, string>(p => Convert.ToString(p["FNUMBER"]));
     return(true);
 }
예제 #17
0
        public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
        {
            if (dataEntities == null)
            {
                return;
            }
            Field billNoField = validateContext.BusinessInfo.GetBillNoField();

            if (dataEntities != null && dataEntities.Count() > 0)
            {
                List <long> lstFids = new List <long>();

                foreach (var data in dataEntities)
                {
                    lstFids.Add(Convert.ToInt64(data.DataEntity["ID"]));
                }

                if (lstFids.Count() <= 0)
                {
                    return;
                }

                SqlParam param = new SqlParam("@FID", KDDbType.udt_inttable, lstFids.ToArray());

                string sql = string.Format(@"
                select a.FID,b.FEntryID,b.FSeq
                from JN_T_SAL_ForecastChange a
                inner join TABLE(fn_StrSplit(@FID,',',1)) tb on a.Fid=tb.Fid
                inner join JN_T_SAL_ForecastChangeEntry b on a.FID=b.FID 
                where not exists (select 1 from JN_T_SAL_ForecastBack c where a.FJNSALEORGID=c.FSALEORGID and a.FJNSALERID=c.FSALERID
                                                                        and a.FJNSaleDeptId=c.FSaleDeptId
                                                                        and b.FJNMATERIALID=c.FMATERIALID and b.FJNAUXPROP=c.FAUXPROPID
                                                                        and b.FJNBaseUnitID=c.FUnitID)
                and a.FDirection='B'
                union all
                select b.FID,c.FEntryID,c.FSeq
                from JN_T_SAL_ForecastBack a          
                inner join JN_T_SAL_ForecastChange b on a.FSALEORGID=b.FJNSALEORGID and a.FSALERID=b.FJNSALERID 
                and a.FSaleDeptId=b.FJNSaleDeptId 
                inner join TABLE(fn_StrSplit(@FID,',',1)) tb on b.Fid=tb.Fid
                inner join JN_T_SAL_ForecastChangeEntry c on b.FID=c.FID and a.FMATERIALID=c.FJNMATERIALID 
                and a.FAUXPROPID=c.FJNAUXPROP and c.FJNBaseUnitID=a.FUnitID
                where b.FDirection='B' and a.FQTY-c.FJNBaseUnitQty<0");

                DynamicObjectCollection docForecast = DBUtils.ExecuteDynamicObject(this.Context, sql, null, null, CommandType.Text, new SqlParam[] { param });

                if (docForecast == null || docForecast.Count() <= 0)
                {
                    return;
                }

                foreach (var data in dataEntities)
                {
                    List <DynamicObject> docSelect = docForecast.Where(p => Convert.ToInt64(data.DataEntity["ID"]) == Convert.ToInt64(p["FID"])).ToList();

                    if (docSelect == null || docSelect.Count() <= 0)
                    {
                        continue;
                    }

                    foreach (var item in docSelect)
                    {
                        AddMsg(validateContext, data, billNoField.Key
                               , string.Format(@"第{0}行审核之后结余数小于0,不能审核!", item["FSeq"]));
                    }
                }
            }
        }