Beispiel #1
0
        public override void OnSetBusinessInfo(SetBusinessInfoArgs e)
        {
            new ExtensionPresenter(this);

            base.OnSetBusinessInfo(e);
            // 创建当前单据元数据副本,避免直接修改原始元数据,并发时串账
            FormMetadata currmetadata = (FormMetadata)ObjectUtils.CreateCopy(
                this.View.OpenParameter.FormMetaData);

            _currBusinessInfo = currmetadata.BusinessInfo;
            _currLayoutInfo   = currmetadata.GetLayoutInfo();

            // 取单据头的元数据模型
            currEntityKey = "FBillHead";
            currEntity    = _currBusinessInfo.GetEntity(currEntityKey);

            // 取配置字段的模板,动态添加的字段,是基于模板字段的一个分身
            modelTextField      = _currBusinessInfo.GetField("FModelText");      //文本模板
            modelDecimalField   = _currBusinessInfo.GetField("FModelDecimal");   //小数模板
            modelF8Field        = _currBusinessInfo.GetField("FModelF8");        //F8模板
            modelAssistantField = _currBusinessInfo.GetField("FModelAssistant"); //辅助资料模板


            var simpleExtension = this.View.OpenParameter.GetCustomParameter("simpleExtension") as DynamicObject;

            presenter.GenerateByJson(simpleExtension["FExtension"] as string);

            _currBusinessInfo.GetDynamicObjectType(true);
            e.BusinessInfo     = _currBusinessInfo;
            e.BillBusinessInfo = _currBusinessInfo;
        }
Beispiel #2
0
        }//end static method

        public static Context CreateInstanceFromCache(this Context ctx, string dataCenterId, long userId)
        {
            Context contextByDataCenterId = DataCenterService.GetDataCenterContextFromCache(dataCenterId);

            //处理用户登录名
            {
                FormMetadata metadata     = FormMetaDataCache.GetCachedFormMetaData(contextByDataCenterId, FormIdConst.SEC_User);
                BusinessInfo businessInfo = metadata.BusinessInfo.GetSubBusinessInfo(new List <string> {
                    "FNumber", "FUserAccount", "FName"
                });
                DynamicObject dataObject = BusinessDataServiceHelper.LoadFromCache(contextByDataCenterId, new object[] { userId }, businessInfo.GetDynamicObjectType()).FirstOrDefault();
                contextByDataCenterId.UserId = dataObject.PkId <long>();
                if (businessInfo.GetField("FNumber") != null)
                {
                    contextByDataCenterId.LoginName = dataObject.FieldProperty <string>(businessInfo.GetField("FNumber"));
                }
                if (businessInfo.GetField("FUserAccount") != null)
                {
                    contextByDataCenterId.LoginName = dataObject.FieldProperty <string>(businessInfo.GetField("FUserAccount"));
                }
                contextByDataCenterId.UserName = dataObject.FieldProperty <string>(businessInfo.GetField("FName"));
            }

            return(contextByDataCenterId);
        }//end static method
        /// <summary>
        /// 赋值
        /// </summary>
        /// <param name="businessinfo"></param>
        /// <param name="dataEntity"></param>
        /// <param name="ormFieldKey"></param>
        /// <param name="fieldKey"></param>
        /// <param name="value"></param>
        private void SetRountIdFiled(BusinessInfo businessinfo, DynamicObject dataEntity, string ormFieldKey, string fieldKey, object value)
        {
            DynamicObject orgFieldData = (DynamicObject)dataEntity[ormFieldKey];

            if (orgFieldData == null)
            {
                BaseDataField baseField = businessinfo.GetField(fieldKey) as BaseDataField;
                SetBaseDataFieldValue(this.Context, baseField, dataEntity, value);
            }
        }
