protected void dataBind() { DataTable dt = bll.GetList(0); rptChannelList.DataSource = dt; rptChannelList.DataBind(); } protected void btnUpdate_Click(object sender, EventArgs e) { int channelid = 0; int sort = 0; int channeltop = 0; int resCount = 0; foreach (RepeaterItem rpt in rptChannelList.Items) { if (rpt.ItemType == ListItemType.AlternatingItem || rpt.ItemType == ListItemType.Item) { channelid = int.Parse(((HiddenField)rpt.FindControl("hidChannelID")).Value); if (((TextBox)rpt.FindControl("txtSort")).Text == "") sort = 0; else sort = int.Parse(((TextBox)rpt.FindControl("txtSort")).Text); if (((TextBox)rpt.FindControl("txtTop")).Text == "") channeltop = 0; else channeltop = int.Parse(((TextBox)rpt.FindControl("txtTop")).Text); model.ChannelID = channelid; model.Sort = sort; model.ChannelTop = channeltop; if (bll.UpdateSort(model)) resCount++; } } dataBind(); if (resCount == rptChannelList.Items.Count && resCount > 0) JscriptPrint("更新定位编号信息成功!", "", "Success"); } /// <summary> /// 更新栏目定位编号 /// </summary> /// <param name="model"></param> public bool UpdateSort(ZBGA.Model.Channel model) { return dal.UpdateSort(model); } /// <summary> /// 更新栏目定位编号 /// </summary> /// <param name="model">栏目实体类</param> public bool UpdateSort(ZBGA.Model.Channel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dt_Channel set "); strSql.Append("sort=@sort,ChannelTop=@ChannelTop"); strSql.Append(" where ChannelID=@ChannelID "); SqlParameter[] parameters = { new SqlParameter("@ChannelID", SqlDbType.Int,4), new SqlParameter("@sort",SqlDbType.Int,4), new SqlParameter("@ChannelTop",SqlDbType.Int,4) }; parameters[0].Value = model.ChannelID; parameters[1].Value = model.Sort; parameters[2].Value = model.ChannelTop; return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0; } /// <summary> /// 添加编辑删除提示 /// </summary> /// <param name="msgtitle">提示文字</param> /// <param name="url">返回地址</param> /// <param name="msgcss">CSS样式</param> protected void JscriptPrint(string msgtitle, string url, string msgcss) { string msbox = ""; msbox += "<script type="text/javascript"> "; msbox += "parent.jsprint("" + msgtitle + "","" + url + "","" + msgcss + "") "; msbox += "</script> "; ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox); } // JavaScript Document //可以自动关闭的提示 function jsprint(msgtitle, url, msgcss) { $("#msgprint").remove(); var cssname = ""; switch (msgcss) { case "Success": cssname = "pcent correct"; break; case "Error": cssname = "pcent disable"; break; default: cssname = "pcent warning"; break; } var str = "<div id="msgprint" class="" + cssname + "">" + msgtitle + "</div>"; $("body").append(str); $("#msgprint").show(); //2秒后清除提示 setTimeout(function() { $("#msgprint").fadeOut(500); //如果动画结束则删除节点 if (!$("#msgprint").is(":animated")) { $("#msgprint").remove(); } //转向URL if (url == "back") { window.history.back(-1); } else if (url != "") { window.location.href = url; } }, 2000); }