BBSBigTypeSetting.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:3k
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class WorkFlow_BBSBigTypeSetting : System.Web.UI.Page
- {
- /// <summary>
- /// 模板
- /// </summary>
- Model.BBSBigTYPE MR = new Model.BBSBigTYPE();
- /// <summary>
- /// 业务
- /// </summary>
- BLL.BBSBigTYPE BR = new BLL.BBSBigTYPE();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "WorkFlow_BBSBigTypeSetting");
- if (!IsPostBack)
- {
- MyDataBind();
- }
- }
- /// <summary>
- /// 获取信息
- /// </summary>
- /// <param name="pidx">页号</param>
- public void MyDataBind()
- {
- List<Model.BBSBigTYPE> LRData = BR.GetList();
- if (LRData.Count == 0)
- {
- Model.BBSBigTYPE MR = new Model.BBSBigTYPE();
- LRData.Add(MR);
- }
- GridView1.DataSource = LRData;
- GridView1.DataBind();
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- MR = new Model.BBSBigTYPE();
- MR.FLMC = TextBox1.Text;
- BR.Add(MR);
- MessageBox.Show("添加成功!");
- MyDataBind();
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- for (int i = 0; i < GridView1.Rows.Count; i++)
- {
- //首先判断是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //当鼠标停留时更改背景色
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
- //当鼠标移开时还原背景色
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }
- }
- protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- string ID = GridView1.Rows[e.RowIndex].Cells[0].Text.ToString().Trim();
- BR.Delete(int.Parse(ID));
- MessageBox.Show("删除成功!");
- MyDataBind();
- }
- protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
- {
- GridView1.EditIndex = e.NewEditIndex;//使其可以进行编辑
- MyDataBind();
- }
- protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
- {
- string tostr = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
- string ID = GridView1.Rows[e.RowIndex].Cells[0].Text.ToString().Trim();
- MR = new Model.BBSBigTYPE();
- MR.FLMC = tostr;
- MR.ID = int.Parse(ID);
- BR.Update(MR);
-
- GridView1.EditIndex = -1;//取消编辑
- MessageBox.Show("更新了" + tostr);
- MyDataBind();
-
- }
- protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
- {
- GridView1.EditIndex = -1;//取消编辑
- MyDataBind();
- }
- }