/// <summary> /// 更新一条数据 /// </summary> public bool Update(VipSoft.Model.SysParameter model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SysParameter set "); strSql.Append("KeyName=@KeyName,"); strSql.Append("Title=@Title,"); strSql.Append("Type=@Type,"); strSql.Append("MaxLength=@MaxLength,"); strSql.Append("GroupTitle=@GroupTitle,"); strSql.Append("Value=@Value,"); strSql.Append("Description=@Description"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@KeyName", SqlDbType.VarChar, 255), new SqlParameter("@Title", SqlDbType.VarChar, 255), new SqlParameter("@Type", SqlDbType.Int, 4), new SqlParameter("@MaxLength", SqlDbType.Int, 4), new SqlParameter("@GroupTitle", SqlDbType.VarChar, 50), new SqlParameter("@Value", SqlDbType.VarChar, 50), new SqlParameter("@Description", SqlDbType.VarChar, 255), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.KeyName; parameters[1].Value = model.Title; parameters[2].Value = model.Type; parameters[3].Value = model.MaxLength; parameters[4].Value = model.GroupTitle; parameters[5].Value = model.Value; parameters[6].Value = model.Description; parameters[7].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.SysParameter DataRowToModel(DataRow row) { VipSoft.Model.SysParameter model=new VipSoft.Model.SysParameter(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["KeyName"]!=null) { model.KeyName=row["KeyName"].ToString(); } if(row["Title"]!=null) { model.Title=row["Title"].ToString(); } if(row["Type"]!=null && row["Type"].ToString()!="") { model.Type=int.Parse(row["Type"].ToString()); } if(row["MaxLength"]!=null && row["MaxLength"].ToString()!="") { model.MaxLength=int.Parse(row["MaxLength"].ToString()); } if(row["GroupTitle"]!=null) { model.GroupTitle=row["GroupTitle"].ToString(); } if(row["Value"]!=null) { model.Value=row["Value"].ToString(); } if(row["Description"]!=null) { model.Description=row["Description"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.SysParameter DataRowToModel(DataRow row) { VipSoft.Model.SysParameter model = new VipSoft.Model.SysParameter(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["KeyName"] != null) { model.KeyName = row["KeyName"].ToString(); } if (row["Title"] != null) { model.Title = row["Title"].ToString(); } if (row["Type"] != null && row["Type"].ToString() != "") { model.Type = int.Parse(row["Type"].ToString()); } if (row["MaxLength"] != null && row["MaxLength"].ToString() != "") { model.MaxLength = int.Parse(row["MaxLength"].ToString()); } if (row["GroupTitle"] != null) { model.GroupTitle = row["GroupTitle"].ToString(); } if (row["Value"] != null) { model.Value = row["Value"].ToString(); } if (row["Description"] != null) { model.Description = row["Description"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(VipSoft.Model.SysParameter model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SysParameter("); strSql.Append("ID,KeyName,Title,Type,MaxLength,GroupTitle,Value,Description)"); strSql.Append(" values ("); strSql.Append("@ID,@KeyName,@Title,@Type,@MaxLength,@GroupTitle,@Value,@Description)"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@KeyName", SqlDbType.VarChar, 255), new SqlParameter("@Title", SqlDbType.VarChar, 255), new SqlParameter("@Type", SqlDbType.Int, 4), new SqlParameter("@MaxLength", SqlDbType.Int, 4), new SqlParameter("@GroupTitle", SqlDbType.VarChar, 50), new SqlParameter("@Value", SqlDbType.VarChar, 50), new SqlParameter("@Description", SqlDbType.VarChar, 255) }; parameters[0].Value = model.ID; parameters[1].Value = model.KeyName; parameters[2].Value = model.Title; parameters[3].Value = model.Type; parameters[4].Value = model.MaxLength; parameters[5].Value = model.GroupTitle; parameters[6].Value = model.Value; parameters[7].Value = model.Description; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.SysParameter GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,KeyName,Title,Type,MaxLength,GroupTitle,Value,Description from SysParameter "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; VipSoft.Model.SysParameter model = new VipSoft.Model.SysParameter(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.SysParameter GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,KeyName,Title,Type,MaxLength,GroupTitle,Value,Description from SysParameter "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; VipSoft.Model.SysParameter model=new VipSoft.Model.SysParameter(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }