ArticlesTypeSetting.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 Articles_ArticlesTypeSetting : System.Web.UI.Page
  12. {
  13.     /// <summary>
  14.     /// 模板 
  15.     /// </summary>
  16.     Model.UseThingsType MR = new Model.UseThingsType();
  17.     /// <summary>
  18.     /// 业务
  19.     /// </summary>
  20.     BLL.UseThingsType BR = new BLL.UseThingsType();
  21.     protected void Page_Load(object sender, EventArgs e)
  22.     {
  23.         LoginLogic.MatchLoad("../", "Articles_ArticlesTypeSetting");
  24.         if (!IsPostBack)
  25.         {
  26.             MyDataBind();
  27.         }
  28.     }
  29.     protected void Button1_Click(object sender, EventArgs e)
  30.     {
  31.         MR.LBMC = KeyValue_LBMC.Text;
  32.         BR.Add(MR);
  33.         MyDataBind();
  34.         MessageBox.Show("添加成功!");
  35.     }
  36.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  37.     {
  38.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  39.         {
  40.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  41.             if (CheckBox1.Checked)
  42.             {
  43.                 cbox.Checked = true;
  44.             }
  45.             else
  46.             {
  47.                 cbox.Checked = false;
  48.             }
  49.         }
  50.     }
  51.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  52.     {
  53.         for (int i = 0; i < GridView1.Rows.Count; i++)
  54.         {
  55.             //首先判断是否是数据行
  56.             if (e.Row.RowType == DataControlRowType.DataRow)
  57.             {
  58.                 //当鼠标停留时更改背景色
  59.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  60.                 //当鼠标移开时还原背景色
  61.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  62.             }
  63.         }
  64.     }
  65.     /// <summary>
  66.     /// 获取信息
  67.     /// </summary>
  68.     /// <param name="pidx">页号</param>
  69.     public void MyDataBind()
  70.     {
  71.         List<Model.UseThingsType> LRData = BR.GetList();
  72.         if (LRData.Count == 0)
  73.         {
  74.             Model.UseThingsType MR = new Model.UseThingsType();
  75.             LRData.Add(MR);
  76.         }
  77.         GridView1.DataSource = LRData;
  78.         GridView1.DataBind();
  79.     }
  80.     protected void DelButton1_Click(object sender, EventArgs e)
  81.     {
  82.         try
  83.         {
  84.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  85.             {
  86.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  87.                 if (cbox.Checked)
  88.                 {
  89.                     // Response.Write(GridView1.Rows[i].Cells[1].Text.ToString() + ":True");
  90.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  91.                     BR.Delete(Id);
  92.                 }
  93.                 else
  94.                 {
  95.                     //Response.Write((GridView1.Rows[i].Cells[1]).Text.ToString() + ":False");
  96.                 }
  97.             }
  98.             MessageBox.Show("删除完成!");
  99.         }
  100.         catch (Exception exp)
  101.         { MessageBox.Show(exp.Message); }
  102.         MyDataBind();
  103.     }
  104. }