Beispiel #4
0
        public override void OnSetLayoutInfo(SetLayoutInfoArgs e)
        {
            base.OnSetLayoutInfo(e);
            // 获取单据体表格的元数据及布局
            string entityKey = "FEntity";
            //Entity entity = _currBusinessInfo.GetEntity(entityKey);
            EntityAppearance entityApp = _currLayoutInfo.GetEntityAppearance(entityKey);
            Entity           entity    = entityApp.Entity;
            var textApp    = _currLayoutInfo.GetFieldAppearance("FField");
            var decimalApp = _currLayoutInfo.GetFieldAppearance("FDecimal");

            for (int i = 0; i < entityData.Columns.Count; i++)
            {
                string name = "FField_" + (i + 1).ToString();
                //FieldAppearance field = new FieldAppearance();
                FieldAppearance field;
                if (i == 0)
                {
                    field = (FieldAppearance)ObjectUtils.CreateCopy(textApp);
                }
                else
                {
                    field = (FieldAppearance)ObjectUtils.CreateCopy(decimalApp);
                    //添加合计列
                    GroupSumColumn sumColumn = new GroupSumColumn();
                    sumColumn.FieldKey  = name;
                    sumColumn.Precision = -1;
                    sumColumn.SumType   = 1;
                    entity.GroupColumnInfo.AddGroupSumColumn(sumColumn);
                }
                field.Key      = name;
                field.Caption  = new LocaleValue(entityData.Columns[i].ColumnName);
                field.Field    = _currBusinessInfo.GetField(name);
                field.Tabindex = i + 1;
                _currLayoutInfo.Add(field);
            }

            _currLayoutInfo.Remove(textApp);
            _currLayoutInfo.Remove(decimalApp);

            entityApp.Layoutinfo.Sort();
            e.LayoutInfo = _currLayoutInfo;

            EntryGrid grid = this.View.GetControl <EntryGrid>("FEntity");

            grid.SetCustomPropertyValue("AllowLayoutSetting", false);
            grid.CreateDyanmicList(_currLayoutInfo.GetEntityAppearance("FEntity"));
            this.View.SendDynamicFormAction(this.View);
        }
