/// <summary> /// 增加一条数据 /// </summary> public int Add(MxWeiXinPF.Model.wx_ucard_store model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_ucard_store("); strSql.Append("wid,storeName,logo,storeCatagory,cardBrief,consumePwd,tel,addr,xPoint,yPoint,createDate,sort_id,isRecommend,hfPic)"); strSql.Append(" values ("); strSql.Append("@wid,@storeName,@logo,@storeCatagory,@cardBrief,@consumePwd,@tel,@addr,@xPoint,@yPoint,@createDate,@sort_id,@isRecommend,@hfPic)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@storeName", SqlDbType.VarChar, 200), new SqlParameter("@logo", SqlDbType.VarChar, 800), new SqlParameter("@storeCatagory", SqlDbType.VarChar, 50), new SqlParameter("@cardBrief", SqlDbType.VarChar, 48), new SqlParameter("@consumePwd", SqlDbType.VarChar, 30), new SqlParameter("@tel", SqlDbType.VarChar, 40), new SqlParameter("@addr", SqlDbType.VarChar, 200), new SqlParameter("@xPoint", SqlDbType.Float, 8), new SqlParameter("@yPoint", SqlDbType.Float, 8), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@isRecommend", SqlDbType.Bit, 1), new SqlParameter("@hfPic", SqlDbType.VarChar, 700) }; parameters[0].Value = model.wid; parameters[1].Value = model.storeName; parameters[2].Value = model.logo; parameters[3].Value = model.storeCatagory; parameters[4].Value = model.cardBrief; parameters[5].Value = model.consumePwd; parameters[6].Value = model.tel; parameters[7].Value = model.addr; parameters[8].Value = model.xPoint; parameters[9].Value = model.yPoint; parameters[10].Value = model.createDate; parameters[11].Value = model.sort_id; parameters[12].Value = model.isRecommend; parameters[13].Value = model.hfPic; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_ucard_store GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,wid,storeName,logo,storeCatagory,cardBrief,consumePwd,tel,addr,xPoint,yPoint,createDate,sort_id,isRecommend,hfPic from wx_ucard_store "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; MxWeiXinPF.Model.wx_ucard_store model = new MxWeiXinPF.Model.wx_ucard_store(); 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 MxWeiXinPF.Model.wx_ucard_store DataRowToModel(DataRow row) { MxWeiXinPF.Model.wx_ucard_store model = new MxWeiXinPF.Model.wx_ucard_store(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["storeName"] != null) { model.storeName = row["storeName"].ToString(); } if (row["logo"] != null) { model.logo = row["logo"].ToString(); } if (row["storeCatagory"] != null) { model.storeCatagory = row["storeCatagory"].ToString(); } if (row["cardBrief"] != null) { model.cardBrief = row["cardBrief"].ToString(); } if (row["consumePwd"] != null) { model.consumePwd = row["consumePwd"].ToString(); } if (row["tel"] != null) { model.tel = row["tel"].ToString(); } if (row["addr"] != null) { model.addr = row["addr"].ToString(); } if (row["xPoint"] != null && row["xPoint"].ToString() != "") { model.xPoint = decimal.Parse(row["xPoint"].ToString()); } if (row["yPoint"] != null && row["yPoint"].ToString() != "") { model.yPoint = decimal.Parse(row["yPoint"].ToString()); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["isRecommend"] != null && row["isRecommend"].ToString() != "") { if ((row["isRecommend"].ToString() == "1") || (row["isRecommend"].ToString().ToLower() == "true")) { model.isRecommend = true; } else { model.isRecommend = false; } } if (row["hfPic"] != null) { model.hfPic = row["hfPic"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MxWeiXinPF.Model.wx_ucard_store model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_ucard_store set "); strSql.Append("wid=@wid,"); strSql.Append("storeName=@storeName,"); strSql.Append("logo=@logo,"); strSql.Append("storeCatagory=@storeCatagory,"); strSql.Append("cardBrief=@cardBrief,"); strSql.Append("consumePwd=@consumePwd,"); strSql.Append("tel=@tel,"); strSql.Append("addr=@addr,"); strSql.Append("xPoint=@xPoint,"); strSql.Append("yPoint=@yPoint,"); strSql.Append("createDate=@createDate,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("isRecommend=@isRecommend,"); strSql.Append("hfPic=@hfPic"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@storeName", SqlDbType.VarChar, 200), new SqlParameter("@logo", SqlDbType.VarChar, 800), new SqlParameter("@storeCatagory", SqlDbType.VarChar, 50), new SqlParameter("@cardBrief", SqlDbType.VarChar, 48), new SqlParameter("@consumePwd", SqlDbType.VarChar, 30), new SqlParameter("@tel", SqlDbType.VarChar, 40), new SqlParameter("@addr", SqlDbType.VarChar, 200), new SqlParameter("@xPoint", SqlDbType.Float, 8), new SqlParameter("@yPoint", SqlDbType.Float, 8), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@isRecommend", SqlDbType.Bit, 1), new SqlParameter("@hfPic", SqlDbType.VarChar, 700), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.storeName; parameters[2].Value = model.logo; parameters[3].Value = model.storeCatagory; parameters[4].Value = model.cardBrief; parameters[5].Value = model.consumePwd; parameters[6].Value = model.tel; parameters[7].Value = model.addr; parameters[8].Value = model.xPoint; parameters[9].Value = model.yPoint; parameters[10].Value = model.createDate; parameters[11].Value = model.sort_id; parameters[12].Value = model.isRecommend; parameters[13].Value = model.hfPic; parameters[14].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_ucard_store DataRowToModel(DataRow row) { MxWeiXinPF.Model.wx_ucard_store model = new MxWeiXinPF.Model.wx_ucard_store(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["storeName"] != null) { model.storeName = row["storeName"].ToString(); } if (row["logo"] != null) { model.logo = row["logo"].ToString(); } if (row["storeCatagory"] != null) { model.storeCatagory = row["storeCatagory"].ToString(); } if (row["cardBrief"] != null) { model.cardBrief = row["cardBrief"].ToString(); } if (row["consumePwd"] != null) { model.consumePwd = row["consumePwd"].ToString(); } if (row["tel"] != null) { model.tel = row["tel"].ToString(); } if (row["addr"] != null) { model.addr = row["addr"].ToString(); } if (row["xPoint"] != null && row["xPoint"].ToString() != "") { model.xPoint = decimal.Parse(row["xPoint"].ToString()); } if (row["yPoint"] != null && row["yPoint"].ToString() != "") { model.yPoint = decimal.Parse(row["yPoint"].ToString()); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["isRecommend"] != null && row["isRecommend"].ToString() != "") { if ((row["isRecommend"].ToString() == "1") || (row["isRecommend"].ToString().ToLower() == "true")) { model.isRecommend = true; } else { model.isRecommend = false; } } if (row["hfPic"] != null) { model.hfPic = row["hfPic"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_ucard_store GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,wid,storeName,logo,storeCatagory,cardBrief,consumePwd,tel,addr,xPoint,yPoint,createDate,sort_id,isRecommend,hfPic from wx_ucard_store "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; MxWeiXinPF.Model.wx_ucard_store model = new MxWeiXinPF.Model.wx_ucard_store(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }