示例#1
0
        public InvokeResult DeleteSelected(string strDictionaryId, string strItemIds)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string[] arrItemIds = strItemIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrItemIds.Length == 0)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                string statementName = new DictionaryItem().GetUpdateMethodName(); //改删除为作废
                foreach (string strItemId in arrItemIds)
                {
                    DictionaryItemPK pk = new DictionaryItemPK {
                        DictionaryId = strDictionaryId, ItemId = strItemId
                    };
                    DeleteCascade(statements, pk);
                    //改删除为作废
                    //statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE });
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = statementName, ParameterObject = new DictionaryItem {
                            DictionaryId = pk.DictionaryId, ItemId = pk.ItemId, Status = 0
                        }.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });

                    /***********************begin 自定义代码*******************/
                    var dictionaryItem = BuilderFactory.DefaultBulder().Load <DictionaryItem, DictionaryItemPK>(pk);
                    StringObjectDictionary dictionary = new
                    {
                        DictionaryId = pk.DictionaryId,
                        ItemId       = pk.ItemId,
                        Action       = SqlExecuteType.DELETE.ToString().ToLower(),
                        OldParentId  = dictionaryItem.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);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
示例#2
0
        public InvokeResult DeleteSelected2(string strDictionaryIdItemIds)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string[] arrDictionaryIdItemIds           = strDictionaryIdItemIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrDictionaryIdItemIds.Length == 0)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                string statementName = new DictionaryItem().GetDeleteMethodName();
                foreach (string strDictionaryIdItemId in arrDictionaryIdItemIds)
                {
                    string[]         arrDictionaryIdItemId = strDictionaryIdItemId.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    DictionaryItemPK pk = new DictionaryItemPK {
                        DictionaryId = arrDictionaryIdItemId[0], ItemId = arrDictionaryIdItemId[1]
                    };
                    DeleteCascade(statements, pk);
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE
                    });
                }
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
示例#3
0
 private void DeleteCascade(List <IBatisNetBatchStatement> statements, DictionaryItemPK pk)
 {
     //此处增加级联删除代码
 }