Beispiel #1
0
        private void SetDefaultExchange(AfterFieldMappingEventArgs e)
        {
            ExtendedDataEntity[] entityArray = e.TargetExtendDataEntitySet.FindByEntityKey("FBillHead");
            e.TargetExtendDataEntitySet.FindByEntityKey("FSaleOrderEntry");
            ExtendedDataEntity[] entityArray2  = e.TargetExtendDataEntitySet.FindByEntityKey("FSaleOrderFinance");
            ICommonService       commonService = ServiceFactory.GetCommonService(base.Context);

            foreach (ExtendedDataEntity entity in entityArray2)
            {
                ExtendedDataEntity entity2 = entityArray[entity.DataEntityIndex];
                long       num             = Convert.ToInt64(entity2.DataEntity["SaleOrgId_Id"]);
                long       num2            = 0;
                long       num3            = 0;
                JSONObject defCurrencyAndExchangeTypeByBizOrgID = commonService.GetDefCurrencyAndExchangeTypeByBizOrgID(base.Context, num);
                if (defCurrencyAndExchangeTypeByBizOrgID != null)
                {
                    num2 = Convert.ToInt64(defCurrencyAndExchangeTypeByBizOrgID["FCyForID"]);
                    num3 = Convert.ToInt64(defCurrencyAndExchangeTypeByBizOrgID["FRateType"]);
                }
                BaseDataField field = e.TargetBusinessInfo.GetField("FExchangeTypeId") as BaseDataField;
                FieldUtils.SetBaseDataFieldValue(base.Context, field, entity.DataEntity, num3);
                long     num4 = Convert.ToInt64(entity.DataEntity["SettleCurrId_Id"]);
                DateTime time = Convert.ToDateTime(entityArray[entity.DataEntityIndex].DataEntity["Date"]);
                if ((num2 == num4) || (time == DateTime.MinValue))
                {
                    entity.DataEntity["ExchangeRate"] = 1;
                }
                else
                {
                    KeyValuePair <decimal, int> pair = commonService.GetExchangeRateAndDecimal(base.Context, num4, num2, num3, time, time);
                    entity.DataEntity["ExchangeRate"] = pair.Key;
                }
            }
        }
Beispiel #2
0
 public static void AddMsg(ValidateContext validateContext, ExtendedDataEntity entity, string title, string msg, string displayToFieldKey = "", ErrorLevel errorLevel = 2)
 {
     if (displayToFieldKey.IsNullOrEmptyOrWhiteSpace())
     {
         displayToFieldKey = validateContext.BusinessInfo.GetBillNoField().Key;
     }
     AddMsg(validateContext, entity, displayToFieldKey, entity["Id"].ToString(), title, msg, errorLevel);
 }
        private List <long> GetProfitCenterIds(ExtendedDataEntity entity)
        {
            DynamicObjectCollection objects = entity["ProfitCenter"] as DynamicObjectCollection;

            if (objects == null)
            {
                return(new List <long>());
            }
            return((from p in objects select Convert.ToInt64(p["ProfitCenter_Id"])).ToList <long>());
        }
        private void CheckFormula(Context ctx, ValidateContext validateContext, ExtendedDataEntity entity, BudgetFormulaService service)
        {
            string formula = Convert.ToString(entity["Express"]);

            if (!service.ValidityFormula(formula))
            {
                string title = ResManager.LoadKDString("合法性校验", "003286000011212", SubSystemType.FIN, new object[0]);
                string msg   = ResManager.LoadKDString("公式设置不正确,请重新设置!", "003286000011305", SubSystemType.FIN, new object[0]);
                CommonValidate.AddMsg(validateContext, entity, title, msg, "", ErrorLevel.Error);
            }
        }
            /// <summary>
            /// 客户管理员
            /// </summary>
            /// <param name="dataEntity"></param>
            /// <param name="validateContext"></param>
            /// <param name="ctx"></param>
            /// <param name="FID"></param>
            private void Act_CtrlCustAdmin(ExtendedDataEntity dataEntity, ValidateContext validateContext, Context ctx, string FID)
            {
                string FCustId = dataEntity["FCustName"] == null ? "0" : (dataEntity["FCustName"] as DynamicObject)["Id"].ToString();

                if (FCustId == "0")
                {
                    ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                        string.Empty,
                        FID,
                        dataEntity.DataEntityIndex,
                        dataEntity.RowIndex,
                        FID,
                        "客户不能为空!",
                        string.Empty);
                    validateContext.AddError(null, ValidationErrorInfo);
                }
                string sql  = string.Format("SELECT FISTRADE FROM T_BD_CUSTOMER WHERE FCUSTID='{0}'", FCustId);
                var    objs = DBUtils.ExecuteDynamicObject(ctx, sql);

                if (objs.Count > 0)
                {
                    string FISTRADE = objs[0]["FISTRADE"].ToString();
                    if (FISTRADE == "0" || FISTRADE == "")
                    {
                        ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                            string.Empty,
                            FID,
                            dataEntity.DataEntityIndex,
                            dataEntity.RowIndex,
                            FID,
                            "当前客户为非交易客户,请转为交易客户后再进行提交!",
                            string.Empty);
                        validateContext.AddError(null, ValidationErrorInfo);
                    }
                    else
                    {
                        string FCustName = dataEntity["FCustName"] == null ? "" : (dataEntity["FCustName"] as DynamicObject)["Name"].ToString();
                        sql  = "SELECT FCUSTID FROM T_BD_CUSTOMER_L WHERE FNAME='" + FCustName + "' AND FLOCALEID='2052'";
                        objs = DBUtils.ExecuteDynamicObject(ctx, sql);
                        if (objs.Count < 1)
                        {
                            ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                                string.Empty,
                                FID,
                                dataEntity.DataEntityIndex,
                                dataEntity.RowIndex,
                                FID,
                                "当前客户还未进行分配,请分配到相应组织后再进行提交!",
                                string.Empty);
                            validateContext.AddError(null, ValidationErrorInfo);
                        }
                    }
                }
            }
        private void DeleteValidator(Context ctx, ValidateContext validateContext, ExtendedDataEntity entity, ReportSchemeService service)
        {
            long reportSchemeId     = Convert.ToInt64(entity["Id"]);
            bool flag               = service.IsReportSchemeUsed(ctx, reportSchemeId);
            bool ctrlRuleBySchemeId = service.GetCtrlRuleBySchemeId(ctx, reportSchemeId);

            if (flag || ctrlRuleBySchemeId)
            {
                string.Format("模板样式方案 {0} 已经被引用,不允许删除!", entity["Name"]);
                validateContext.AddError(entity, new ValidationErrorInfo("Name", "Id", entity.DataEntityIndex, 0, Convert.ToString(entity["Id"]), "该模板样式方案已经被其他单据引用,不能删除!", "删除:", ErrorLevel.Error));
            }
        }
            /// <summary>
            /// Bom员
            /// </summary>
            /// <param name="dataEntity"></param>
            /// <param name="validateContext"></param>
            /// <param name="ctx"></param>
            /// <param name="FID"></param>
            private void Act_CtrlBomer(ExtendedDataEntity dataEntity, ValidateContext validateContext, Context ctx, string FID)
            {
                bool   IsNull      = false;
                var    entity      = dataEntity["FEntityBPR"] as DynamicObjectCollection;
                string FBMtlGroup  = "0";
                string FMaterialID = "0";

                string userId = ctx.UserId.ToString();

                string sql   = string.Format(@"SELECT emg.F_ORA_CRMMTLGP FROM
                        (SELECT * FROM T_SEC_USER WHERE FUSERID='{0}') u
                        INNER JOIN V_BD_CONTACTOBJECT c ON u.FLINKOBJECT=c.FID
                        INNER JOIN T_HR_EMPINFO e ON c.FNUMBER=e.FNUMBER AND e.F_ORA_ISCRMBOM=1
                        INNER JOIN T_HR_EMPINFOCrmMG emg ON e.FID=emg.FID", userId);
                var    objs  = DBUtils.ExecuteDynamicObject(ctx, sql);
                string MtlGp = "";


                for (int i = 0; i < entity.Count; i++)
                {
                    FBMtlGroup = entity[i]["FBMtlGroup"] == null ? "0" : (entity[i]["FBMtlGroup"] as DynamicObject)["Id"].ToString();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        if (objs[j]["F_ORA_CRMMTLGP"].ToString() == FBMtlGroup)
                        {
                            FMaterialID = entity[i]["FMaterialID"] == null ? "0" : (entity[i]["FMaterialID"] as DynamicObject)["Id"].ToString();
                            if (FMaterialID == "0")
                            {
                                IsNull = true;
                                break;
                            }
                        }
                    }
                }

                if (IsNull)
                {
                    ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                        string.Empty,
                        FID,
                        dataEntity.DataEntityIndex,
                        dataEntity.RowIndex,
                        FID,
                        "请选择对应的物料!",
                        string.Empty);
                    validateContext.AddError(null, ValidationErrorInfo);
                }
            }
Beispiel #8
0
        private BudgetReportEntity GetReportEntityByExtendedDate(ExtendedDataEntity entity)
        {
            BudgetReportEntity entity2 = new BudgetReportEntity {
                SchemeID     = Convert.ToInt32(entity.DataEntity["SchemeID_Id"]),
                SampleID     = entity["SampleID_Id"].ToString(),
                AmountunitID = Convert.ToInt32(entity.DataEntity["AmountUnitID_Id"]),
                CurrencyID   = Convert.ToInt32(entity.DataEntity["CurrencyID_Id"]),
                DeptOrgID    = Convert.ToInt64(entity.DataEntity["DeptOrgID_Id"])
            };
            DynamicObject obj2 = entity.DataEntity["DeptOrgID"] as DynamicObject;

            entity2.DeptOrgName = (obj2 == null) ? string.Empty : obj2["Name"].ToString();
            entity2.Year        = Convert.ToInt32(entity.DataEntity["Year"]);
            entity2.Period      = Convert.ToInt32(entity.DataEntity["Period"]);
            entity2.CycleID     = entity.DataEntity["CycleID"].ToString();
            entity2.ID          = entity.DataEntity["Id"].ToString();
            return(entity2);
        }
Beispiel #9
0
        public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx)
        {
            Dictionary <int, string> source = new Dictionary <int, string>();

            source.Add(0, ResManager.LoadKDString("年", "0032056000020678", SubSystemType.FIN, new object[0]));
            source.Add(1, ResManager.LoadKDString("半年", "0032056000020679", SubSystemType.FIN, new object[0]));
            source.Add(2, ResManager.LoadKDString("季", "0032056000020680", SubSystemType.FIN, new object[0]));
            source.Add(3, ResManager.LoadKDString("月", "0032056000020681", SubSystemType.FIN, new object[0]));
            source.Add(4, ResManager.LoadKDString("旬", "0032056000020682", SubSystemType.FIN, new object[0]));
            source.Add(5, ResManager.LoadKDString("周", "0032056000020683", SubSystemType.FIN, new object[0]));
            source.Add(6, ResManager.LoadKDString("日", "0032056000020684", SubSystemType.FIN, new object[0]));
            ExtendedDataEntity[] entityArray = dataEntities;
            for (int i = 0; i < entityArray.Length; i++)
            {
                Func <KeyValuePair <int, string>, bool> predicate = null;
                ExtendedDataEntity entity  = entityArray[i];
                StringBuilder      builder = new StringBuilder();
                builder.Append(string.Format(ResManager.LoadKDString("组织:{0}  ", "0032056000020566", SubSystemType.FIN, new object[0]), Convert.ToString((entity.DataEntity["OrgID"] as DynamicObject)["Name"])));
                builder.Append(string.Format(ResManager.LoadKDString("预算模板:{0}  ", "0032056000020558", SubSystemType.FIN, new object[0]), entity.DataEntity["NUMBER"].ToString()));
                if (predicate == null)
                {
                    predicate = dic => ((long)dic.Key) == Convert.ToUInt32(entity.DataEntity["CycleID"]);
                }
                builder.Append(string.Format(ResManager.LoadKDString("周期:{0}  ", "0032056000020559", SubSystemType.FIN, new object[0]), source.Where <KeyValuePair <int, string> >(predicate).FirstOrDefault <KeyValuePair <int, string> >().Value));
                builder.Append(string.Format(ResManager.LoadKDString("预算年度:{0}  ", "0032056000020560", SubSystemType.FIN, new object[0]), Convert.ToString(entity.DataEntity["Year"])));
                builder.Append(string.Format(ResManager.LoadKDString("币别:{0}  ", "0032056000020561", SubSystemType.FIN, new object[0]), Convert.ToString((entity.DataEntity["CurrencyID"] as DynamicObject)["Name"])));
                builder.Append(string.Format(ResManager.LoadKDString("预算方案:{0}  ", "0032056000020562", SubSystemType.FIN, new object[0]), Convert.ToString((entity.DataEntity["SchemeID"] as DynamicObject)["NUMBER"])));
                string str = builder.ToString();
                DynamicObjectCollection objects = entity["BM_Sheet"] as DynamicObjectCollection;
                if ((objects == null) || (objects.Count <= 0))
                {
                    string message = ResManager.LoadKDString("报表未编辑,不能提交!", "0032056000020563", SubSystemType.FIN, new object[0]);
                    string title   = ResManager.LoadKDString("提交:", "0032056000020564", SubSystemType.FIN, new object[0]) + str;
                    validateContext.AddError(entity, new ValidationErrorInfo("FNumber", "FRptID", entity.DataEntityIndex, 0, Convert.ToString(entity["ID"]), message, title, ErrorLevel.Error));
                }
            }
        }
        /// <summary>
        /// 目标单单据构建完毕,且已经创建好与源单的关联关系之后,触发此事件
        /// </summary>
        /// <param name="e"></param>
        /// <remarks>
        /// 本事件的时机,刚好能够符合需求,
        /// 而AfterConvert事件,则在执行表单服务策略之后
        /// </remarks>
        public override void OnAfterCreateLink(CreateLinkEventArgs e)
        {
            // 目标单单据体元数据
            Entity entity = e.TargetBusinessInfo.GetEntity("FRefundBillSrcEntity");
            Entity es     = e.SourceBusinessInfo.GetEntity("FEntity");

            // 读取已经生成的付款退款单
            ExtendedDataEntity[] bills = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead");

            // 定义一个集合,存储新拆分出来的单据体行
            List <ExtendedDataEntity> newRows = new List <ExtendedDataEntity>();

            // 对目标单据进行循环
            foreach (var bill in bills)
            {
                // 取单据体集合
                DynamicObjectCollection rowObjs = entity.DynamicProperty.GetValue(bill.DataEntity)
                                                  as DynamicObjectCollection;



                // 对单据体进行循环:从后往前循环,新拆分的行,避开循环
                int rowCount    = rowObjs.Count;
                int newRowCount = 1;
                for (int i = rowCount - 1; i >= 0; i--)
                {
                    DynamicObject rowObj = rowObjs[i];

                    double        F_JNRoadAmount    = Convert.ToDouble(rowObj["F_JNRoadAmount"]);
                    double        PLANPAYAMOUNT     = Convert.ToDouble(rowObj["PLANREFUNDAMOUNT"]);
                    double        AFTTAXTOTALAMOUNT = Convert.ToDouble(rowObj["AFTTAXTOTALAMOUNT"]);
                    double        F_JNTAXAmount     = Convert.ToDouble(rowObj["F_JNTAXAmount"]);
                    DynamicObject newRowObj         = null;


                    rowObj["PLANREFUNDAMOUNT"]  = PLANPAYAMOUNT - F_JNRoadAmount - F_JNTAXAmount;
                    rowObj["AFTTAXTOTALAMOUNT"] = AFTTAXTOTALAMOUNT - F_JNRoadAmount - F_JNTAXAmount;
                    rowObj["REALREFUNDAMOUNT"]  = rowObj["PLANREFUNDAMOUNT"];
                    rowObj["F_JNRoadAmount"]    = 0;
                    // 根据规则进行拆分:
                    // 示例代码略过拆分规则,强制对每行进行拆分
                    // 通过复制的方式,产生新行:确保字段值、关联关系与原行一致
                    if (F_JNRoadAmount > 0)
                    {
                        var           SRCCOSTID = rowObj["FSRCCOSTID"] as DynamicObject;
                        DynamicObject SRCCOST   = (DynamicObject)SRCCOSTID.Clone(true, false);
                        newRowObj = (DynamicObject)rowObj.Clone(false, true);
                        //DynamicObject newRowObj = rowObj.Clone(;
                        //DynamicObject newRowObj = (DynamicObject)rowObj.Clone(true, true);
                        newRowObj["PLANREFUNDAMOUNT"]  = F_JNRoadAmount;
                        newRowObj["AFTTAXTOTALAMOUNT"] = F_JNRoadAmount;
                        newRowObj["F_JNRoadAmount"]    = 0;
                        newRowObj["REALREFUNDAMOUNT"]  = F_JNRoadAmount;
                        //newRowObj["Seq"] = i + 1;

                        QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                        queryParam.FormId = "BD_Expense";

                        queryParam.SelectItems.Add(new SelectorItemInfo("FMasterId"));
                        queryParam.SelectItems.Add(new SelectorItemInfo("FNumber"));
                        queryParam.SelectItems.Add(new SelectorItemInfo("FName"));
                        queryParam.FilterClauseWihtKey = string.Format(" FNumber = '{0}' ", "FYXM23");
                        var expense = QueryServiceHelper.GetDynamicObjectCollection(this.Context, queryParam);
                        newRowObj["FSRCCOSTID_Id"] = expense[0]["FMasterId"];
                        SRCCOST["Id"]           = expense[0]["FMasterId"];
                        SRCCOST["msterId"]      = expense[0]["FMasterId"];
                        SRCCOST["Name"]         = expense[0]["FName"];
                        SRCCOST["Number"]       = expense[0]["FNumber"];
                        newRowObj["FSRCCOSTID"] = SRCCOST;


                        // 把新行,插入到单据中,排在当前行之后
                        rowObjs.Insert(i + 1, newRowObj);

                        //newRowObj["SRCCOSTID_Id"] = 131120;
                    }

                    if (F_JNTAXAmount > 0)
                    {
                        var           SRCCOSTID = rowObj["FSRCCOSTID"] as DynamicObject;
                        DynamicObject SRCCOST   = (DynamicObject)SRCCOSTID.Clone(true, false);

                        newRowObj = (DynamicObject)rowObj.Clone(false, true);
                        //DynamicObject newRowObj = rowObj.Clone(;
                        //DynamicObject newRowObj = (DynamicObject)rowObj.Clone(true, true);
                        newRowObj["PLANREFUNDAMOUNT"]  = F_JNTAXAmount;
                        newRowObj["AFTTAXTOTALAMOUNT"] = F_JNTAXAmount;
                        newRowObj["F_JNRoadAmount"]    = 0;
                        newRowObj["REALREFUNDAMOUNT"]  = F_JNTAXAmount;
                        //newRowObj["Seq"] = i + 1;

                        QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
                        queryParam.FormId = "BD_Expense";

                        queryParam.SelectItems.Add(new SelectorItemInfo("FMasterId"));
                        queryParam.SelectItems.Add(new SelectorItemInfo("FNumber"));
                        queryParam.SelectItems.Add(new SelectorItemInfo("FName"));
                        queryParam.FilterClauseWihtKey = string.Format(" FNumber = '{0}' ", "FYXM98");
                        var expense = QueryServiceHelper.GetDynamicObjectCollection(this.Context, queryParam);
                        newRowObj["FSRCCOSTID_Id"] = expense[0]["FMasterId"];
                        SRCCOST["Id"]           = expense[0]["FMasterId"];
                        SRCCOST["msterId"]      = expense[0]["FMasterId"];
                        SRCCOST["Name"]         = expense[0]["FName"];
                        SRCCOST["Number"]       = expense[0]["FNumber"];
                        newRowObj["FSRCCOSTID"] = SRCCOST;


                        // 把新行,插入到单据中,排在当前行之后
                        rowObjs.Insert(i + 1, newRowObj);

                        //newRowObj["SRCCOSTID_Id"] = 131120;
                    }
                    if (newRowObj != null)
                    {
                        // 为新行创建一个ExtendedDataEntity对象,表单服务策略需要此对象
                        ExtendedDataEntity newRow = new ExtendedDataEntity(
                            newRowObj, bill.DataEntityIndex, rowCount + newRowCount);
                        newRows.Add(newRow);

                        newRowCount++;
                    }
                }
            }

            // 把新拆分出来的单据体行,加入到下推结果中
            // 特别说明:如果去掉此语句,新拆分的行,不会执行表单服务策略
            e.TargetExtendedDataEntities.AddExtendedDataEntities("FEntity", newRows.ToArray());
        }
Beispiel #11
0
        private void AddMsg(ValidateContext validateContext, ExtendedDataEntity entity, string displayToFieldKey, string msg)
        {
            ValidationErrorInfo errorInfo = new ValidationErrorInfo(displayToFieldKey, entity.DataEntity["Id"].ToString(), entity.DataEntityIndex, entity.RowIndex, "???", msg, Convert.ToString(entity.DataEntity["BillNo"]), ErrorLevel.Error);

            validateContext.AddError(entity.DataEntity, errorInfo);
        }
            /// <summary>
            /// 合同评审员
            /// </summary>
            /// <param name="dataEntity"></param>
            /// <param name="validateContext"></param>
            /// <param name="ctx"></param>
            /// <param name="FID"></param>
            private void Act_CtrlContractor(ExtendedDataEntity dataEntity, ValidateContext validateContext, Context ctx, string FID)
            {
                string FPayTerm      = dataEntity["FPayTerm"] == null ? "0" : (dataEntity["FPayTerm"] as DynamicObject)["Id"].ToString();
                string F_CZ_BillType = dataEntity["F_CZ_BillType"] == null ? "0" : dataEntity["F_CZ_BillType"].ToString();
                string FSettleOrgId  = dataEntity["FSettleOrgId"] == null ? "0" : (dataEntity["FSettleOrgId"] as DynamicObject)["Id"].ToString();

                if (FPayTerm == "0")
                {
                    ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                        string.Empty,
                        FID,
                        dataEntity.DataEntityIndex,
                        dataEntity.RowIndex,
                        FID,
                        "请选择付款方式!",
                        string.Empty);
                    validateContext.AddError(null, ValidationErrorInfo);
                }
                if (F_CZ_BillType == "")
                {
                    ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                        string.Empty,
                        FID,
                        dataEntity.DataEntityIndex,
                        dataEntity.RowIndex,
                        FID,
                        "请选择订单类型!",
                        string.Empty);
                    validateContext.AddError(null, ValidationErrorInfo);
                }
                if (FSettleOrgId == "0")
                {
                    ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                        string.Empty,
                        FID,
                        dataEntity.DataEntityIndex,
                        dataEntity.RowIndex,
                        FID,
                        "请选择签单组织!",
                        string.Empty);
                    validateContext.AddError(null, ValidationErrorInfo);
                }
                var  entity = dataEntity["FEntityBPR"] as DynamicObjectCollection;
                bool IsNull = false;

                foreach (var row in entity)
                {
                    string FProdFactory = row["FProdFactory"] == null ? "0" : (row["FProdFactory"] as DynamicObject)["Id"].ToString();
                    if (FProdFactory == "0")
                    {
                        IsNull = true;
                    }
                }

                if (IsNull)
                {
                    ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo(
                        string.Empty,
                        FID,
                        dataEntity.DataEntityIndex,
                        dataEntity.RowIndex,
                        FID,
                        "请选择表体的生产工厂!",
                        string.Empty);
                    validateContext.AddError(null, ValidationErrorInfo);
                }
            }
        private void SplitData(AfterConvertEventArgs e)
        {
            ExtendedDataEntity[] source = e.Result.FindByEntityKey("FEntity");
            string        billTypeId    = (source.FirstOrDefault <ExtendedDataEntity>().DataEntity.Parent as DynamicObject).GetDynamicObjectItemValue <string>("FBillTypeID_Id", null);
            DynamicObject dynamicObject = Kingdee.K3.MFG.App.AppServiceContext.BusinessDataService.LoadBillTypePara(base.Context, "InspectBillTPS", billTypeId, true);
            string        str2          = dynamicObject.GetDynamicObjectItemValue <string>("SPLITBY", null);

            if ((!dynamicObject.IsNullOrEmpty() && !str2.EqualsIgnoreCase("A")) && !str2.IsNullOrEmptyOrWhiteSpace())
            {
                List <long> materialIds = (from s in source select s.DataEntity.GetDynamicValue <long>("MaterialId_Id", 0L)).ToList <long>();
                Dictionary <long, Tuple <long, long> > inspectorInfo = Kingdee.K3.MFG.App.AppServiceContext.GetService <IInspectService>().GetInspectorInfo(base.Context, materialIds);
                if (!inspectorInfo.IsEmpty <KeyValuePair <long, Tuple <long, long> > >())
                {
                    ExtendedDataEntity[]      entityArray2 = e.Result.FindByEntityKey("FBillHead");
                    List <ExtendedDataEntity> list2        = new List <ExtendedDataEntity>();
                    foreach (ExtendedDataEntity entity in entityArray2)
                    {
                        Dictionary <long, ExtendedDataEntity> dictionary2 = new Dictionary <long, ExtendedDataEntity>();
                        foreach (DynamicObject obj3 in entity.DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null))
                        {
                            Tuple <long, long> tuple;
                            long key = obj3.GetDynamicValue <long>("MaterialId_Id", 0L);
                            if (inspectorInfo.TryGetValue(key, out tuple))
                            {
                                long num2 = str2.EqualsIgnoreCase("B") ? tuple.Item1 : tuple.Item2;
                                if (dictionary2.Keys.Contains <long>(num2))
                                {
                                    dictionary2[num2].DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null).Add(obj3);
                                }
                                else
                                {
                                    ExtendedDataEntity      entity2  = (ExtendedDataEntity)entity.Clone();
                                    DynamicObjectCollection objects3 = entity2.DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null);
                                    objects3.Clear();
                                    objects3.Add(obj3);
                                    if (str2.EqualsIgnoreCase("B"))
                                    {
                                        entity2.DataEntity.SetDynamicObjectItemValue("InspectGroupId_Id", tuple.Item1);
                                    }
                                    else if (str2.EqualsIgnoreCase("C"))
                                    {
                                        entity2.DataEntity.SetDynamicObjectItemValue("InspectorId_Id", tuple.Item2);
                                    }
                                    dictionary2.Add(num2, entity2);
                                }
                            }
                        }
                        list2.AddRange(dictionary2.Values);
                        dictionary2.Clear();
                    }
                    DynamicObject[] col = (from s in list2 select s.DataEntity).ToArray <DynamicObject>();
                    if (!col.IsEmpty <DynamicObject>())
                    {
                        Kingdee.K3.MFG.App.AppServiceContext.DBService.LoadReferenceObject(base.Context, col, col.FirstOrDefault <DynamicObject>().DynamicObjectType, true);
                        for (int i = 0; i < entityArray2.Length; i++)
                        {
                            e.Result.RemoveExtendedDataEntity("FBillHead", 0);//原来e.Result.RemoveExtendedDataEntity("FBillHead",i)
                        }
                        e.Result.AddExtendedDataEntities("FBillHead", list2.ToArray());
                    }
                }
            }
        }
