/// <summary> /// 增加一条数据 /// </summary> public bool Add(VipSoft.Model.MoneyRule model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into MoneyRule("); strSql.Append("ID,Name,OneHour,SecondHour,ThirdHour,ThanTime)"); strSql.Append(" values ("); strSql.Append("@ID,@Name,@OneHour,@SecondHour,@ThirdHour,@ThanTime)"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@OneHour", SqlDbType.Money, 8), new SqlParameter("@SecondHour", SqlDbType.Money, 8), new SqlParameter("@ThirdHour", SqlDbType.Money, 8), new SqlParameter("@ThanTime", SqlDbType.Int, 4) }; parameters[0].Value = model.ID; parameters[1].Value = model.Name; parameters[2].Value = model.OneHour; parameters[3].Value = model.SecondHour; parameters[4].Value = model.ThirdHour; parameters[5].Value = model.ThanTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.MoneyRule DataRowToModel(DataRow row) { VipSoft.Model.MoneyRule model=new VipSoft.Model.MoneyRule(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["Name"]!=null) { model.Name=row["Name"].ToString(); } if(row["OneHour"]!=null && row["OneHour"].ToString()!="") { model.OneHour=decimal.Parse(row["OneHour"].ToString()); } if(row["SecondHour"]!=null && row["SecondHour"].ToString()!="") { model.SecondHour=decimal.Parse(row["SecondHour"].ToString()); } if(row["ThirdHour"]!=null && row["ThirdHour"].ToString()!="") { model.ThirdHour=decimal.Parse(row["ThirdHour"].ToString()); } if(row["ThanTime"]!=null && row["ThanTime"].ToString()!="") { model.ThanTime=int.Parse(row["ThanTime"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.MoneyRule DataRowToModel(DataRow row) { VipSoft.Model.MoneyRule model = new VipSoft.Model.MoneyRule(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["OneHour"] != null && row["OneHour"].ToString() != "") { model.OneHour = decimal.Parse(row["OneHour"].ToString()); } if (row["SecondHour"] != null && row["SecondHour"].ToString() != "") { model.SecondHour = decimal.Parse(row["SecondHour"].ToString()); } if (row["ThirdHour"] != null && row["ThirdHour"].ToString() != "") { model.ThirdHour = decimal.Parse(row["ThirdHour"].ToString()); } if (row["ThanTime"] != null && row["ThanTime"].ToString() != "") { model.ThanTime = int.Parse(row["ThanTime"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(VipSoft.Model.MoneyRule model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update MoneyRule set "); strSql.Append("ID=@ID,"); strSql.Append("Name=@Name,"); strSql.Append("OneHour=@OneHour,"); strSql.Append("SecondHour=@SecondHour,"); strSql.Append("ThirdHour=@ThirdHour,"); strSql.Append("ThanTime=@ThanTime"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@OneHour", SqlDbType.Money, 8), new SqlParameter("@SecondHour", SqlDbType.Money, 8), new SqlParameter("@ThirdHour", SqlDbType.Money, 8), new SqlParameter("@ThanTime", SqlDbType.Int, 4) }; parameters[0].Value = model.ID; parameters[1].Value = model.Name; parameters[2].Value = model.OneHour; parameters[3].Value = model.SecondHour; parameters[4].Value = model.ThirdHour; parameters[5].Value = model.ThanTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.MoneyRule GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,Name,OneHour,SecondHour,ThirdHour,ThanTime from MoneyRule "); strSql.Append(" where "); SqlParameter[] parameters = { }; VipSoft.Model.MoneyRule model = new VipSoft.Model.MoneyRule(); 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.MoneyRule GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,Name,OneHour,SecondHour,ThirdHour,ThanTime from MoneyRule "); strSql.Append(" where "); SqlParameter[] parameters = { }; VipSoft.Model.MoneyRule model=new VipSoft.Model.MoneyRule(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
public VipSoft.Model.MoneyRule GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,Name,OneHourMoney, SecondHourMoney, ThirdHourMoney, ThanTime from MoneyRule "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; VipSoft.Model.MoneyRule model = new VipSoft.Model.MoneyRule(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }