/// <summary> ///根据主键值查找Sys_PersonDeskTopConfig记录 /// </summary> /// <param name="keyId">KeyId</param> /// <returns>Sys_PersonDeskTopConfig</returns> public Sys_PersonDeskTopConfig FindSys_PersonDeskTopConfig(int keyId) { string sql = @"SELECT KeyId, PersonId, ConfigName, ConfigValue, CreateDate, ModifiedDate FROM dbo.Sys_PersonDeskTopConfig WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, keyId); Sys_PersonDeskTopConfig sys_PersonDeskTopConfig = null; using (IDataReader dr = db.ExecuteReader(command)) { if (dr.Read()) { sys_PersonDeskTopConfig = new Sys_PersonDeskTopConfig(); sys_PersonDeskTopConfig.KeyId = (int)dr["KeyId"]; sys_PersonDeskTopConfig.PersonId = (int)dr["PersonId"]; sys_PersonDeskTopConfig.ConfigName = (string)dr["ConfigName"]; sys_PersonDeskTopConfig.ConfigValue = (string)dr["ConfigValue"]; sys_PersonDeskTopConfig.CreateDate = dr["CreateDate"] == DBNull.Value ? null : (DateTime?)dr["CreateDate"]; sys_PersonDeskTopConfig.ModifiedDate = dr["ModifiedDate"] == DBNull.Value ? null : (DateTime?)dr["ModifiedDate"]; } } return(sys_PersonDeskTopConfig); }
/// <summary> /// 保存桌面设置,如果存在就更新不存在就创建 /// </summary> /// <param name="personId">用户ID</param> /// <param name="name">键</param> /// <param name="value">值</param> /// <returns></returns> public String SaveSys_PersonDeskTopConfig(int personId, string name, string value) { string strResult = ""; try { if (this._sys_PersonDeskTopConfigDAO.CheckPersonConfigName(personId, name) == 0) { Sys_PersonDeskTopConfig config = new Sys_PersonDeskTopConfig() { PersonId = personId, ConfigName = name, ConfigValue = value, CreateDate = DateTime.Now, ModifiedDate = DateTime.Now }; this.CreateSys_PersonDeskTopConfig(config); } else { this._sys_PersonDeskTopConfigDAO.UpdateSys_PersonDeskTopConfig(personId, name, value); } } catch (Exception ex) { strResult = ex.Message; } return(strResult); }
/// <summary> /// 更新Sys_PersonDeskTopConfig记录 /// </summary> /// <param name="sys_PersonDeskTopConfig">Sys_PersonDeskTopConfig对象</param> /// <returns>受影响的记录数</returns> public int UpdateSys_PersonDeskTopConfig(Sys_PersonDeskTopConfig sys_PersonDeskTopConfig) { string sql = @"UPDATE dbo.Sys_PersonDeskTopConfig SET PersonId = @PersonId, ConfigName = @ConfigName, ConfigValue = @ConfigValue, CreateDate = @CreateDate, ModifiedDate = @ModifiedDate WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, sys_PersonDeskTopConfig.KeyId); db.AddInParameter(command, "PersonId", DbType.Int32, sys_PersonDeskTopConfig.PersonId); db.AddInParameter(command, "ConfigName", DbType.String, sys_PersonDeskTopConfig.ConfigName); db.AddInParameter(command, "ConfigValue", DbType.String, sys_PersonDeskTopConfig.ConfigValue); db.AddInParameter(command, "CreateDate", DbType.DateTime, sys_PersonDeskTopConfig.CreateDate.HasValue ? (object)sys_PersonDeskTopConfig.CreateDate : DBNull.Value); db.AddInParameter(command, "ModifiedDate", DbType.DateTime, sys_PersonDeskTopConfig.ModifiedDate.HasValue ? (object)sys_PersonDeskTopConfig.ModifiedDate : DBNull.Value); return(db.ExecuteNonQuery(command)); }
/// <summary> /// 返回满足查询条件的Sys_PersonDeskTopConfig实体列表 /// </summary> /// <param name="param">查询条件</param> /// <returns>Sys_PersonDeskTopConfig实体列表</returns> public IList <Sys_PersonDeskTopConfig> GetSys_PersonDeskTopConfigs(QueryParameter param) { string sql = @"SELECT KeyId, PersonId, ConfigName, ConfigValue, CreateDate, ModifiedDate FROM dbo.Sys_PersonDeskTopConfig"; 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_PersonDeskTopConfig> list = new List <Sys_PersonDeskTopConfig>(); using (IDataReader dr = db.ExecuteReader(command)) { while (dr.Read()) { Sys_PersonDeskTopConfig sys_PersonDeskTopConfig = new Sys_PersonDeskTopConfig(); sys_PersonDeskTopConfig.KeyId = (int)dr["KeyId"]; sys_PersonDeskTopConfig.PersonId = (int)dr["PersonId"]; sys_PersonDeskTopConfig.ConfigName = (string)dr["ConfigName"]; sys_PersonDeskTopConfig.ConfigValue = (string)dr["ConfigValue"]; sys_PersonDeskTopConfig.CreateDate = dr["CreateDate"] == DBNull.Value ? null : (DateTime?)dr["CreateDate"]; sys_PersonDeskTopConfig.ModifiedDate = dr["ModifiedDate"] == DBNull.Value ? null : (DateTime?)dr["ModifiedDate"]; list.Add(sys_PersonDeskTopConfig); } } return(list); }
/// <summary> /// 更新Sys_PersonDeskTopConfig /// </summary> /// <param name="sys_PersonDeskTopConfig">实体类</param> /// <param name="logEntity">日志类</param> /// <returns></returns> public string UpdateSys_PersonDeskTopConfig(Sys_PersonDeskTopConfig sys_PersonDeskTopConfig, Log_Operate logEntity) { string strResult = ""; using (TransactionScope trans = new TransactionScope()) { try { this._sys_PersonDeskTopConfigDAO.UpdateSys_PersonDeskTopConfig(sys_PersonDeskTopConfig); Log_OperateFacade logFacade = new Log_OperateFacade(); int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(strResult); }
/// <summary> /// 创建Sys_PersonDeskTopConfig /// </summary> /// <param name="sys_PersonDeskTopConfig">实体类</param> /// <param name="logEntity">日志类</param> /// <param name="strResult">错误信息</param> /// <returns></returns> public int InsertSys_PersonDeskTopConfig(Sys_PersonDeskTopConfig sys_PersonDeskTopConfig, Log_Operate logEntity, ref string strResult) { int intResult = 0; using (TransactionScope trans = new TransactionScope()) { try { this._sys_PersonDeskTopConfigDAO.InsertSys_PersonDeskTopConfig(sys_PersonDeskTopConfig); Log_OperateFacade logFacade = new Log_OperateFacade(); logEntity.OperateFunction = "新增_sys_PersonDeskTopConfig表ID为" + intResult.ToString() + "的数据"; int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(intResult); }
/// <summary> /// 插入Sys_PersonDeskTopConfig记录 /// </summary> /// <param name="sys_PersonDeskTopConfig">Sys_PersonDeskTopConfig对象</param> /// <returns></returns> public int InsertSys_PersonDeskTopConfig(Sys_PersonDeskTopConfig sys_PersonDeskTopConfig) { string sql = @"INSERT INTO dbo.Sys_PersonDeskTopConfig(PersonId, ConfigName, ConfigValue, CreateDate, ModifiedDate) VALUES(@PersonId, @ConfigName, @ConfigValue, @CreateDate, @ModifiedDate); 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, "PersonId", DbType.Int32, sys_PersonDeskTopConfig.PersonId); db.AddInParameter(command, "ConfigName", DbType.String, sys_PersonDeskTopConfig.ConfigName); db.AddInParameter(command, "ConfigValue", DbType.String, sys_PersonDeskTopConfig.ConfigValue); db.AddInParameter(command, "CreateDate", DbType.DateTime, sys_PersonDeskTopConfig.CreateDate.HasValue ? (object)sys_PersonDeskTopConfig.CreateDate : DBNull.Value); db.AddInParameter(command, "ModifiedDate", DbType.DateTime, sys_PersonDeskTopConfig.ModifiedDate.HasValue ? (object)sys_PersonDeskTopConfig.ModifiedDate : DBNull.Value); int affectedRecords = db.ExecuteNonQuery(command); if (affectedRecords < 1) { throw new ApplicationException("插入数据失败, 没有记录被插入"); } return(affectedRecords); }
/// <summary> /// 更新Sys_PersonDeskTopConfig记录 /// </summary> /// <param name="sys_PersonDeskTopConfig"> /// Sys_PersonDeskTopConfig对象</param> /// <returns>受影响的记录数</returns> public int UpdateSys_PersonDeskTopConfig(Sys_PersonDeskTopConfig sys_PersonDeskTopConfig) { return(this._sys_PersonDeskTopConfigDAO.UpdateSys_PersonDeskTopConfig(sys_PersonDeskTopConfig)); }
/// <summary> /// 创建Sys_PersonDeskTopConfig记录 /// </summary> /// <param name="sys_PersonDeskTopConfig"> /// Sys_PersonDeskTopConfig对象</param> /// <returns></returns> public int CreateSys_PersonDeskTopConfig(Sys_PersonDeskTopConfig sys_PersonDeskTopConfig) { return(this._sys_PersonDeskTopConfigDAO.InsertSys_PersonDeskTopConfig(sys_PersonDeskTopConfig)); }