/// <summary> /// 更新一条数据 /// </summary> public bool Update(VipSoft.Model.CouponDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CouponDetail set "); strSql.Append("CouponID=@CouponID,"); strSql.Append("CouponNumber=@CouponNumber,"); strSql.Append("State=@State,"); strSql.Append("UsedTime=@UsedTime"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@CouponID", SqlDbType.Int, 4), new SqlParameter("@CouponNumber", SqlDbType.VarChar, 20), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@UsedTime", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.CouponID; parameters[1].Value = model.CouponNumber; parameters[2].Value = model.State; parameters[3].Value = model.UsedTime; parameters[4].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(VipSoft.Model.CouponDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CouponDetail("); strSql.Append("CouponID,CouponNumber,State,UsedTime)"); strSql.Append(" values ("); strSql.Append("@CouponID,@CouponNumber,@State,@UsedTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CouponID", SqlDbType.Int, 4), new SqlParameter("@CouponNumber", SqlDbType.VarChar, 20), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@UsedTime", SqlDbType.DateTime) }; parameters[0].Value = model.CouponID; parameters[1].Value = model.CouponNumber; parameters[2].Value = model.State; parameters[3].Value = model.UsedTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.CouponDetail DataRowToModel(DataRow row) { VipSoft.Model.CouponDetail model = new VipSoft.Model.CouponDetail(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["CouponID"] != null && row["CouponID"].ToString() != "") { model.CouponID = int.Parse(row["CouponID"].ToString()); } if (row["CouponNumber"] != null) { model.CouponNumber = row["CouponNumber"].ToString(); } if (row["State"] != null && row["State"].ToString() != "") { model.State = int.Parse(row["State"].ToString()); } if (row["UsedTime"] != null && row["UsedTime"].ToString() != "") { model.UsedTime = DateTime.Parse(row["UsedTime"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.CouponDetail DataRowToModel(DataRow row) { VipSoft.Model.CouponDetail model=new VipSoft.Model.CouponDetail(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["CouponID"]!=null && row["CouponID"].ToString()!="") { model.CouponID=int.Parse(row["CouponID"].ToString()); } if(row["CouponNumber"]!=null) { model.CouponNumber=row["CouponNumber"].ToString(); } if(row["State"]!=null && row["State"].ToString()!="") { model.State=int.Parse(row["State"].ToString()); } if(row["UsedTime"]!=null && row["UsedTime"].ToString()!="") { model.UsedTime=DateTime.Parse(row["UsedTime"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.CouponDetail GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,CouponID,CouponNumber,State,UsedTime from CouponDetail "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; VipSoft.Model.CouponDetail model = new VipSoft.Model.CouponDetail(); 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.CouponDetail GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,CouponID,CouponNumber,State,UsedTime from CouponDetail "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; VipSoft.Model.CouponDetail model=new VipSoft.Model.CouponDetail(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }