public override void AfterConvert(Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e)
        {
            base.AfterConvert(e);
            //设置采购部门
            this.info = e.TargetBusinessInfo;
            Kingdee.K3.SCM.Contracts.ICommonService commonService = Kingdee.K3.SCM.Contracts.ServiceFactory.GetCommonService(base.Context);
            ExtendedDataEntity[] entityArray = e.Result.FindByEntityKey("FBillHead");
            BaseDataField        Deptfield   = this.info.GetField("FPurchaseDeptId") as BaseDataField;

            if ((entityArray != null) && (entityArray.Length > 0))
            {
                foreach (ExtendedDataEntity entity in entityArray)
                {
                    DynamicObject dataEntity = entity.DataEntity;
                    long          num        = Convert.ToInt64(dataEntity["PurchaseDeptId_id"]);
                    long          orgId      = Convert.ToInt64(dataEntity["PurchaseOrgId_id"]);
                    if (num <= 0L)
                    {
                        long num3 = commonService.GetUserOperatorId(base.Context, base.Context.UserId, orgId, "CGY");
                        long num4 = commonService.GetMyDepartment(base.Context, base.Context.UserId).FirstOrDefault <long>();
                        FieldUtils.SetBaseDataFieldValue(base.Context, Deptfield, dataEntity, num4);
                    }
                }
            }
        }
示例#2
0
        private void SetRelativeCodeByMaterialId(AfterFieldMappingEventArgs e)
        {
            ExtendedDataEntity[] entityArray  = e.TargetExtendDataEntitySet.FindByEntityKey("FSaleOrderEntry");
            ExtendedDataEntity[] entityArray2 = e.TargetExtendDataEntitySet.FindByEntityKey("FBillHead");
            Kingdee.K3.SCM.Contracts.ICommonService service = Kingdee.K3.SCM.App.ServiceHelper.GetService <ICommonService>();
            Dictionary <long, bool> dictionary = new Dictionary <long, bool>();

            foreach (ExtendedDataEntity entity in entityArray)
            {
                if (!entity.DataEntity["MapId_Id"].IsNullOrEmptyOrWhiteSpace())
                {
                    continue;
                }
                bool flag = false;
                long key  = Convert.ToInt64(entityArray2[entity.DataEntityIndex].DataEntity["SaleOrgId_Id"]);
                long num2 = Convert.ToInt64(entityArray2[entity.DataEntityIndex].DataEntity["CustId_Id"]);
                long num3 = Convert.ToInt64(entity.DataEntity["MaterialId_Id"]);
                if (!dictionary.ContainsKey(key))
                {
                    object obj2 = service.GetSystemProfile(base.Context, key, "SAL_SystemParameter", "UseCustMatMapping", false);
                    flag = (obj2 != null) && Convert.ToBoolean(obj2);
                    dictionary.Add(key, flag);
                }
                if (dictionary[key])
                {
                    List <CustomerMaterialResult> list = service.GetRelativeCodeByMaterial(base.Context, num3, num2, key);
                    if (list.Count > 0)
                    {
                        string str = "";
                        foreach (CustomerMaterialResult result in list)
                        {
                            if (result.FCustId > 0)
                            {
                                str = result.Fid;
                                break;
                            }
                        }
                        if (str.IsNullOrEmptyOrWhiteSpace())
                        {
                            str = list[0].Fid;
                        }
                        BaseDataField field = e.TargetBusinessInfo.GetField("FMapId") as BaseDataField;
                        FieldUtils.SetBaseDataFieldValue(base.Context, field, entity.DataEntity, str);
                    }
                }
            }
        }