コード例 #1
0
ファイル: Field.aspx.cs プロジェクト: mkbiltek2019/ERP_6.0
        //添加属性
        protected void FieldGrid_InsertCommand(object sender, GridCommandEventArgs e)
        {
            var       editedItem = (GridEditableItem)e.Item;
            var       fieldId    = Guid.NewGuid();
            Guid      parentfieldId;
            string    fieldName;
            string    fieldValue;
            FieldInfo fieldInfo;

            switch (editedItem.OwnerTableView.DataMember)
            {
            case "TopField":
            {
                parentfieldId = Guid.Empty;
                fieldName     = ((TextBox)editedItem.FindControl("TB_FieldName")).Text;
                fieldValue    = ((TextBox)editedItem.FindControl("TB_FieldValue")).Text;

                try
                {
                    fieldInfo = new FieldInfo
                    {
                        FieldId       = fieldId,
                        ParentFieldId = parentfieldId,
                        FieldName     = fieldName,
                        FieldValue    = fieldValue
                    };

                    string errorMessage;
                    var    result = _goodsFieldSao.AddField(fieldInfo, out errorMessage);
                    if (result)
                    {
                        //商品属性添加操作记录添加
                        var personnelInfo = CurrentSession.Personnel.Get();
                        WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, fieldId, "",
                                                   OperationPoint.GoodsAttributeManager.Add.GetBusinessInfo(), string.Empty);
                        //WebControl.AddCommodityAttributeOperation(HRS.Enum.OperationTypePoint.OperationLogTypeEnum.CommodityAttribute, CurrentSession.Personnel.Get().PersonnelId, fieldId, fieldName + fieldValue, HRS.Enum.OperationTypePoint.CommodityAttributeState.AddAttribute, string.Empty);
                        FieldGrid.Rebind();
                    }
                    else
                    {
                        RAM.Alert("操作无效!" + errorMessage);
                    }
                }
                catch
                {
                    RAM.Alert("商品属性信息添加失败!");
                }
            }
            break;

            case "CombField":
            {
                GridDataItem parentItem = editedItem.OwnerTableView.ParentItem;
                parentfieldId = new Guid(parentItem.GetDataKeyValue("FieldId").ToString());
                fieldName     = ((Label)parentItem.FindControl("LB_FieldName")).Text;
                fieldValue    = ((TextBox)editedItem.FindControl("TB_FieldValue")).Text;
                try
                {
                    fieldInfo = new FieldInfo
                    {
                        FieldId       = fieldId,
                        ParentFieldId = parentfieldId,
                        FieldName     = fieldName,
                        FieldValue    = fieldValue
                    };

                    string errorMessage;
                    var    result = _goodsFieldSao.AddField(fieldInfo, out errorMessage);
                    if (result)
                    {
                        //商品属性添加操作记录添加
                        var personnelInfo = CurrentSession.Personnel.Get();
                        WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, fieldId, "",
                                                   OperationPoint.GoodsAttributeManager.Add.GetBusinessInfo(), string.Empty);
                        //WebControl.AddCommodityAttributeOperation(HRS.Enum.OperationTypePoint.OperationLogTypeEnum.CommodityAttribute, CurrentSession.Personnel.Get().PersonnelId, fieldId, fieldName + fieldValue, HRS.Enum.OperationTypePoint.CommodityAttributeState.AddAttribute, string.Empty);
                        editedItem.OwnerTableView.Rebind();
                    }
                    else
                    {
                        RAM.Alert("操作无效!" + errorMessage);
                    }
                }
                catch
                {
                    RAM.Alert("商品属性信息添加失败!");
                }
            }
            break;
            }
        }