Beispiel #5
0
        }//end method

        /// <summary>
        /// 标记状态。
        /// </summary>
        /// <param name="ctx">上下文对象。</param>]
        /// <param name="businessInfo">业务对象。</param>
        /// <param name="dataEntities">数据包。</param>
        /// <param name="statusValue">状态值。</param>
        /// <param name="fieldKey">状态字段。</param>
        public void MarkGenStatus(Context ctx, BusinessInfo businessInfo, DynamicObject[] dataEntities, string statusValue, string fieldKey = "FPHMXGenTargetStatus")
        {
            //标记生成状态。
            var statusField = businessInfo.GetField(fieldKey);

            foreach (var data in dataEntities)
            {
                statusField.DynamicProperty.SetValue(data, statusValue);
            }
            if (dataEntities.Any())
            {
                var saveService = ServiceHelper.GetService <ISaveService>();
                saveService.Save(ctx, dataEntities);
            } //end if
        }
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            if (e.Key.EqualsIgnoreCase("F_JD_BTNOK"))
            {
                this.View.GetControl("F_JD_BTNOK").Enabled = false;

                if (FileNameList.Count < 1)
                {
                    this.View.ShowMessage("未检测到需要引入的txt文件!", MessageBoxType.Error);
                }
                else
                {
                    string result = "";
                    for (int f = 0; f < FileNameList.Count; f++)
                    {
                        result += "\r\n《" + _FileList[f] + "》结果:";
                        try
                        {
                            string        CustomKey = this.View.OpenParameter.GetCustomParameter("CustomKey").ToString();//获取父级页面传参的参数
                            List <object> analysis  = new List <object> {
                            };
                            if (CustomKey == "2001")
                            {
                                analysis = GetAnalysisTxt(FileNameList[f]);
                            }
                            else
                            {
                                analysis = GetAnalysisTxt2(FileNameList[f]);
                            }

                            string sql_3 = @"select tt.FID,t1.FENTRYID,t2.FMATERIALID,t2.FNUMBER from t_STK_InStock tt
                            left outer join T_STK_INSTOCKENTRY t1 on tt.FID=t1.FID
                            left outer join T_BD_MATERIAL t2 on t1.FMATERIALID=t2.FMATERIALID
                            where tt.FCancelStatus='A' and tt.FDocumentStatus in('A','B') and tt.F_PAEZ_Text='" + analysis[0].ToString() + "'";


                            DataSet   ds_3    = DBServiceHelper.ExecuteDataSet(this.Context, sql_3);
                            DataTable dt_head = ds_3.Tables[0]; dt_head.PrimaryKey = new DataColumn[] { dt_head.Columns["FENTRYID"] };
                            if (dt_head.Rows.Count < 1)
                            {
                                result += "\r\n 不存在Invoice No:“" + analysis[0].ToString() + "”的单据或已提交或已审核,无法更新单价。\r\n________________________________________________________________________\r\n";
                                continue;
                            }
                            long      BillID   = Convert.ToInt64(dt_head.Rows[0]["FID"]);
                            DataTable dt_entry = (DataTable)analysis[1];

                            #region 修改单据数据

                            FormMetadata  meta        = MetaDataServiceHelper.Load(this.Context, "STK_InStock") as FormMetadata;
                            BusinessInfo  info        = meta.BusinessInfo;
                            DynamicObject toModifyObj = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.LoadSingle(this.Context, BillID, info.GetDynamicObjectType());

                            if (toModifyObj != null)
                            {
                                decimal FEXCHANGERATE = 1;
                                DynamicObjectCollection InStockFin = toModifyObj["InStockFin"] as DynamicObjectCollection;
                                foreach (DynamicObject StockFin in InStockFin)
                                {
                                    FEXCHANGERATE = Convert.ToDecimal(info.GetField("FEXCHANGERATE").DynamicProperty.GetValue(StockFin));//汇率
                                }

                                DynamicObjectCollection entryObjs = toModifyObj["InStockEntry"] as DynamicObjectCollection;
                                string  FNUMBER = string.Empty;
                                decimal FTaxPrice = 0; decimal FTAXRATE = 0; decimal FPRICEUNITQTY = 0;
                                string  err_row = "";
                                foreach (DynamicObject entryObj in entryObjs)
                                {
                                    int FENTRYID = Convert.ToInt32(entryObj["Id"]);
                                    FTAXRATE      = Convert.ToDecimal(info.GetField("FTAXRATE").DynamicProperty.GetValue(entryObj)) / 100;
                                    FPRICEUNITQTY = Convert.ToDecimal(info.GetField("FPRICEUNITQTY").DynamicProperty.GetValue(entryObj));
                                    DataRow dr = dt_head.Rows.Find(FENTRYID);
                                    if (dr != null)
                                    {
                                        FNUMBER = dr["FNUMBER"].ToString();
                                        DataRow[] dr_r = dt_entry.Select("FPartID='" + FNUMBER + "'");
                                        if (dr_r.Length > 0)
                                        {
                                            FTaxPrice = Convert.ToDecimal(dr_r[0]["FUnitPrice"]);
                                            decimal FPRICE     = Math.Round((FTaxPrice / (1 + FTAXRATE)), 6, MidpointRounding.AwayFromZero);
                                            decimal FALLAMOUNT = Math.Round((FTaxPrice * FPRICEUNITQTY), 2, MidpointRounding.AwayFromZero);
                                            decimal FAMOUNT    = Math.Round((FTaxPrice / (1 + FTAXRATE) * FPRICEUNITQTY), 2, MidpointRounding.AwayFromZero);

                                            info.GetField("FPRICE").DynamicProperty.SetValue(entryObj, FPRICE);
                                            info.GetField("FTaxPrice").DynamicProperty.SetValue(entryObj, FTaxPrice);
                                            info.GetField("FALLAMOUNT").DynamicProperty.SetValue(entryObj, FALLAMOUNT);
                                            info.GetField("FAMOUNT").DynamicProperty.SetValue(entryObj, FAMOUNT);
                                            info.GetField("FTAXAMOUNT").DynamicProperty.SetValue(entryObj, FALLAMOUNT - FAMOUNT);
                                            info.GetField("FTAXNETPRICE").DynamicProperty.SetValue(entryObj, FTaxPrice);

                                            info.GetField("FTAXAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FALLAMOUNT - FAMOUNT) * FEXCHANGERATE, 2, MidpointRounding.AwayFromZero)); //税额(本位币)
                                            info.GetField("FAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FAMOUNT * FEXCHANGERATE), 2, MidpointRounding.AwayFromZero));                 //金额(本位币)FAMOUNT_LC
                                            info.GetField("FALLAMOUNT_LC").DynamicProperty.SetValue(entryObj, Math.Round((FALLAMOUNT * FEXCHANGERATE), 2, MidpointRounding.AwayFromZero));           //含税金额(本位币)FAMOUNT_LC
                                        }
                                        else
                                        {
                                            err_row += "物料【" + FNUMBER + "】未检测到导入的数据。\r\n";
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        err_row += "分录【" + FENTRYID + "】未检测对应物料数据,请检查。\r\n";
                                        continue;
                                    }
                                }
                                if (err_row == "")
                                {
                                    IOperationResult save_result = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Save(this.Context, info, new DynamicObject[] { toModifyObj }, null, "Save");
                                    if (save_result.IsSuccess)
                                    {
                                        Import  = true;
                                        result += "\r\n引入成功!\r\n________________________________________________________________________\r\n";
                                        continue;
                                    }
                                    else
                                    {
                                        for (int mf = 0; mf < save_result.ValidationErrors.Count; mf++)
                                        {
                                            result += "\r\n" + save_result.ValidationErrors[mf].Message;
                                        }
                                        result += "\r\n________________________________________________________________________\r\n";
                                        continue;
                                    }
                                }
                                else
                                {
                                    result += "\r\n" + err_row;
                                    result += "\r\n________________________________________________________________________\r\n";
                                    continue;
                                }
                            }
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            result += "\r\n" + ex.Message.ToString() + "\r\n________________________________________________________________________\r\n";
                            continue;
                        }
                    }

                    this._FileList.Clear();
                    this.FileNameList.Clear();
                    this.View.GetControl("F_JD_FileUpdate").SetValue(DBNull.Value);
                    this.View.Refresh();
                    this.View.ShowMessage("导入完成,以下为具体的引入情况:" + result, MessageBoxType.Advise);
                }
            }
            else if (e.Key.EqualsIgnoreCase("F_JD_BTNCancel"))
            {
                this.View.ReturnToParentWindow(new FormResult(Import));
                this.View.Close();
            }
        }
Beispiel #7
0
        public void GetBudgetDimensionInfo()
        {
            DynamicObjectCollection objects = this.dyRptScheme["DimensionEntity"] as DynamicObjectCollection;

            this.dicDimensionInfo.Clear();
            this.dicDimensionField.Clear();
            int num = 1;

            foreach (DynamicObject obj2 in objects)
            {
                DynamicObject obj3 = obj2["DimensionID"] as DynamicObject;
                if (((obj3 != null) && (Convert.ToString(obj3["BaseDataType_Id"]) != "BM_BUDGETCALENDAR")) && (Convert.ToString(obj3["BaseDataType_Id"]) != "BM_DEPTORG"))
                {
                    string        str    = Convert.ToString(obj3["Category"]);
                    string        formId = Convert.ToString(obj3["BaseDataType_Id"]);
                    int           key    = Convert.ToInt32(obj3["Id"]);
                    DimensionInfo info   = new DimensionInfo {
                        Id              = key,
                        Name            = Convert.ToString(obj3["Name"]),
                        Category        = str,
                        DataControlType = 1
                    };
                    if (str == "10")
                    {
                        formId               = "BOS_ASSISTANTDATA_SELECT";
                        info.PKFieldName     = "FEntryID";
                        info.TableName       = "T_BAS_ASSISTANTDATAENTRY";
                        info.NumberFieldName = "FNUMBER";
                        info.NameFieldName   = "FDATAVALUE";
                        info.NameTableName   = "T_BAS_ASSISTANTDATAENTRY_L";
                    }
                    else
                    {
                        info.FormId = formId;
                        BusinessInfo demensionMetaData = this.GetDemensionMetaData(formId);
                        info.PKFieldName = demensionMetaData.GetForm().PkFieldName;
                        string nameFieldKey = demensionMetaData.GetForm().NameFieldKey;
                        if (!string.IsNullOrWhiteSpace(nameFieldKey))
                        {
                            info.NameFieldName = nameFieldKey;
                            if (demensionMetaData.GetField(nameFieldKey) is MultiLangTextField)
                            {
                                info.NameTableName = demensionMetaData.GetField(nameFieldKey).TableName + "_L";
                            }
                            else
                            {
                                info.NameTableName = demensionMetaData.GetField(nameFieldKey).TableName;
                            }
                        }
                        info.NumberFieldName = demensionMetaData.GetForm().NumberFieldKey;
                        info.TableName       = demensionMetaData.GetField(demensionMetaData.GetForm().NumberFieldKey).TableName;
                        int baseDataType = ServiceHelper.GetService <IOrganizationService>().GetBaseDataType(base.Context, formId);
                        if (baseDataType == 2)
                        {
                            string masterPKFieldName = demensionMetaData.GetForm().MasterPKFieldName;
                            if (!string.IsNullOrWhiteSpace(masterPKFieldName))
                            {
                                info.DataControlType   = baseDataType;
                                info.MasterIDFieldName = masterPKFieldName;
                            }
                        }
                    }
                    if (this.filterParameter.DicDimissionFilter.ContainsKey(key))
                    {
                        info.IsShowField = true;
                        string str5 = string.Format("FDIMENSIONID{0}", num);
                        string str6 = string.Format("FDIMENSIONNAME{0}", num);
                        info.ShowFieldId   = str5;
                        info.ShowFieldName = str6;
                        this.dicDimensionField.Add(str5, str6);
                        num++;
                    }
                    else
                    {
                        info.IsShowField = false;
                    }
                    this.dicDimensionInfo.Add(key, info);
                }
            }
        }
Beispiel #8
0
        public static T FieldProperty <T>(this DynamicObject dataObject, BusinessInfo businessInfo, string keyName)
        {
            string propertyName = businessInfo.GetField(keyName).PropertyName;

            return(Property <T>(dataObject, propertyName));
        }
Beispiel #9
0
        public override void OnSetBusinessInfo(SetBusinessInfoArgs e)
        {
            base.OnSetBusinessInfo(e);

            FormMetadata currmetadata = (FormMetadata)ObjectUtils.CreateCopy(this.View.OpenParameter.FormMetaData);

            _currBusinessInfo = currmetadata.BusinessInfo;
            _currLayoutInfo   = currmetadata.GetLayoutInfo();
            // 获取单据体表格的元数据及布局
            string entityKey = "FEntity";
            Entity entity    = _currBusinessInfo.GetEntity(entityKey);
            //EntityAppearance entityApp = _currLayoutInfo.GetEntityAppearance(entityKey);

            string FSDate = this.View.OpenParameter.GetCustomParameter("FSDate") == null ? "" :
                            this.View.OpenParameter.GetCustomParameter("FSDate").ToString();
            string FEDate = this.View.OpenParameter.GetCustomParameter("FEDate") == null ? "" :
                            this.View.OpenParameter.GetCustomParameter("FEDate").ToString();
            string FOrgId = this.View.OpenParameter.GetCustomParameter("FOrgId") == null ? "0" :
                            this.View.OpenParameter.GetCustomParameter("FOrgId").ToString();
            string FDeptID = this.View.OpenParameter.GetCustomParameter("FDeptID") == null ? "0" :
                             this.View.OpenParameter.GetCustomParameter("FDeptID").ToString();
            string FAccountId = this.View.OpenParameter.GetCustomParameter("FAccountId") == null ? "0" :
                                this.View.OpenParameter.GetCustomParameter("FAccountId").ToString();

            string sql = string.Format(@"EXEC proc_czly_AccountDept @SDt='{0}', @EDt='{1}', 
@FOrgId='{2}', @FDeptId='{3}', @FAccountId='{4}'",
                                       FSDate, FEDate, FOrgId, FDeptID, FAccountId);


            Field textField    = _currBusinessInfo.GetField("FField");
            Field decimalField = _currBusinessInfo.GetField("FDecimal");

            //var textApp = _currLayoutInfo.GetEntityAppearance("FField");

            entityData = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0];

            // 获取生成的费用项目列
            sql = string.Format(@"EXEC proc_czly_AccountOrg @SDt='{0}', @EDt='{1}', 
@FOrgId='{2}', @FDeptId='{3}', @FAccountId='{4}'",
                                FSDate, FEDate, FOrgId, FDeptID, FAccountId);
            costItems = DBUtils.ExecuteDataSet(this.Context, sql).Tables[0];

            for (int i = 0; i < entityData.Columns.Count; i++)
            {
                string name = "FField_" + (i + 1).ToString();
                //Field field = new Field();
                Field field;
                if (i == 0)
                {
                    field = (Field)ObjectUtils.CreateCopy(textField);
                }
                else
                {
                    field = (Field)ObjectUtils.CreateCopy(decimalField);
                    // 增加合计列
                    GroupSumColumn sumColumn = new GroupSumColumn();
                    sumColumn.FieldKey  = name;
                    sumColumn.Precision = -1;
                    sumColumn.SumType   = 1;
                    entity.GroupColumnInfo.AddGroupSumColumn(sumColumn);
                }

                field.DynamicProperty = null;
                //field.ElementType = ElementType.BarItemElementType_TextField;
                field.Entity       = entity;
                field.EntityKey    = entityKey;
                field.Key          = name;
                field.FieldName    = name;
                field.PropertyName = name;
                field.Name         = new LocaleValue(name);
                _currBusinessInfo.Add(field);
            }

            _currBusinessInfo.Remove(textField);
            _currBusinessInfo.Remove(decimalField);
            // 强制要求重新构建单据的ORM模型
            _currBusinessInfo.GetDynamicObjectType(true);

            // 输出动态调整后的单据逻辑元数据模型(BusinessInfo)
            e.BusinessInfo     = _currBusinessInfo;
            e.BillBusinessInfo = _currBusinessInfo;
        }