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

OA系统

开发平台:

C#

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