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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  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. using System.Collections.Generic;
  12. public partial class FileBooks_RollRoomManager : System.Web.UI.Page
  13. {
  14.     /// <summary>
  15.     /// 模板 
  16.     /// </summary>
  17.     Model.RollRooms MR = new Model.RollRooms();
  18.     /// <summary>
  19.     /// 业务
  20.     /// </summary>
  21.     BLL.RollRooms BR = new BLL.RollRooms();
  22.     /// <summary>
  23.     /// 查询条件
  24.     /// </summary>
  25.     public string TiaoJian
  26.     {
  27.         get
  28.         {
  29.             if (ViewState["RollRoomsTiaoJian"] == null)
  30.             {
  31.                 return "";
  32.             }
  33.             else
  34.             {
  35.                 return ViewState["RollRoomsTiaoJian"].ToString();
  36.             }
  37.         }
  38.         set { ViewState["RollRoomsTiaoJian"] = value; }
  39.     }
  40.     protected void Page_Load(object sender, EventArgs e)
  41.     {
  42.         LoginLogic.MatchLoad("../", "FileBooks_RollRoomManager");
  43.         if (!IsPostBack)
  44.         {
  45.             TiaoJian = "";
  46.             MyDataBind(1);
  47.         }
  48.     }
  49.     /// <summary>
  50.     /// 获取信息
  51.     /// </summary>
  52.     /// <param name="pidx">页号</param>
  53.     public void MyDataBind(int pidx)
  54.     {
  55.         AspNetPager1.RecordCount = BR.GetCount(TiaoJian);
  56.         List<Model.RollRooms> LRData = BR.GetPageList(20, pidx, "ID", false, TiaoJian);
  57.         if (LRData.Count == 0)
  58.         {
  59.             Model.RollRooms MR = new Model.RollRooms();
  60.             MR.BZ = "";
  61.             MR.ID = 0;
  62.             MR.JKH = "";
  63.             MR.JKMC = "";
  64.             MR.SSBM = "";
  65.             LRData.Add(MR);
  66.         }
  67.         GridView1.DataSource = LRData;
  68.         GridView1.DataBind();
  69.     }
  70.     /// <summary>
  71.     /// 部门
  72.     /// </summary>
  73.     /// <returns></returns>
  74.     public string BuMen()
  75.     {
  76.         int Id = int.Parse(Eval("SSBM").ToString());
  77.         return OACommon.GetDept(Id);
  78.     }
  79.     /// <summary>
  80.     /// 操作
  81.     /// </summary>
  82.     /// <returns></returns>
  83.     public string CaoZuo()
  84.     {
  85.         string Id = Eval("Id").ToString();
  86.         //编辑 清空密码 删除
  87.         string Rtstr = "<a href='RollRoomAdd.aspx'>添加卷库</a>&nbsp;&nbsp;";
  88.         Rtstr += "<a href='RollRoomEdit.aspx?id=" + Id + "'>修改卷库信息</a>&nbsp;&nbsp;";
  89.         
  90.         return Rtstr;
  91.     }
  92.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  93.     {
  94.         MyDataBind(e.NewPageIndex);
  95.     }
  96.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  97.     {
  98.         for (int i = 0; i < GridView1.Rows.Count; i++)
  99.         {
  100.             //首先判断是否是数据行
  101.             if (e.Row.RowType == DataControlRowType.DataRow)
  102.             {
  103.                 //当鼠标停留时更改背景色
  104.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  105.                 //当鼠标移开时还原背景色
  106.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  107.             }
  108.         }
  109.     }
  110.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  111.     {
  112.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  113.         {
  114.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  115.             if (CheckBox1.Checked)
  116.             {
  117.                 cbox.Checked = true;
  118.             }
  119.             else
  120.             {
  121.                 cbox.Checked = false;
  122.             }
  123.         }
  124.     }
  125.     protected void DelButton1_Click(object sender, EventArgs e)
  126.     {
  127.         try
  128.         {
  129.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  130.             {
  131.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  132.                 if (cbox.Checked)
  133.                 {
  134.                     // Response.Write(GridView1.Rows[i].Cells[1].Text.ToString() + ":True");
  135.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  136.                     BR.Delete(Id);
  137.                 }
  138.                 else
  139.                 {
  140.                     //  Response.Write((GridView1.Rows[i].Cells[1]).Text.ToString() + ":False");
  141.                 }
  142.             }
  143.             MessageBox.Show("删除完成!");
  144.         }
  145.         catch (Exception exp)
  146.         { MessageBox.Show(exp.Message); }
  147.         MyDataBind(AspNetPager1.CurrentPageIndex);
  148.     }
  149. }