Beispiel #14
0
        public static void AddMsg(ValidateContext validateContext, ExtendedDataEntity entity, string displayToFieldKey, string id, string title, string msg, ErrorLevel errorLevel = 2)
        {
            ValidationErrorInfo errorInfo = new ValidationErrorInfo(displayToFieldKey, entity.DataEntity["Id"].ToString(), entity.DataEntityIndex, entity.RowIndex, id, msg, title, errorLevel);

            validateContext.AddError(entity.DataEntity, errorInfo);
        }
Beispiel #15
0
 private BudgetCtrlPlateformMain Convert2Entity(ExtendedDataEntity parm)
 {
     return new BudgetCtrlPlateformMain { DeptOrgId = int.Parse(parm.DataEntity["DEPTORGID_ID"].ToString()), OrgType = parm.DataEntity["ORGTYPE"].ToString(), OrgId = int.Parse((parm.DataEntity["DEPTORGID"] as DynamicObject)["ORGID"].ToString()), DeptOrgName = (parm.DataEntity["DEPTORGID"] as DynamicObject)["OrgName"].ToString(), SchemeId = int.Parse(parm.DataEntity["FSCHEMEID_ID"].ToString()), SchemeNumber = (parm.DataEntity["FSCHEMEID"] as DynamicObject)["Number"].ToString() };
 }