/// <summary> /// 更新一条数据 /// </summary> public bool Update(XCWeiXin.Model.wx_PicStore model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_PicStore set "); strSql.Append("picName=@picName,"); strSql.Append("picUri=@picUri,"); strSql.Append("picTemplates=@picTemplates,"); strSql.Append("picType=@picType,"); strSql.Append("picUsedType=@picUsedType,"); strSql.Append("picValue=@picValue,"); strSql.Append("picCreatePerson=@picCreatePerson,"); strSql.Append("createDate=@createDate"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@picName", SqlDbType.VarChar, 200), new SqlParameter("@picUri", SqlDbType.VarChar, 1000), new SqlParameter("@picTemplates", SqlDbType.VarChar, 300), new SqlParameter("@picType", SqlDbType.Int, 4), new SqlParameter("@picUsedType", SqlDbType.NVarChar, 50), new SqlParameter("@picValue", SqlDbType.VarChar, 300), new SqlParameter("@picCreatePerson", SqlDbType.VarChar, 200), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.picName; parameters[1].Value = model.picUri; parameters[2].Value = model.picTemplates; parameters[3].Value = model.picType; parameters[4].Value = model.picUsedType; parameters[5].Value = model.picValue; parameters[6].Value = model.picCreatePerson; parameters[7].Value = model.createDate; parameters[8].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XCWeiXin.Model.wx_PicStore DataRowToModel(DataRow row) { XCWeiXin.Model.wx_PicStore model = new XCWeiXin.Model.wx_PicStore(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["picName"] != null) { model.picName = row["picName"].ToString(); } if (row["picUri"] != null) { model.picUri = row["picUri"].ToString(); } if (row["picTemplates"] != null) { model.picTemplates = row["picTemplates"].ToString(); } if (row["picType"] != null && row["picType"].ToString() != "") { model.picType = int.Parse(row["picType"].ToString()); } if (row["picUsedType"] != null) { model.picUsedType = row["picUsedType"].ToString(); } if (row["picValue"] != null) { model.picValue = row["picValue"].ToString(); } if (row["picCreatePerson"] != null) { model.picCreatePerson = row["picCreatePerson"].ToString(); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(XCWeiXin.Model.wx_PicStore model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_PicStore("); strSql.Append("picName,picUri,picTemplates,picType,picUsedType,picValue,picCreatePerson,createDate)"); strSql.Append(" values ("); strSql.Append("@picName,@picUri,@picTemplates,@picType,@picUsedType,@picValue,@picCreatePerson,@createDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@picName", SqlDbType.VarChar, 200), new SqlParameter("@picUri", SqlDbType.VarChar, 1000), new SqlParameter("@picTemplates", SqlDbType.VarChar, 300), new SqlParameter("@picType", SqlDbType.Int, 4), new SqlParameter("@picUsedType", SqlDbType.NVarChar, 50), new SqlParameter("@picValue", SqlDbType.VarChar, 300), new SqlParameter("@picCreatePerson", SqlDbType.VarChar, 200), new SqlParameter("@createDate", SqlDbType.DateTime) }; parameters[0].Value = model.picName; parameters[1].Value = model.picUri; parameters[2].Value = model.picTemplates; parameters[3].Value = model.picType; parameters[4].Value = model.picUsedType; parameters[5].Value = model.picValue; parameters[6].Value = model.picCreatePerson; parameters[7].Value = model.createDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void BindPic(string templates) { if (templates == "0") { litPicStr.Text = ""; return; } StringBuilder sb = new StringBuilder(""); IList <XCWeiXin.Model.wx_PicStore> plist = bll.GetModelList("pictemplates='" + templates + "'"); if (plist == null || plist.Count <= 0) { litPicStr.Text = ""; return; } XCWeiXin.Model.wx_PicStore p = new XCWeiXin.Model.wx_PicStore(); for (int i = 0; i < plist.Count; i++) { sb.Append("<li>"); p = plist[i]; //if (p.picType == 1) //{ //图片 sb.Append("<label for=\"rad" + p.id + "\" class=\"picLabel\" > <table class=\"picTable\"><tr><td class=\"picTd\"><img src=\"" + p.picUri + "\" disabled /></td></tr><tr><td class=\"chkTd\"><input id=\"rad" + p.id + "\" class=\"radPic\" name=\"radPic\" value=\"" + p.picUri + "\" type=\"radio\" /><label >" + p.picName + "</label></td></tr></table></label>"); // } //else if (p.picType == 2) //{ // //css3 // sb.Append("<label for=\"rad" + p.id + "\" class=\"picLabel\" > <table ><tr><td><span class=\"" + p.picUri + "\" /></td></tr><tr><td><input id=\"rad" + p.id + "\" class=\"radPic\" name=\"radPic\" value=\"" + p.picUri + "\" type=\"radio\" /><label >" + p.picName + "</label></td></tr></table></label>"); //} sb.Append("</li>"); } litPicStr.Text = sb.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public XCWeiXin.Model.wx_PicStore GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,picName,picUri,picTemplates,picType,picUsedType,picValue,picCreatePerson,createDate from wx_PicStore "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; XCWeiXin.Model.wx_PicStore model = new XCWeiXin.Model.wx_PicStore(); 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 bool Update(XCWeiXin.Model.wx_PicStore model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(XCWeiXin.Model.wx_PicStore model) { return(dal.Add(model)); }