protected void gv_catelist_RowEditing(object sender, GridViewEditEventArgs e) { for (int i = 0; i < this.gv_catelist.Rows.Count; i++) { if (i == e.NewEditIndex) { this.gv_catelist.Rows[i].CssClass = "select"; } else { this.gv_catelist.Rows[i].CssClass = "select_no"; } } InfoSortInfo infoSortInfo = InfoSortInfo.Read((int)this.gv_catelist.DataKeys[e.NewEditIndex].Value); this.hf_id.Value = infoSortInfo.Id.ToString(); this.ddl_module.SelectedValue = infoSortInfo.ModuleId.ToString(); this.ddl_cate.SelectedValue = infoSortInfo.Pid.ToString(); this.tb_sortname.Text = infoSortInfo.SortName; this.tb_sortUrl.Text = infoSortInfo.SortUrl; this.tb_sortOrder.Text = infoSortInfo.SortOrder.ToString(); this.tb_sortPath.Text = infoSortInfo.SortPath; this.tb_sortFileName.Text = infoSortInfo.SortFileName; this.tb_sortTitle.Text = infoSortInfo.SortTitle; this.tb_keywords.Text = infoSortInfo.Keywords; this.tb_description.Text = infoSortInfo.Description; this.bt_add.Text = " 修改 "; }
protected void bt_delete_Click(object sender, EventArgs e) { for (int i = 0; i < this.gv_catelist.Rows.Count; i++) { CheckBox checkBox = this.gv_catelist.Rows[i].FindControl("checkbox1") as CheckBox; if (checkBox.Checked) { InfoSortInfo.Delete((int)this.gv_catelist.DataKeys[i].Value); } } this.BindData(); }
public static List <InfoSortInfo> ReadList(string whereStr) { List <InfoSortInfo> list = new List <InfoSortInfo>(); Database database = new Database(); DataView defaultView = database.RunProc("select * from InfoSort " + whereStr).Tables[0].DefaultView; for (int i = 0; i < defaultView.Count; i++) { list.Add(InfoSortInfo.Read(int.Parse(defaultView[i]["id"].ToString()))); } database.Dispose(); return(list); }
public static InfoSortInfo Read(int id) { InfoSortInfo result = null; Database database = new Database(); MySqlDataReader mySqlDataReader = database.RunProcGetReader("select * from InfoSort where id=" + id); while (mySqlDataReader.Read()) { result = new InfoSortInfo(int.Parse(mySqlDataReader.GetValue(0).ToString()), int.Parse(mySqlDataReader.GetValue(1).ToString()), int.Parse(mySqlDataReader.GetValue(2).ToString()), int.Parse(mySqlDataReader.GetValue(3).ToString()), mySqlDataReader.GetValue(4).ToString(), int.Parse(mySqlDataReader.GetValue(5).ToString()), mySqlDataReader.GetValue(6).ToString(), int.Parse(mySqlDataReader.GetValue(7).ToString()), mySqlDataReader.GetValue(8).ToString(), mySqlDataReader.GetValue(9).ToString(), mySqlDataReader.GetValue(10).ToString(), mySqlDataReader.GetValue(11).ToString(), mySqlDataReader.GetValue(12).ToString(), DateTime.Parse(mySqlDataReader.GetValue(13).ToString()), int.Parse(mySqlDataReader.GetValue(14).ToString())); } mySqlDataReader.Close(); database.Dispose(); return(result); }
protected void gv_catelist_RowUpdating(object sender, GridViewUpdateEventArgs e) { InfoSortInfo infoSortInfo = InfoSortInfo.Read((int)this.gv_catelist.DataKeys[e.RowIndex].Value); if (infoSortInfo.SortStatus == 1) { infoSortInfo.SortStatus = 0; } else { infoSortInfo.SortStatus = 1; } infoSortInfo.Update(); this.BindData(); }
protected void bt_save_Click(object sender, EventArgs e) { for (int i = 0; i < this.gv_catelist.Rows.Count; i++) { CheckBox checkBox = this.gv_catelist.Rows[i].FindControl("checkbox1") as CheckBox; if (checkBox.Checked) { InfoSortInfo infoSortInfo = InfoSortInfo.Read((int)this.gv_catelist.DataKeys[i].Value); infoSortInfo.SortName = ((TextBox)this.gv_catelist.Rows[i].FindControl("tb_sortname")).Text; infoSortInfo.SortUrl = ((TextBox)this.gv_catelist.Rows[i].FindControl("tb_sortUrl")).Text; infoSortInfo.SortType = int.Parse(((DropDownList)this.gv_catelist.Rows[i].FindControl("ddl_sortType")).SelectedValue); infoSortInfo.SortOrder = int.Parse(((TextBox)this.gv_catelist.Rows[i].FindControl("tb_sortOrder")).Text); infoSortInfo.Update(); } } this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Ok", "alert('保存成功!');", true); this.BindData(); }
protected void bt_add_Click(object sender, EventArgs e) { if (this.hf_id.Value == "0") { int sortLevel = 0; if (this.ddl_cate.SelectedValue != "0") { InfoSortInfo infoSortInfo = InfoSortInfo.Read(int.Parse(this.ddl_cate.SelectedValue)); sortLevel = infoSortInfo.SortLevel + 1; } InfoSortInfo infoSortInfo2 = new InfoSortInfo(0, int.Parse(this.ddl_module.SelectedValue), sortLevel, int.Parse(this.ddl_cate.SelectedValue), this.tb_sortname.Text, int.Parse(this.ddl_sortType.Text), this.tb_sortUrl.Text, int.Parse(this.tb_sortOrder.Text), "", "", "", "", "", DateTime.Now, 1); infoSortInfo2.Insert(); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Ok", "alert('添加成功!');", true); } else { InfoSortInfo infoSortInfo3 = InfoSortInfo.Read(int.Parse(this.hf_id.Value)); infoSortInfo3.ModuleId = int.Parse(this.ddl_module.SelectedValue); if (infoSortInfo3.Id.ToString() != this.ddl_cate.SelectedValue) { infoSortInfo3.Pid = int.Parse(this.ddl_cate.SelectedValue); } if (this.ddl_cate.SelectedValue != "0") { infoSortInfo3.SortLevel = InfoSortInfo.Read(int.Parse(this.ddl_cate.SelectedValue)).SortLevel + 1; } else { infoSortInfo3.SortLevel = 0; } infoSortInfo3.SortType = int.Parse(this.ddl_sortType.SelectedValue); infoSortInfo3.SortName = this.tb_sortname.Text; infoSortInfo3.SortUrl = this.tb_sortUrl.Text; infoSortInfo3.SortOrder = int.Parse(this.tb_sortOrder.Text); infoSortInfo3.SortPath = this.tb_sortPath.Text; infoSortInfo3.SortFileName = this.tb_sortFileName.Text; infoSortInfo3.SortTitle = this.tb_sortTitle.Text; infoSortInfo3.Keywords = this.tb_keywords.Text; infoSortInfo3.Description = this.tb_description.Text; infoSortInfo3.Update(); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Ok", "alert('修改成功!');", true); } this.BindData(); }
protected void gv_catelist_RowDeleting(object sender, GridViewDeleteEventArgs e) { InfoSortInfo.Delete((int)this.gv_catelist.DataKeys[e.RowIndex].Value); this.BindData(); }
public void BindData() { int currentPage = (base.Request["page"] != null && base.Request["page"] != "") ? int.Parse(base.Request["page"]) : 1; this.pager.CurrentPage = currentPage; this.pager.PageSize = 10; int recordConnt = 0; this.repeater1.DataSource = this.db.RunProcGetDataView(string.Concat(new object[] { "select * from article where sortId=", int.Parse(base.Request["id"]), " or sortId in(select id from infoSort where pid=", int.Parse(base.Request["id"]), ")" }), (this.pager.CurrentPage - 1) * this.pager.PageSize, this.pager.PageSize, out recordConnt); this.repeater1.DataBind(); this.pager.UrlFormat = "?page={0}&id=" + base.Request["id"]; this.pager.NumberButton = 10; this.pager.RecordConnt = recordConnt; InfoSortInfo infoSortInfo = InfoSortInfo.Read(int.Parse(base.Request["id"])); this.Page.Title = infoSortInfo.SortName; MySqlDataReader mySqlDataReader = this.db.RunProcGetReader("select B.moduleTableName as moduleName, A.* from infosort as A,moduleList as B where A.moduleId=B.id and pid<>0 and A.moduleId=13 order by A.sortOrder "); while (mySqlDataReader.Read()) { if (mySqlDataReader["sortType"].ToString() == "1") { this.sb.AppendLine(string.Concat(new string[] { "<li><a href='", mySqlDataReader["moduleName"].ToString(), "List.aspx?id=", mySqlDataReader["Id"].ToString(), "'>", mySqlDataReader["SortName"].ToString(), "</a></li>" })); } else { if (mySqlDataReader["sortType"].ToString() == "2") { this.sb.AppendLine(string.Concat(new string[] { "<li><a href='", mySqlDataReader["moduleName"].ToString(), "View.aspx?sortId=", mySqlDataReader["Id"].ToString(), "''>", mySqlDataReader["SortName"].ToString(), "</a></li>" })); } else { if (mySqlDataReader["sortType"].ToString() == "3") { this.sb.AppendLine(string.Concat(new string[] { "<li><a href='", mySqlDataReader["sortUrl"].ToString(), "'>", mySqlDataReader["SortName"].ToString(), "</a></li>" })); } } } } mySqlDataReader.Close(); }