예제 #1
0
        public static Dictionary <long, KDTimeZone> ConvertToKDTimeZones(DynamicObjectCollection docTimeZones)
        {
            Dictionary <long, KDTimeZone> dicTimeZones;

            try
            {
                dicTimeZones = docTimeZones.Where(dy => null != dy["FTIMEOFFSET"]).Select(
                    dy =>
                    new KDTimeZone(
                        Convert.ToInt64(dy["FID"]),
                        dy["FNUMBER"].ToString(),
                        new LocaleValue(dy["FNAME"] == null ? "" : dy["FNAME"].ToString(), Convert.ToInt32(dy["FLOCALEID"])),
                        GetTimeSpan(0, Convert.ToInt32(dy["FTIMEOFFSET"]), 0),
                        (UnForbidStatus.Equals(dy["FFORBIDSTATUS"].ToString(), StringComparison.CurrentCultureIgnoreCase) &&
                         AuditStatus.Equals(dy["FDOCUMENTSTATUS"].ToString(), StringComparison.CurrentCultureIgnoreCase))
                        )
                    ).ToDictionary(tz => tz.Id);
                if (dicTimeZones.Count == 0)
                {
                    throw new Exception("时区数据没有加载");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("时区数据加载不正确,请确认时区数据导入正确,信息如下:{0}", ex.Message));
            }

            return(dicTimeZones);
        }
예제 #2
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 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 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
                inner join TABLE(fn_StrSplit(@FID,',',1)) tb on b.Fid=tb.Fid
                where b.FDirection='A' 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"]));
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }
예제 #4
0
        public void BindPeriodList(DynamicObject dyScheme, DynamicObject dyCanlendar, bool isNeedToSetValue, int periodType = 0)
        {
            Func <DynamicObject, bool> predicate = null;
            int                     startYear    = Convert.ToInt32(this.View.Model.GetValue("FSTARTYEAR"));
            int                     endYear      = Convert.ToInt32(this.View.Model.GetValue("FENDYEAR"));
            List <EnumItem>         items        = new List <EnumItem>();
            List <EnumItem>         list2        = new List <EnumItem>();
            DynamicObjectCollection source       = dyCanlendar["BudgetPeriodEntity"] as DynamicObjectCollection;
            int                     num          = 0;
            int                     num2         = 0;

            foreach (DynamicObject obj2 in from p in source
                     where (Convert.ToInt32(p["PeriodType"]) == periodType) && (Convert.ToInt32(p["PeriodYear"]) == startYear)
                     select p)
            {
                EnumItem item = new EnumItem {
                    EnumId  = Convert.ToString(obj2["Period"]),
                    Seq     = num,
                    Value   = Convert.ToString(obj2["Period"]),
                    Caption = new LocaleValue(Convert.ToString(obj2["Period"]))
                };
                items.Add(item);
                if (startYear == endYear)
                {
                    list2.Add(item);
                }
            }
            if (startYear != endYear)
            {
                if (predicate == null)
                {
                    predicate = p => (Convert.ToInt32(p["PeriodType"]) == periodType) && (Convert.ToInt32(p["PeriodYear"]) == endYear);
                }
                foreach (DynamicObject obj3 in source.Where <DynamicObject>(predicate))
                {
                    EnumItem item2 = new EnumItem {
                        EnumId  = Convert.ToString(obj3["Period"]),
                        Seq     = num2,
                        Value   = Convert.ToString(obj3["Period"]),
                        Caption = new LocaleValue(Convert.ToString(obj3["Period"]))
                    };
                    list2.Add(item2);
                }
            }
            this.View.GetControl <ComboFieldEditor>("FSTARTPERIOD").SetComboItems(items);
            this.View.GetControl <ComboFieldEditor>("FENDPERIOD").SetComboItems(list2);
            if ((items.Count > 0) && isNeedToSetValue)
            {
                this.View.Model.SetValue("FSTARTPERIOD", items[0].Value);
            }
            if ((list2.Count > 0) && isNeedToSetValue)
            {
                this.View.Model.SetValue("FENDPERIOD", list2[0].Value);
            }
        }
