/// <summary> /// 插入业务单位类型,该表不做显示维护记录 /// </summary> /// <param name="sys_BusiUnitType">业务单位类型,该表不做显示维护对象</param> /// <returns></returns> public int InsertSys_BusiUnitType(Sys_BusiUnitType sys_BusiUnitType) { string sql = @"INSERT INTO dbo.Sys_BusiUnitType(BusiUnitTypeCode, BusiUnitTypeName, BusiUnitTypeShortName, ParentID, Status, DisplayOrder, Remark, CreatedBy) VALUES(@BusiUnitTypeCode, @BusiUnitTypeName, @BusiUnitTypeShortName, @ParentID, @Status, @DisplayOrder, @Remark, @CreatedBy); SELECT @KeyId = SCOPE_IDENTITY()"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddOutParameter(command, "KeyId", DbType.Int32, sizeof(int)); db.AddInParameter(command, "BusiUnitTypeCode", DbType.String, string.IsNullOrEmpty(sys_BusiUnitType.BusiUnitTypeCode) ? DBNull.Value : (object)sys_BusiUnitType.BusiUnitTypeCode); db.AddInParameter(command, "BusiUnitTypeName", DbType.String, sys_BusiUnitType.BusiUnitTypeName); db.AddInParameter(command, "BusiUnitTypeShortName", DbType.String, string.IsNullOrEmpty(sys_BusiUnitType.BusiUnitTypeShortName) ? DBNull.Value : (object)sys_BusiUnitType.BusiUnitTypeShortName); db.AddInParameter(command, "ParentID", DbType.Int32, sys_BusiUnitType.ParentID.HasValue ? (object)sys_BusiUnitType.ParentID : DBNull.Value); db.AddInParameter(command, "Status", DbType.Boolean, sys_BusiUnitType.Status); db.AddInParameter(command, "DisplayOrder", DbType.Int32, sys_BusiUnitType.DisplayOrder); db.AddInParameter(command, "Remark", DbType.String, string.IsNullOrEmpty(sys_BusiUnitType.Remark) ? DBNull.Value : (object)sys_BusiUnitType.Remark); db.AddInParameter(command, "CreatedBy", DbType.Int32, sys_BusiUnitType.CreatedBy); int affectedRecords = db.ExecuteNonQuery(command); if (affectedRecords < 1) { throw new ApplicationException("插入数据失败, 没有记录被插入"); } else { string strTemp = "select @@identity"; DataTable dt = GetDataTable(strTemp); if (dt != null && dt.Rows.Count > 0) { affectedRecords = int.Parse(dt.Rows[0][0].ToString()); } } return(affectedRecords); }
/// <summary> ///根据主键值查找业务单位类型,该表不做显示维护记录 /// </summary> /// <param name="keyId">业务单位类型内码</param> /// <returns>Sys_BusiUnitType</returns> public Sys_BusiUnitType FindSys_BusiUnitType(int keyId) { string sql = @"SELECT KeyId, BusiUnitTypeCode, BusiUnitTypeName, BusiUnitTypeShortName, ParentID, Status, DisplayOrder, Remark, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn FROM dbo.Sys_BusiUnitType WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, keyId); Sys_BusiUnitType sys_BusiUnitType = null; using (IDataReader dr = db.ExecuteReader(command)) { if (dr.Read()) { sys_BusiUnitType = new Sys_BusiUnitType(); sys_BusiUnitType.KeyId = (int)dr["KeyId"]; sys_BusiUnitType.BusiUnitTypeCode = dr["BusiUnitTypeCode"] == DBNull.Value ? null : (string)dr["BusiUnitTypeCode"]; sys_BusiUnitType.BusiUnitTypeName = (string)dr["BusiUnitTypeName"]; sys_BusiUnitType.BusiUnitTypeShortName = dr["BusiUnitTypeShortName"] == DBNull.Value ? null : (string)dr["BusiUnitTypeShortName"]; sys_BusiUnitType.ParentID = dr["ParentID"] == DBNull.Value ? null : (int?)dr["ParentID"]; sys_BusiUnitType.Status = (bool)dr["Status"]; sys_BusiUnitType.DisplayOrder = (int)dr["DisplayOrder"]; sys_BusiUnitType.Remark = dr["Remark"] == DBNull.Value ? null : (string)dr["Remark"]; sys_BusiUnitType.CreatedBy = (int)dr["CreatedBy"]; sys_BusiUnitType.CreatedOn = (DateTime)dr["CreatedOn"]; sys_BusiUnitType.ModifiedBy = dr["ModifiedBy"] == DBNull.Value ? null : (int?)dr["ModifiedBy"]; sys_BusiUnitType.ModifiedOn = dr["ModifiedOn"] == DBNull.Value ? null : (DateTime?)dr["ModifiedOn"]; } } return(sys_BusiUnitType); }
/// <summary> /// 返回满足查询条件的业务单位类型,该表不做显示维护实体列表 /// </summary> /// <param name="param">查询条件</param> /// <returns>业务单位类型,该表不做显示维护实体列表</returns> public IList <Sys_BusiUnitType> GetSys_BusiUnitTypes(QueryParameter param) { string sql = @"SELECT KeyId, BusiUnitTypeCode, BusiUnitTypeName, BusiUnitTypeShortName, ParentID, Status, DisplayOrder, Remark, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn FROM dbo.Sys_BusiUnitType"; if (param != null) { sql = QueryParameter.CompleteSqlString(sql, param); } Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); if (param != null) { //设置参数 foreach (IExpression exp in param.WhereExpressions) { if (exp is SimpleExpression) { SimpleExpression simple = exp as SimpleExpression; db.AddInParameter(command, simple.ExpName, simple.DbType, simple.Value); } } } IList <Sys_BusiUnitType> list = new List <Sys_BusiUnitType>(); using (IDataReader dr = db.ExecuteReader(command)) { while (dr.Read()) { Sys_BusiUnitType sys_BusiUnitType = new Sys_BusiUnitType(); sys_BusiUnitType.KeyId = (int)dr["KeyId"]; sys_BusiUnitType.BusiUnitTypeCode = dr["BusiUnitTypeCode"] == DBNull.Value ? null : (string)dr["BusiUnitTypeCode"]; sys_BusiUnitType.BusiUnitTypeName = (string)dr["BusiUnitTypeName"]; sys_BusiUnitType.BusiUnitTypeShortName = dr["BusiUnitTypeShortName"] == DBNull.Value ? null : (string)dr["BusiUnitTypeShortName"]; sys_BusiUnitType.ParentID = dr["ParentID"] == DBNull.Value ? null : (int?)dr["ParentID"]; sys_BusiUnitType.Status = (bool)dr["Status"]; sys_BusiUnitType.DisplayOrder = (int)dr["DisplayOrder"]; sys_BusiUnitType.Remark = dr["Remark"] == DBNull.Value ? null : (string)dr["Remark"]; sys_BusiUnitType.CreatedBy = (int)dr["CreatedBy"]; sys_BusiUnitType.CreatedOn = (DateTime)dr["CreatedOn"]; sys_BusiUnitType.ModifiedBy = dr["ModifiedBy"] == DBNull.Value ? null : (int?)dr["ModifiedBy"]; sys_BusiUnitType.ModifiedOn = dr["ModifiedOn"] == DBNull.Value ? null : (DateTime?)dr["ModifiedOn"]; list.Add(sys_BusiUnitType); } } return(list); }
/// <summary> /// 更新业务单位类型,该表不做显示维护记录 /// </summary> /// <param name="sys_BusiUnitType">业务单位类型,该表不做显示维护对象</param> /// <returns>受影响的记录数</returns> public int UpdateSys_BusiUnitType(Sys_BusiUnitType sys_BusiUnitType) { string sql = @"UPDATE dbo.Sys_BusiUnitType SET BusiUnitTypeCode = @BusiUnitTypeCode, BusiUnitTypeName = @BusiUnitTypeName, BusiUnitTypeShortName = @BusiUnitTypeShortName, ParentID = @ParentID, Status = @Status, DisplayOrder = @DisplayOrder, Remark = @Remark, ModifiedBy = @ModifiedBy, ModifiedOn = @ModifiedOn WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, sys_BusiUnitType.KeyId); db.AddInParameter(command, "BusiUnitTypeCode", DbType.String, string.IsNullOrEmpty(sys_BusiUnitType.BusiUnitTypeCode) ? DBNull.Value : (object)sys_BusiUnitType.BusiUnitTypeCode); db.AddInParameter(command, "BusiUnitTypeName", DbType.String, sys_BusiUnitType.BusiUnitTypeName); db.AddInParameter(command, "BusiUnitTypeShortName", DbType.String, string.IsNullOrEmpty(sys_BusiUnitType.BusiUnitTypeShortName) ? DBNull.Value : (object)sys_BusiUnitType.BusiUnitTypeShortName); db.AddInParameter(command, "ParentID", DbType.Int32, sys_BusiUnitType.ParentID.HasValue ? (object)sys_BusiUnitType.ParentID : DBNull.Value); db.AddInParameter(command, "Status", DbType.Boolean, sys_BusiUnitType.Status); db.AddInParameter(command, "DisplayOrder", DbType.Int32, sys_BusiUnitType.DisplayOrder); db.AddInParameter(command, "Remark", DbType.String, string.IsNullOrEmpty(sys_BusiUnitType.Remark) ? DBNull.Value : (object)sys_BusiUnitType.Remark); db.AddInParameter(command, "ModifiedBy", DbType.Int32, sys_BusiUnitType.ModifiedBy.HasValue ? (object)sys_BusiUnitType.ModifiedBy : DBNull.Value); db.AddInParameter(command, "ModifiedOn", DbType.DateTime, sys_BusiUnitType.ModifiedOn.HasValue ? (object)sys_BusiUnitType.ModifiedOn : DBNull.Value); return(db.ExecuteNonQuery(command)); }
/// <summary> /// 更新Sys_BusiUnitType /// </summary> /// <param name="sys_BusiUnitType">实体类</param> /// <param name="logEntity">日志类</param> /// <returns></returns> public string UpdateSys_BusiUnitType(Sys_BusiUnitType sys_BusiUnitType, Log_Operate logEntity) { string strResult = ""; using (TransactionScope trans = new TransactionScope()) { try { this._sys_BusiUnitTypeDAO.UpdateSys_BusiUnitType(sys_BusiUnitType); Log_OperateFacade logFacade = new Log_OperateFacade(); int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(strResult); }
/// <summary> /// 创建Sys_BusiUnitType /// </summary> /// <param name="sys_BusiUnitType">实体类</param> /// <param name="logEntity">日志类</param> /// <param name="strResult">错误信息</param> /// <returns></returns> public int InsertSys_BusiUnitType(Sys_BusiUnitType sys_BusiUnitType, Log_Operate logEntity, ref string strResult) { int intResult = 0; using (TransactionScope trans = new TransactionScope()) { try { this._sys_BusiUnitTypeDAO.InsertSys_BusiUnitType(sys_BusiUnitType); Log_OperateFacade logFacade = new Log_OperateFacade(); logEntity.OperateFunction = "新增_sys_BusiUnitType表ID为" + intResult.ToString() + "的数据"; int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(intResult); }
/// <summary> /// 更新业务单位类型,该表不做显示维护记录 /// </summary> /// <param name="sys_BusiUnitType"> /// 业务单位类型,该表不做显示维护对象</param> /// <returns>受影响的记录数</returns> public int UpdateSys_BusiUnitType(Sys_BusiUnitType sys_BusiUnitType) { return(this._sys_BusiUnitTypeDAO.UpdateSys_BusiUnitType(sys_BusiUnitType)); }
/// <summary> /// 创建业务单位类型,该表不做显示维护记录 /// </summary> /// <param name="sys_BusiUnitType"> /// 业务单位类型,该表不做显示维护对象</param> /// <returns></returns> public int CreateSys_BusiUnitType(Sys_BusiUnitType sys_BusiUnitType) { return(this._sys_BusiUnitTypeDAO.InsertSys_BusiUnitType(sys_BusiUnitType)); }