/// <summary> /// 数据绑定 /// </summary> public void Bind() { if (Request.QueryString["ids"] != null && Request.QueryString["ids"].ToString() != "") { publicityPicturemodel = publicityPicturebll.GetModel(Convert.ToInt32(Request.QueryString["ids"])); if (publicityPicturemodel != null) { string[] strlistss = publicityPicturemodel.Content.Split(','); if (strlistss.Length > 0) { if (strlistss.Length > 24) { int shang = strlistss.Length / 3; double yushu = strlistss.Length % 3; if (yushu > 0) { shang = shang + 1; } int width = 213 * shang + 25; strlist = "<div style='height: 660px;'>"; } for (int i = 0; i < strlistss.Length; i++) { strlist += "<div style='float:left;width:185px;margin: 0 10px;margin-top:25px;cursor:pointer;' onclick='goitemback(" + i + ")'>" + "<img src='" + FilesUrl + "UploadFiles/Guide/PublicityP/" + strlistss[i].ToString() + "' width='186' height='165' style='border-radius: 15px;'/>" + "</div> "; } } } } strlist += "</div>"; }
/// <summary> /// 得到一个对象实体 /// </summary> public HeqiaoDaoshiCore.Model.PublicityPicture DataRowToModel(DataRow row) { HeqiaoDaoshiCore.Model.PublicityPicture model = new HeqiaoDaoshiCore.Model.PublicityPicture(); if (row != null) { if (row["PublicityPictureUUID"] != null && row["PublicityPictureUUID"].ToString() != "") { model.PublicityPictureUUID = new Guid(row["PublicityPictureUUID"].ToString()); } if (row["Title"] != null) { model.Title = row["Title"].ToString(); } if (row["ReleaseTime"] != null && row["ReleaseTime"].ToString() != "") { model.ReleaseTime = DateTime.Parse(row["ReleaseTime"].ToString()); } if (row["IsRelease"] != null && row["IsRelease"].ToString() != "") { if ((row["IsRelease"].ToString() == "1") || (row["IsRelease"].ToString().ToLower() == "true")) { model.IsRelease = true; } else { model.IsRelease = false; } } if (row["Cover"] != null) { model.Cover = row["Cover"].ToString(); } if (row["Content"] != null) { model.Content = row["Content"].ToString(); } if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } if (row["AddPeople"] != null) { model.AddPeople = row["AddPeople"].ToString(); } if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["IsDeleted"] != null && row["IsDeleted"].ToString() != "") { model.IsDeleted = int.Parse(row["IsDeleted"].ToString()); } if (row["Photo"] != null) { model.Photo = row["Photo"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(HeqiaoDaoshiCore.Model.PublicityPicture model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PublicityPicture set "); strSql.Append("Title=@Title,"); strSql.Append("ReleaseTime=@ReleaseTime,"); strSql.Append("IsRelease=@IsRelease,"); strSql.Append("Cover=@Cover,"); strSql.Append("Content=@Content,"); strSql.Append("AddTime=@AddTime,"); strSql.Append("AddPeople=@AddPeople,"); strSql.Append("IsDeleted=@IsDeleted,"); strSql.Append("Photo=@Photo"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@Title", SqlDbType.NVarChar, 255), new SqlParameter("@ReleaseTime", SqlDbType.DateTime), new SqlParameter("@IsRelease", SqlDbType.Bit, 1), new SqlParameter("@Cover", SqlDbType.NVarChar, -1), new SqlParameter("@Content", SqlDbType.NVarChar, -1), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@AddPeople", SqlDbType.VarChar, 100), new SqlParameter("@IsDeleted", SqlDbType.Int, 4), new SqlParameter("@Photo", SqlDbType.NVarChar, -1), new SqlParameter("@PublicityPictureUUID", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.Title; parameters[1].Value = model.ReleaseTime; parameters[2].Value = model.IsRelease; parameters[3].Value = model.Cover; parameters[4].Value = model.Content; parameters[5].Value = model.AddTime; parameters[6].Value = model.AddPeople; parameters[7].Value = model.IsDeleted; parameters[8].Value = model.Photo; parameters[9].Value = model.PublicityPictureUUID; parameters[10].Value = model.ID; int rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(HeqiaoDaoshiCore.Model.PublicityPicture model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PublicityPicture("); strSql.Append("PublicityPictureUUID,Title,ReleaseTime,IsRelease,Cover,Content,AddTime,AddPeople,IsDeleted,Photo)"); strSql.Append(" values ("); strSql.Append("@PublicityPictureUUID,@Title,@ReleaseTime,@IsRelease,@Cover,@Content,@AddTime,@AddPeople,@IsDeleted,@Photo)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@PublicityPictureUUID", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@Title", SqlDbType.NVarChar, 255), new SqlParameter("@ReleaseTime", SqlDbType.DateTime), new SqlParameter("@IsRelease", SqlDbType.Bit, 1), new SqlParameter("@Cover", SqlDbType.NVarChar, -1), new SqlParameter("@Content", SqlDbType.NVarChar, -1), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@AddPeople", SqlDbType.VarChar, 100), new SqlParameter("@IsDeleted", SqlDbType.Int, 4), new SqlParameter("@Photo", SqlDbType.NVarChar, -1) }; parameters[0].Value = Guid.NewGuid(); parameters[1].Value = model.Title; parameters[2].Value = model.ReleaseTime; parameters[3].Value = model.IsRelease; parameters[4].Value = model.Cover; parameters[5].Value = model.Content; parameters[6].Value = model.AddTime; parameters[7].Value = model.AddPeople; parameters[8].Value = model.IsDeleted; parameters[9].Value = model.Photo; object obj = DbHelperSql.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 数据绑定 /// </summary> public void Bind() { if (Request.QueryString["ids"] != null && Request.QueryString["ids"].ToString() != "") { publicityPicturemodel = publicityPicturebll.GetModel(Convert.ToInt32(Request.QueryString["ids"])); if (publicityPicturemodel != null) { string[] strlistss = publicityPicturemodel.Content.Split(','); if (strlistss.Length > 0) { Itemlistr = ""; for (int i = 0; i < strlistss.Length; i++) { Itemlistr += "<li><div style='float: left; width: 1230px; margin-top: 85px;'>" + "<img src ='" + FilesUrl + "UploadFiles/Guide/PublicityP/" + strlistss[i].ToString() + "' width='1207' height='557'/></div>" + "<span class='li-tit'>第" + (i + 1) + "张,共" + strlistss.Length + "张</span></li>"; } } } } }
/// <summary> /// 得到一个对象实体 /// </summary> public HeqiaoDaoshiCore.Model.PublicityPicture GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PublicityPictureUUID,Title,ReleaseTime,IsRelease,Cover,Content,AddTime,AddPeople,ID,IsDeleted,Photo from PublicityPicture "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; HeqiaoDaoshiCore.Model.PublicityPicture model = new HeqiaoDaoshiCore.Model.PublicityPicture(); DataSet ds = DbHelperSql.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }