예제 #1
0
        public ModelInvokeResult <DictionaryItemPK> Update(string strDictionaryId, string strItemId, DictionaryItem dictionaryItem)
        {
            ModelInvokeResult <DictionaryItemPK> result = new ModelInvokeResult <DictionaryItemPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string _DictionaryId = strDictionaryId;
                dictionaryItem.DictionaryId = _DictionaryId;
                string _ItemId = strItemId;
                dictionaryItem.ItemId = _ItemId;
                if (dictionaryItem.ParentId == "_")
                {
                    dictionaryItem.ParentId = null;
                }
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = dictionaryItem.GetUpdateMethodName(), ParameterObject = dictionaryItem.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                });
                /***********************begin 自定义代码*******************/
                var dictionaryItemOld = BuilderFactory.DefaultBulder().Load <DictionaryItem, DictionaryItemPK>(new DictionaryItemPK {
                    DictionaryId = strDictionaryId, ItemId = strItemId
                });
                StringObjectDictionary dictionary = new
                {
                    DictionaryId = dictionaryItem.DictionaryId,
                    ItemId       = dictionaryItem.ItemId,
                    Action       = SqlExecuteType.UPDATE.ToString().ToLower(),
                    OldParentId  = dictionaryItemOld.ParentId
                }.ToStringObjectDictionary();
                dictionary.Add("ErrorCode", null);
                dictionary.Add("ErrorMessage", null);

                statements.Add(new IBatisNetBatchStatement {
                    StatementName = "SP_Sys_AdjustDictionaryItem", ParameterObject = dictionary, Type = SqlExecuteType.UPDATE
                });
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new DictionaryItemPK {
                    DictionaryId = _DictionaryId, ItemId = _ItemId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
예제 #2
0
        public ModelInvokeResult <DictionaryItemPK> Create(DictionaryItem dictionaryItem)
        {
            ModelInvokeResult <DictionaryItemPK> result = new ModelInvokeResult <DictionaryItemPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (dictionaryItem.ItemId == "自动生成")
                {
                    dictionaryItem.ItemId = GlobalManager.getPK2(dictionaryItem.GetMappingTableName(), "ItemId", "UD");//user define
                }
                if (dictionaryItem.ParentId == "_")
                {
                    dictionaryItem.ParentId = null;
                }
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = dictionaryItem.GetCreateMethodName(), ParameterObject = dictionaryItem.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                });
                /***********************begin 自定义代码*******************/
                StringObjectDictionary dictionary = new
                {
                    DictionaryId = dictionaryItem.DictionaryId,
                    ItemId       = dictionaryItem.ItemId,
                    Action       = SqlExecuteType.INSERT.ToString().ToLower(),
                    OldParentId  = System.DBNull.Value
                }.ToStringObjectDictionary();
                dictionary.Add("ErrorCode", null);
                dictionary.Add("ErrorMessage", null);

                statements.Add(new IBatisNetBatchStatement {
                    StatementName = "SP_Sys_AdjustDictionaryItem", ParameterObject = dictionary, Type = SqlExecuteType.UPDATE
                });
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new DictionaryItemPK {
                    DictionaryId = dictionaryItem.DictionaryId, ItemId = dictionaryItem.ItemId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }