WorkFlowTypeSetting.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:3k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class WorkFlow_WorkFlowTypeSetting : System.Web.UI.Page
  12. {
  13.     /// <summary>
  14.     /// 模板
  15.     /// </summary>
  16.     Model.FlowBaseType MR = new Model.FlowBaseType();
  17.     /// <summary>
  18.     /// 业务
  19.     /// </summary>
  20.     BLL.FlowBaseType BR = new BLL.FlowBaseType();
  21.     protected void Page_Load(object sender, EventArgs e)
  22.     {
  23.         LoginLogic.MatchLoad("../", "WorkFlow_WorkFlowTypeSetting");
  24.         if (!IsPostBack)
  25.         {
  26.             MyDataBind();
  27.         }
  28.     }
  29.     /// <summary>
  30.     /// 获取信息
  31.     /// </summary>
  32.     /// <param name="pidx">页号</param>
  33.     public void MyDataBind()
  34.     {
  35.         List<Model.FlowBaseType> LRData = BR.GetList();
  36.         if (LRData.Count == 0)
  37.         {
  38.             Model.FlowBaseType MR = new Model.FlowBaseType();
  39.             LRData.Add(MR);
  40.         }
  41.         GridView1.DataSource = LRData;
  42.         GridView1.DataBind();
  43.     }
  44.     protected void Button1_Click(object sender, EventArgs e)
  45.     {
  46.         MR = new Model.FlowBaseType();
  47.         MR.FLMC = TextBox1.Text;
  48.         BR.Add(MR);
  49.         MessageBox.Show("添加成功!");
  50.         MyDataBind();
  51.     }
  52.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  53.     {
  54.         for (int i = 0; i < GridView1.Rows.Count; i++)
  55.         {
  56.             //首先判断是否是数据行
  57.             if (e.Row.RowType == DataControlRowType.DataRow)
  58.             {
  59.                 //当鼠标停留时更改背景色
  60.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  61.                 //当鼠标移开时还原背景色
  62.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  63.             }
  64.         }
  65.     }
  66.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  67.     {
  68.         string ID = GridView1.Rows[e.RowIndex].Cells[0].Text.ToString().Trim();
  69.         BR.Delete(int.Parse(ID));
  70.         MessageBox.Show("删除成功!");
  71.         MyDataBind();
  72.     }
  73.     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  74.     {
  75.         GridView1.EditIndex = e.NewEditIndex;//使其可以进行编辑
  76.         MyDataBind();
  77.     }
  78.     protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  79.     {
  80.         string tostr = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
  81.         string ID = GridView1.Rows[e.RowIndex].Cells[0].Text.ToString().Trim();
  82.         MR = new Model.FlowBaseType();
  83.         MR.FLMC = tostr;
  84.         MR.ID = int.Parse(ID);
  85.         BR.Update(MR);
  86.    
  87.         GridView1.EditIndex = -1;//取消编辑
  88.         MessageBox.Show("更新了" + tostr);
  89.         MyDataBind();
  90.   
  91.     }
  92.     protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
  93.     {
  94.         GridView1.EditIndex = -1;//取消编辑
  95.         MyDataBind();
  96.     }
  97. }