/// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="entity">实体</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>受影响的行数</returns>
        public int Add(UserInfo userInfo, CiItemDetailsEntity entity, out string statusMessage)
        {
            int returnValue = 0;

            statusMessage = string.Empty;

            if (this.GetDTByValues(userInfo, new string[] { CiItemDetailsTable.FieldItemId, CiItemDetailsTable.FieldItemName, CiItemDetailsTable.FieldDeleteMark }, new string[] { entity.ItemId.ToString(), entity.ItemName, "0" }).Rows.Count > 0)
            {
                returnValue   = 0;
                statusMessage = "已存在相同的明细项!";
            }
            else
            {
                using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType))
                {
                    try
                    {
                        dbProvider.Open(RDIFrameworkDbConection);
                        var manager = new CiItemDetailsManager(dbProvider, userInfo);
                        returnValue   = !string.IsNullOrEmpty(manager.AddEntity(entity)) ?1:0;
                        statusMessage = "成功新增数据!";
                    }
                    catch (Exception ex)
                    {
                        CiExceptionManager.LogException(dbProvider, userInfo, ex);
                        throw ex;
                    }
                    finally
                    {
                        dbProvider.Close();
                    }
                }
            }
            return(returnValue);
        }
        /// <summary>
        /// 批次設置刪除标志
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var manager = new CiItemDetailsManager(dbProvider, userInfo);
                returnValue = manager.SetDeleted(ids);
            });
            return(returnValue);
        }
        /// <summary>
        /// 批次保存数据
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="entites">实体列表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(UserInfo userInfo, List <CiItemDetailsEntity> entites)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var manager = new CiItemDetailsManager(dbProvider, userInfo);
                //returnValue = manager.BatchSave(entites);
            });
            return(returnValue);
        }
Esempio n. 4
0
        /// <summary>
        /// 根据数据字典主键得到字典明细数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="itemId">父级主键</param>
        /// <returns>数据表</returns>
        public DataTable GetItemDetailDTByItemId(UserInfo userInfo, string itemId)
        {
            var dataTable = new DataTable(CiItemDetailsTable.TableName);
            var parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var itemsDetailManager = new CiItemDetailsManager(dbProvider, userInfo);
                dataTable           = itemsDetailManager.GetDT(CiItemDetailsTable.FieldItemId, itemId, CiItemDetailsTable.FieldDeleteMark, 0, CiItemDetailsTable.FieldSortCode);
                dataTable.TableName = CiItemDetailsTable.TableName;
            });
            return(dataTable);
        }
        /// <summary>
        /// 依條件獲取数据列表
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="names">字段</param>
        /// <param name="values">值</param>
        /// <returns>数据表</returns>
        public DataTable GetDTByValues(UserInfo userInfo, string[] names, object[] values)
        {
            DataTable dataTable = new DataTable(CiItemDetailsTable.TableName);
            var       parameter = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var manager         = new CiItemDetailsManager(dbProvider, userInfo);
                dataTable           = manager.GetDT(names, values);
                dataTable.TableName = CiItemDetailsTable.TableName;
            });
            return(dataTable);
        }
        /// <summary>
        /// 取得实体
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="id">主鍵</param>
        /// <returns>实体</returns>
        public CiItemDetailsEntity GetEntity(UserInfo userInfo, string id)
        {
            CiItemDetailsEntity entity = null;
            var parameter = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var manager = new CiItemDetailsManager(dbProvider, userInfo);
                entity      = manager.GetEntity(id);
            });

            return(entity);
        }
        /// <summary>
        /// 取得列表
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <returns>数据表</returns>
        public DataTable GetDT(UserInfo userInfo)
        {
            var dataTable = new DataTable(CiItemDetailsTable.TableName);
            var parameter = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var manager         = new CiItemDetailsManager(dbProvider, userInfo);
                dataTable           = manager.GetDT(CiItemDetailsTable.FieldDeleteMark, 0, CiItemDetailsTable.FieldSortCode);
                dataTable.TableName = CiItemDetailsTable.TableName;
            });

            return(dataTable);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="entity">实体</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>影响行数</returns>
        public int Update(UserInfo userInfo, CiItemDetailsEntity entity, out string statusMessage)
        {
            int returnValue = 0;

            statusMessage = string.Empty;

            using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType))
            {
                try
                {
                    dbProvider.Open(RDIFrameworkDbConection);

                    var manager = new CiItemDetailsManager(dbProvider, userInfo);
                    if (manager.IsExisted(entity))
                    {
                        returnValue   = 0;
                        statusMessage = "已存在相同的明细项!";
                    }
                    else
                    {
                        returnValue   = manager.UpdateEntity(entity);
                        statusMessage = "修改数据成功!";
                    }
                }
                catch (Exception ex)
                {
                    CiExceptionManager.LogException(dbProvider, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbProvider.Close();
                }
            }

            return(returnValue);
        }