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

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_AgreeSupplyMeeting : System.Web.UI.Page
  13. {
  14.     /// <summary>
  15.     /// 模板 
  16.     /// </summary>
  17.     Model.MeetingRun MC = new Model.MeetingRun();
  18.     /// <summary>
  19.     /// 业务
  20.     /// </summary>
  21.     BLL.MeetingRun BC = new BLL.MeetingRun();
  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_AgreeSupplyMeeting");
  43.         BLL.MeetingManagers BMM = new BLL.MeetingManagers();
  44.         if (BMM.GetCount("GLY = '" + SessionInclude.SessionId + "'") <= 0)
  45.         {
  46.             MessageBox.ShowAndRedirect(this, "你没有权限浏览该页面!", "../index.aspx");
  47.         }
  48.         else
  49.         {
  50.             if (!IsPostBack)
  51.             {
  52.                 //TiaoJian = "CPH = 'lvs' and SYZT = '待批' and convert(varchar(10),KSSJ,120) = '今天'";
  53.                 TiaoJian = "PZZT = '" + States.SupplyState_Wait + "' and convert(varchar(10),KSSJ,120) = '" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
  54.                 MyDataBind(1);
  55.             }
  56.         }
  57.     }
  58.     /// <summary>
  59.     /// 获取信息
  60.     /// </summary>
  61.     /// <param name="pidx">页号</param>
  62.     public void MyDataBind(int pidx)
  63.     {
  64.         AspNetPager1.RecordCount = BC.GetCount(TiaoJian);
  65.         List<Model.MeetingRun> LRData = BC.GetPageList(20, pidx, "KSSJ", true, TiaoJian);
  66.         if (LRData.Count == 0)
  67.         {
  68.             Model.MeetingRun MC = new Model.MeetingRun();
  69.             LRData.Add(MC);
  70.         }
  71.         GridView1.DataSource = LRData;
  72.         GridView1.DataBind();
  73.     }
  74.     /// <summary>
  75.     /// 会议室
  76.     /// </summary>
  77.     /// <returns></returns>
  78.     public string HYS()
  79.     {
  80.         int id = 0;
  81.         if (BC.GetCount(TiaoJian) > 0)
  82.         {
  83.             id = int.Parse(Eval("HYS").ToString());
  84.         }
  85.         return EnumGet.GetMeetingRoomsName(id);
  86.     }
  87.     /// <summary>
  88.     /// 操作
  89.     /// </summary>
  90.     /// <returns></returns>
  91.     public string CaoZuo()
  92.     {
  93.         string Rtstr = "";
  94.         if (BC.GetCount(TiaoJian) > 0)
  95.         {
  96.             string Id = Eval("Id").ToString();
  97.             Rtstr = "<a href='" + "MeetingDetail.aspx?id=" + Id + "'>详细信息</a>&nbsp;&nbsp;";
  98.         }
  99.         else
  100.         {
  101.             Rtstr = "今日还没有待批的会议室!";
  102.         }
  103.         return Rtstr;
  104.     }
  105.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  106.     {
  107.         MyDataBind(e.NewPageIndex);
  108.     }
  109.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  110.     {
  111.         for (int i = 0; i < GridView1.Rows.Count; i++)
  112.         {
  113.             //首先判断是否是数据行
  114.             if (e.Row.RowType == DataControlRowType.DataRow)
  115.             {
  116.                 //当鼠标停留时更改背景色
  117.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  118.                 //当鼠标移开时还原背景色
  119.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  120.             }
  121.         }
  122.     }
  123.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  124.     {
  125.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  126.         {
  127.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  128.             if (CheckBox1.Checked)
  129.             {
  130.                 cbox.Checked = true;
  131.             }
  132.             else
  133.             {
  134.                 cbox.Checked = false;
  135.             }
  136.         }
  137.     }
  138.     protected void DelButton1_Click(object sender, EventArgs e)
  139.     {
  140.         try
  141.         {
  142.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  143.             {
  144.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  145.                 if (cbox.Checked)
  146.                 {
  147.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  148.                     if (Id == 0)
  149.                     {
  150.                         throw new Exception("该记录不能进行审批!");
  151.                     }
  152.                     MC = BC.GetModel(Id);
  153.                     MC.PZZT = States.SupplyState_Agree;
  154.                     BC.Update(MC);
  155.                 }
  156.                 else
  157.                 {
  158.                 }
  159.             }
  160.             MessageBox.Show("审批完成!");
  161.         }
  162.         catch (Exception exp)
  163.         { MessageBox.Show(exp.Message); }
  164.         MyDataBind(AspNetPager1.CurrentPageIndex);
  165.     }
  166.     protected void DelButton2_Click(object sender, EventArgs e)
  167.     {
  168.         try
  169.         {
  170.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  171.             {
  172.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  173.                 if (cbox.Checked)
  174.                 {
  175.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  176.                     if (Id == 0)
  177.                     {
  178.                         throw new Exception("该记录不能进行审批!");
  179.                     }
  180.                     if (String.IsNullOrEmpty(KeyValue_MS.Text.Trim()))
  181.                     {
  182.                         throw new Exception("原因不能为空!");
  183.                     }
  184.                     MC = BC.GetModel(Id);
  185.                     MC.PZZT = States.SupplyState_No;
  186.                     MC.MS = KeyValue_MS.Text;
  187.                     BC.Update(MC);
  188.                 }
  189.                 else
  190.                 {
  191.                 }
  192.             }
  193.             MessageBox.Show("审批完成!");
  194.             KeyValue_MS.Text = "";
  195.         }
  196.         catch (Exception exp)
  197.         { MessageBox.Show(exp.Message); }
  198.         MyDataBind(AspNetPager1.CurrentPageIndex);
  199.     }
  200. }