예제 #5
0
        public override void AfterConvert(Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e)
        {
            base.AfterConvert(e);

            ExtendedDataEntity[] entityArray = e.Result.FindByEntityKey("FbillHead");

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

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

            foreach (ExtendedDataEntity entity in entityArray)
            {
                if (!lstMaterialID.Contains(Convert.ToInt64(entity.DataEntity["MaterialId_Id"])))
                {
                    lstMaterialID.Add(Convert.ToInt64(entity.DataEntity["MaterialId_Id"]));
                }
            }

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

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

            string strSql = string.Format(@"select a.FID,a.FMaterialId from T_ENG_BOM a
                                          INNER JOIN TABLE(fn_StrSplit(@FID,',',1)) b on a.FMaterialId=b.FID ");

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

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

            foreach (ExtendedDataEntity entity in entityArray)
            {
                DynamicObject dycBom = entity["BomId"] as DynamicObject;
                if (dycBom == null || Convert.ToInt64(dycBom["Id"]) == 0)
                {
                    DynamicObject dycSelect = dycBomCollections.Where(o => Convert.ToInt64(o["FMaterialId"]) == Convert.ToInt64(entity.DataEntity["MaterialId_Id"])).FirstOrDefault();
                    if (dycSelect != null)
                    {
                        entity.DataEntity["BomId_Id"] = dycSelect["FID"];
                    }
                }
                Kingdee.BOS.ServiceHelper.DBServiceHelper.LoadReferenceObject(this.Context, new DynamicObject[] { entity.DataEntity }, e.TargetBusinessInfo.GetDynamicObjectType());
            }
        }
예제 #6
0
 /// <summary>
 /// 校验逻辑实现
 /// </summary>
 /// <param name="dataEntities"></param>
 /// <param name="validateContext"></param>
 /// <param name="ctx"></param>
 public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
 {
     if (dataEntities == null)
     {
         return;
     }
     foreach (var dataEntity in dataEntities)
     {
         string billNo   = dataEntity["BillNo"].ToString();             //单据编号
         string pickMtrl = string.Format(@"select t1.FBILLNO,FDOCUMENTSTATUS from  T_PRD_PICKMTRL t1
                         inner join T_PRD_PICKMTRLDATA t2 on t1.FID=t2.FID 
                         where FMOBILLNO='{0}'  
                         group by t1.FBILLNO,FDOCUMENTSTATUS", billNo); //生产领料单
         DynamicObjectCollection pickMtrlData = DBUtils.ExecuteDynamicObject(this.Context, pickMtrl);
         List <string>           pickMtrlList = pickMtrlData.Where(o => o["FDOCUMENTSTATUS"].ToString() != "C").Select(o => o["FBILLNO"].ToString()).ToList();
         if (pickMtrlList.Count() > 0)
         {
             string pickMtrlNo = string.Join(",", pickMtrlList);
             validateContext.AddError(dataEntity.DataEntity,
                                      new ValidationErrorInfo("FBillNo",
                                                              Convert.ToString(((DynamicObject)(dataEntity.DataEntity))["Id"]),
                                                              dataEntity.DataEntityIndex,
                                                              dataEntity.RowIndex,
                                                              "JN-YDL-MOClose",
                                                              string.Format("执行至结案失败:下游单据生产领料单:{0}还未审核!", pickMtrlNo.Substring(0, pickMtrlNo.Length - 1)),
                                                              "金蝶提示"));
             continue;
         }
         string inStock = string.Format(@"select t1.FBILLNO,t1.FDOCUMENTSTATUS from T_PRD_INSTOCK t1 
                         inner join T_PRD_INSTOCKENTRY t2 on t1.FID=t2.FID 
                         where t2.FMOBILLNO='{0}'
                         group by t1.FBILLNO,t1.FDOCUMENTSTATUS", billNo);//生产入库单
         DynamicObjectCollection inStockData = DBUtils.ExecuteDynamicObject(this.Context, inStock);
         List <string>           inStockList = inStockData.Where(o => o["FDOCUMENTSTATUS"].ToString() != "C").Select(o => o["FBILLNO"].ToString()).ToList();
         if (inStockList.Count() > 0)
         {
             string inStockNo = string.Join(",", inStockList);
             validateContext.AddError(dataEntity.DataEntity,
                                      new ValidationErrorInfo("FBillNo",
                                                              Convert.ToString(((DynamicObject)(dataEntity.DataEntity))["Id"]),
                                                              dataEntity.DataEntityIndex,
                                                              dataEntity.RowIndex,
                                                              "JN-YDL-MOClose",
                                                              string.Format("执行至结案失败:下游单据生产入库单:{0}还未审核!", inStockNo.Substring(0, inStockNo.Length - 1)),
                                                              "金蝶提示"));
             continue;
         }
     }
 }
예제 #7
0
        private void UpdateSupplierId(List <DynamicObject> subDataList)
        {
            if (subDataList == null || subDataList.Count <= 0)
            {
                return;
            }
            foreach (DynamicObject subData in subDataList)
            {
                DynamicObjectCollection entryDatas = subData["TreeEntity"] as DynamicObjectCollection;
                var datas = entryDatas.Where(d => d["CreateType"].ToString() == "6" && d["PurOrderId"].ToString() == "0").ToList <DynamicObject>();
                foreach (var d in datas)
                {
                    d["SupplierId_Id"] = 0;
                    d["SupplierId"]    = null;
                }

                //DynamicObjectCollection entryDatas=subData.GetDynamicValue<DynamicObjectCollection>(CONST_SUB_SUBREQORDER.CONST_FTreeEntity.)
            }
        }
예제 #8
0
        /// <summary>
        /// 事务后事件
        /// </summary>
        /// <param name="e"></param>
        public override void BeginOperationTransaction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeginOperationTransactionArgs e)
        {
            base.BeginOperationTransaction(e);
            if (e.DataEntitys == null)
            {
                return;
            }
            var billGroups = e.DataEntitys;

            //List<string> sql = new List<string>();
            foreach (var billGroup in billGroups)
            {
                bool     flag = false;
                int      Id   = Convert.ToInt32(billGroup["Id"]);
                DateTime date = Convert.ToDateTime(billGroup["Date"]);
                DynamicObjectCollection dynamicOs = billGroup["SaleOrderEntry"] as DynamicObjectCollection;//分录明细
                foreach (var dynamicO in dynamicOs)
                {
                    decimal       taxPrice       = Convert.ToDecimal(dynamicO["TaxPrice"]);     //含税单价
                    int           auxPropId      = Convert.ToInt32(dynamicO["AuxPropId_Id"]);   //辅助属性
                    int           materialId     = Convert.ToInt32(dynamicO["MaterialId_Id"]);  //当前物料
                    DynamicObject PriceListEntry = dynamicO["PriceListEntry"] as DynamicObject; //行价目表
                    if (PriceListEntry == null)
                    {
                        continue;
                    }
                    DynamicObjectCollection salPriceListtrys = PriceListEntry["SAL_PRICELISTENTRY"] as DynamicObjectCollection;                                                                                     //价目表明细
                    var priceList = salPriceListtrys.Where(f => Convert.ToInt32(f["MaterialId_Id"]) == materialId && Convert.ToDateTime(f["EffectiveDate"]) <= date && Convert.ToDateTime(f["ExpiryDate"]) > date); //物料、生效(失效)日期判断,
                    if (priceList.Count() == 1)
                    {
                        //string sqlUpdate = string.Format("update T_SAL_ORDER set FJNPRICECHANGE='1' where FID={0}", Id);
                        //sql.Add(sqlUpdate);
                        foreach (var obj in priceList)
                        {
                            //当分录中存在含税单价低于最低限价时,限价标识自动勾选上
                            if (taxPrice < Convert.ToDecimal(obj["DownPrice"]))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (priceList.Count() > 1)
                    {
                        //辅助属性判断
                        var priceEntry = priceList.Where(f => Convert.ToInt32(f["AuxPropId_Id"]) == auxPropId);
                        if (priceEntry.Count() == 1)
                        {
                            //string sqlUpdate = string.Format("update T_SAL_ORDER set FJNPRICECHANGE='1' where FID={0}", Id);
                            //sql.Add(sqlUpdate);
                            foreach (var obj in priceEntry)
                            {
                                //当分录中存在含税单价低于最低限价时,限价标识自动勾选上
                                if (taxPrice < Convert.ToDecimal(obj["DownPrice"]))
                                {
                                    flag = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (flag)
                {
                    billGroup["FJNPRICECHANGE"] = true;
                    //JN.K3.YDL.Core.AppServiceContext.SaveService.Save(this.Context, new DynamicObject[] { billGroup });//保存数据包
                }
            }
            //if (sql.Count > 0)
            //{
            //    DBUtils.ExecuteBatch (this.Context, sql,50);//批量处理sql,50表示一次提交50条
            //}
        }
예제 #9
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"]));
                }
            }
        }
예제 #10
0
        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterBarItemClick(e);


            if (e.BarItemKey.EqualsIgnoreCase("SZXY_tbGridPrintNo"))
            {
                this.Model.DataObject["FFormId"] = this.View.BusinessInfo.GetForm().Id;
                Utils.Save(View, new DynamicObject[] { this.Model.DataObject }, Kingdee.BOS.Orm.OperateOption.Create(), Context);

                #region
                if (this.Model.GetValue("F_SZXY_OrgId") is DynamicObject OrgObj)
                {
                    long orgid = Convert.ToInt64(OrgObj["Id"]);

                    //是否指定标签模板
                    string PJSQL = " ";

                    //DynamicObject PrintTemp = this.Model.GetValue("F_SZXY_LabelPrint") as DynamicObject;

                    //if (PrintTemp != null)
                    //{
                    //    string PId = Convert.ToString(PrintTemp["Id"]);

                    //    if (!PId.IsNullOrEmptyOrWhiteSpace())
                    //    {
                    //        PJSQL = $" and T1.Fid={PId} ";
                    //    }
                    //}


                    string MacInfo = Utils.GetMacAddress();
                    Logger.Debug("当前MAC地址", MacInfo);
                    string F_SZXY_CustId = "";
                    string material      = "";
                    string CustName      = "";

                    DynamicObjectCollection entry1 = this.Model.DataObject["SZXY_CPCHBGDEntry"] as DynamicObjectCollection;

                    if (entry1 != null)
                    {
                        StringBuilder STR = new StringBuilder();

                        DataSet PrintModelDS = null;
                        int     ckb          = 0;

                        foreach (var item in entry1.Where(m => !Convert.ToString(m["F_SZXY_Barcode"]).IsNullOrEmptyOrWhiteSpace()))
                        {
                            string BarNo = Convert.ToString(item["F_SZXY_Barcode"]);

                            if (item["F_SZXY_CustId"] is DynamicObject cust)
                            {
                                F_SZXY_CustId = Convert.ToString(cust["Id"]);
                                CustName      = Convert.ToString(cust["Name"]);
                            }
                            if (item["F_SZXY_Material"] is DynamicObject Mat)
                            {
                                material = Convert.ToString(Mat["Name"]);
                            }

                            if (!MacInfo.IsNullOrEmptyOrWhiteSpace())
                            {
                                Logger.Debug("调用匹配模板前客户为", CustName);
                                PrintModelDS = XYStraddleCut.getPrintModel(this.View, Context, PJSQL, orgid.ToString(), MacInfo, F_SZXY_CustId, material, BarNo, "BarNo", ref ckb);

                                if (PrintModelDS != null)
                                {
                                    XYStraddleCut.Print(PrintModelDS, ckb, Context, this.View, $"'{BarNo}'", "BarNo");
                                }
                            }
                        }
                    }

                    #endregion
                }
            }
        }
        /// <summary>
        /// 校验逻辑实现
        /// </summary>
        /// <param name="dataEntities"></param>
        /// <param name="validateContext"></param>
        /// <param name="ctx"></param>
        public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
        {
            if (dataEntities == null)
            {
                return;
            }

            var enProp = validateContext.BusinessInfo.GetField(matFldKey).Entity.EntryName;

            this.EntityKey = enProp;
            var orgFldKey = validateContext.BusinessInfo.MainOrgField.Key;

            foreach (var dataEntity in dataEntities)
            {
                string billType = dataEntity["FBillTypeID_Id"].ToString();
                if (!(billType == "005056c00008baa211e3097d9bc0332e" || billType == "005056945db184ed11e3af2dcda7ee49"))
                {
                    continue;                                                                                                     //产品检验单\自制工序检验单
                }
                DynamicObjectCollection rows = dataEntity[enProp] as DynamicObjectCollection;
                if (rows == null || rows.Count <= 0)
                {
                    continue;
                }

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

                //先查本单的数据
                var grp1 = (from p in checkRows
                            select new
                {
                    OrgID = long.Parse(dataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"].ToString()),
                    MatId = long.Parse(p["MaterialId_Id"].ToString()),
                    AuxId = long.Parse(p["AuxPropId_Id"].ToString()),
                    LotNumber = Convert.ToString(p["Lot_Text"]),
                    UnitEnzymes = Convert.ToDecimal(p["FJNUnitEnzymes"])
                }).Distinct().ToList();

                var grp2 = (from p in checkRows
                            select new
                {
                    OrgID = long.Parse(dataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"].ToString()),
                    MatId = long.Parse(p["MaterialId_Id"].ToString()),
                    AuxId = long.Parse(p["AuxPropId_Id"].ToString()),
                    LotNumber = Convert.ToString(p["Lot_Text"])
                }).Distinct().ToList();

                if (grp1.Count != grp2.Count)
                {
                    validateContext.AddError(dataEntity.DataEntity,
                                             new ValidationErrorInfo("FBillNo",
                                                                     Convert.ToString(((DynamicObject)(dataEntity.DataEntity))["Id"]),
                                                                     dataEntity.DataEntityIndex,
                                                                     dataEntity.RowIndex,
                                                                     "JN-InStockCheck-002",
                                                                     string.Format("保存失败:启用双计量单位的物料,公司+物料+辅助属性+批号所对应的单位酶活量有多个!", dataEntity.BillNo),
                                                                     "金蝶提示", ErrorLevel.Warning));
                    continue;
                }

                //查数据库后台的数据
                foreach (var item in checkRows)
                {
                    var matVal = item["MaterialId"] as DynamicObject;
                    if (matVal == null)
                    {
                        continue;
                    }
                    CheckPara para = new CheckPara();
                    para.lotNumber = item["Lot_Text"].ToString();
                    if (para.lotNumber.Length == 0)
                    {
                        continue;
                    }
                    DynamicObjectCollection linkData = item["FEntity_Link"] as DynamicObjectCollection;
                    para.tableName     = linkData[0]["sTableName"].ToString();
                    para.linkId        = string.Join(",", linkData.Select(s => Convert.ToInt32(s["SBillId"])));
                    para.currEnFldName = validateContext.BusinessInfo.GetField(matFldKey).Entity.EntryPkFieldName;
                    para.orgId         = Convert.ToInt64(dataEntity.DataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"]);
                    para.matId         = Convert.ToInt64(matVal["Id"]);
                    var aux = item["AuxPropId"] as DynamicObject;
                    if (aux != null)
                    {
                        para.auxPropId = Convert.ToInt64(aux["Id"]);
                    }

                    para.unitEnzymes    = Convert.ToDecimal(item["FJNUnitEnzymes"]);
                    para.currentEntryId = Convert.ToInt64(item["Id"]);
                    para.currFormKey    = validateContext.BusinessInfo.GetForm().Id;
                    para.ctx            = ctx;

                    string errInfor = "";
                    if (CheckExists(para, out errInfor))
                    {
                        validateContext.AddError(dataEntity.DataEntity,
                                                 new ValidationErrorInfo("FBillNo",
                                                                         Convert.ToString(dataEntity.DataEntity["Id"]),
                                                                         dataEntity.DataEntityIndex,
                                                                         dataEntity.RowIndex,
                                                                         "JN-InStockCheck-002",
                                                                         string.Format("保存失败:第{1}行物料,启用双计量单位,公司+物料+辅助属性+批号所对应的单位酶活量有多个({0})!", errInfor, rows.IndexOf(item) + 1),
                                                                         "金蝶提示", ErrorLevel.Warning));
                        continue;
                    }
                }
            }
        }
예제 #12
0
        private List <string> ValidateEntry(string requestType, DynamicObjectCollection entrys, string billStatus)
        {
            List <string> list = new List <string>();

            using (IEnumerator <DynamicObject> enumerator = entrys.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Func <DynamicObject, bool> predicate = null;
                    DynamicObject entry = enumerator.Current;
                    if (predicate == null)
                    {
                        predicate = p => Convert.ToInt64(p["SosurceRowID"]) == Convert.ToInt64(entry["SosurceRowID"]);
                    }
                    List <DynamicObject> source = entrys.Where <DynamicObject>(predicate).ToList <DynamicObject>();
                    bool flag  = source.Any <DynamicObject>(p => !string.IsNullOrWhiteSpace(Convert.ToString(p["SourceBillNo"])));
                    bool flag2 = Convert.ToBoolean(entry["IsFromBorrow"]);
                    if (!flag || !flag2)
                    {
                        return(list);
                    }
                    //源单可冲销金额
                    decimal num = source.Sum <DynamicObject>((Func <DynamicObject, decimal>)(p => Convert.ToDecimal(p["SrcBorrowAmount"])));
                    Convert.ToDecimal(entry["ExpSubmitAmount"]); //核定报销金额
                    Convert.ToDecimal(entry["ReqSubmitAmount"]); //核定付退款金额
                    decimal num2 = source.Sum <DynamicObject>((Func <DynamicObject, decimal>)(p => Convert.ToDecimal(p["ExpSubmitAmount"])));
                    decimal num3 = source.Sum <DynamicObject>((Func <DynamicObject, decimal>)(p => Convert.ToDecimal(p["ReqSubmitAmount"])));
                    source.Sum <DynamicObject>((Func <DynamicObject, decimal>)(p => Convert.ToDecimal(p["SrcOffsetAmount"])));
                    decimal num4 = source.Sum <DynamicObject>((Func <DynamicObject, decimal>)(p => Convert.ToDecimal(p["FSRCPAYEDAMOUNT"])));//源单已付款金额
                    string  str  = requestType;
                    if (str == null)
                    {
                        goto Label_034C;
                    }
                    if (!(str == "1"))
                    {
                        if (str == "2")
                        {
                            goto Label_0269;
                        }
                        goto Label_034C;
                    }
                    if (num > num2)
                    {
                        if (billStatus.Equals("B"))
                        {
                            list.Add(string.Format(ResManager.LoadKDString("申请付款时,核定报销金额不能小于源单可冲销金额:{0}", "003831000013828", SubSystemType.FIN, new object[0]), num));
                        }
                        else
                        {
                            list.Add(string.Format(ResManager.LoadKDString("申请付款时,申请报销金额不能小于源单可冲销金额:{0}", "003831000012434", SubSystemType.FIN, new object[0]), num));
                        }
                    }
                    if (num > (num2 - num3 - num4))
                    {
                        if (billStatus.Equals("B"))
                        {
                            list.Add(string.Format(ResManager.LoadKDString("申请付款时,核定报销金额 - 核定付款金额 - 源单已付款金额不能小于源单可冲销金额:{0}", "003831000013829", SubSystemType.FIN, new object[0]), num));
                        }
                        else
                        {
                            list.Add(string.Format(ResManager.LoadKDString("申请付款时,申请报销金额 - 付款申请金额 - 源单已付款金额不能小于源单可冲销金额:{0}", "003831000012435", SubSystemType.FIN, new object[0]), num));
                        }
                    }
                    continue;
Label_0269:
                    if (num < num2)
                    {
                        if (billStatus.Equals("B"))
                        {
                            list.Add(string.Format(ResManager.LoadKDString("退款申请时,核定报销金额不能大于源单未下推金额:{0}", "003831000013830", SubSystemType.FIN, new object[0]), num));
                        }
                        else
                        {
                            list.Add(string.Format(ResManager.LoadKDString("退款申请时,申请报销金额不能大于源单未下推金额:{0}", "003831000012436", SubSystemType.FIN, new object[0]), num));
                        }
                    }
                    if (num < (num2 + num3 + num4))
                    {
                        if (billStatus.Equals("B"))
                        {
                            list.Add(string.Format(ResManager.LoadKDString("退款申请时,核定报销金额 + 核定退款金额  + 源单已付款金额不能大于源单可冲销金额:{0}", "003831000013831", SubSystemType.FIN, new object[0]), num));
                        }
                        else
                        {
                            list.Add(string.Format(ResManager.LoadKDString("退款申请时,申请报销金额 + 退款申请金额+ 源单已付款金额不能大于源单可冲销金额:{0}", "003831000012437", SubSystemType.FIN, new object[0]), num));
                        }
                    }
                    continue;
Label_034C:
                    if (num < num2)
                    {
                        if (billStatus.Equals("B"))
                        {
                            list.Add(string.Format(ResManager.LoadKDString("不退不付时, 核定报销金额不能大于源单可冲销金额:{0}", "003831000013832", SubSystemType.FIN, new object[0]), num));
                            continue;
                        }
                        list.Add(string.Format(ResManager.LoadKDString("不退不付时, 申请报销金额不能大于源单可冲销金额:{0}", "003831000012438", SubSystemType.FIN, new object[0]), num));
                    }
                }
            }
            return(list);
        }
예제 #13
0
        /// <summary>
        /// 校验逻辑实现
        /// </summary>
        /// <param name="dataEntities"></param>
        /// <param name="validateContext"></param>
        /// <param name="ctx"></param>
        public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
        {
            if (dataEntities == null)
            {
                return;
            }

            var enProp = validateContext.BusinessInfo.GetField(matFldKey).Entity.EntryName;

            this.EntityKey = enProp;

            var   orgFldKey = validateContext.BusinessInfo.MainOrgField.Key;
            Field lotFld    = validateContext.BusinessInfo.GetField(this.LotNoFldKey);
            Field matFld    = validateContext.BusinessInfo.GetField(this.MatFldKey);
            Field auxFld    = validateContext.BusinessInfo.GetField(this.AuxPropFldKey);

            foreach (var dataEntity in dataEntities)
            {
                DynamicObjectCollection rows = dataEntity[enProp] as DynamicObjectCollection;
                if (rows == null || rows.Count <= 0)
                {
                    continue;
                }

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

                //先查本单的数据
                var grp1 = (from p in checkRows
                            select new
                {
                    OrgID = long.Parse(dataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"].ToString()),
                    MatId = long.Parse(p[matFld.PropertyName + "_Id"].ToString()),
                    AuxId = long.Parse(p[auxFld.PropertyName + "_Id"].ToString()),
                    LotNumber = Convert.ToString(p[lotFld.PropertyName + "_Text"]),
                    UnitEnzymes = Convert.ToDecimal(p["FJNUnitEnzymes"])
                }).Distinct().ToList();

                var grp2 = (from p in checkRows
                            select new
                {
                    OrgID = long.Parse(dataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"].ToString()),
                    MatId = long.Parse(p[matFld.PropertyName + "_Id"].ToString()),
                    AuxId = long.Parse(p[auxFld.PropertyName + "_Id"].ToString()),
                    LotNumber = Convert.ToString(p[lotFld.PropertyName + "_Text"])
                }).Distinct().ToList();

                if (grp1.Count != grp2.Count)
                {
                    validateContext.AddError(dataEntity.DataEntity,
                                             new ValidationErrorInfo("FBillNo",
                                                                     Convert.ToString(((DynamicObject)(dataEntity.DataEntity))["Id"]),
                                                                     dataEntity.DataEntityIndex,
                                                                     dataEntity.RowIndex,
                                                                     "JN-InStockCheck-002",
                                                                     string.Format("保存失败:启用双计量单位的物料,公司+物料+辅助属性+批号所对应的单位酶活量有多个!", dataEntity.BillNo),
                                                                     "金蝶提示"));
                    continue;
                }

                //查数据库后台的数据
                foreach (var item in checkRows)
                {
                    var matVal = matFld.GetFieldValue(item) as DynamicObject;
                    if (matVal == null)
                    {
                        continue;
                    }

                    CheckPara para = new CheckPara();
                    para.currEnFldName = validateContext.BusinessInfo.GetField(matFldKey).Entity.EntryPkFieldName;
                    para.orgId         = Convert.ToInt64(dataEntity.DataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"]);
                    para.matId         = Convert.ToInt64(matVal["Id"]);
                    var lotVal = lotFld.GetFieldValue(item);
                    if (lotVal != null && !lotVal.IsNullOrEmptyOrWhiteSpace())
                    {
                        para.lotNumber = lotVal.ToString();
                    }
                    else
                    {
                        para.lotNumber = "";
                    }
                    var aux = auxFld.GetFieldValue(item) as DynamicObject;
                    if (aux != null)
                    {
                        para.auxPropId = Convert.ToInt64(aux["Id"]);
                    }

                    para.unitEnzymes    = Convert.ToDecimal(item["FJNUnitEnzymes"]);
                    para.currentEntryId = Convert.ToInt64(item["Id"]);
                    para.currFormKey    = validateContext.BusinessInfo.GetForm().Id;
                    para.ctx            = ctx;

                    string errInfor = "";
                    if (CheckExists(para, out errInfor))
                    {
                        validateContext.AddError(dataEntity.DataEntity,
                                                 new ValidationErrorInfo("FBillNo",
                                                                         Convert.ToString(dataEntity.DataEntity["Id"]),
                                                                         dataEntity.DataEntityIndex,
                                                                         dataEntity.RowIndex,
                                                                         "JN-InStockCheck-002",
                                                                         string.Format("保存失败:第{1}行物料,启用双计量单位,公司+物料+辅助属性+批号所对应的单位酶活量有多个({0})!", errInfor, rows.IndexOf(item) + 1),
                                                                         "金蝶提示"));
                        continue;
                    }
                }
            }
        }