EntertainManager.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 Entertain_EntertainManager : System.Web.UI.Page
  13. {
  14.     /// <summary>
  15.     /// 模板 
  16.     /// </summary>
  17.     Model.Receives MR = new Model.Receives();
  18.     /// <summary>
  19.     /// 业务
  20.     /// </summary>
  21.     BLL.Receives BR = new BLL.Receives();
  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("../", "Entertain_EntertainManager");
  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 = BR.GetCount(TiaoJian);
  60.         List<Model.Receives> LRData = BR.GetPageList(20, pidx, "ID", false, TiaoJian);
  61.         if (LRData.Count == 0)
  62.         {
  63.             Model.Receives MR = new Model.Receives();
  64.             LRData.Add(MR);
  65.         }
  66.         GridView1.DataSource = LRData;
  67.         GridView1.DataBind();
  68.     }
  69.     /// <summary>
  70.     /// 接待人员
  71.     /// </summary>
  72.     /// <returns></returns>
  73.     public string YPLB()
  74.     {
  75.         //int Id = int.Parse(Eval("YPLB").ToString());
  76.         //return EnumGet.GetUseThingsTypeName(Id);
  77.         return SessionInclude.SessionId;
  78.     }
  79.     /// <summary>
  80.     /// 接待类别
  81.     /// </summary>
  82.     /// <returns></returns>
  83.     public string JDLB()
  84.     {
  85.         string Id = "0";
  86.         if (BR.GetCount(TiaoJian) > 0)
  87.         {
  88.             Id = Eval("JDLB").ToString(); 
  89.         }       
  90.         return EnumGet.GetJieDaiName(Id);
  91.     }
  92.     /// <summary>
  93.     /// 详细类别
  94.     /// </summary>
  95.     /// <returns></returns>
  96.     public string XXLB()
  97.     {
  98.         string Id_jd = "0";
  99.         string Id_xx = "0";
  100.         if (BR.GetCount(TiaoJian) > 0)
  101.         {
  102.             Id_jd = Eval("JDLB").ToString();
  103.             Id_xx = Eval("XXLB").ToString();
  104.         }
  105.         return EnumGet.GetXiangXiName(int.Parse(Id_jd), int.Parse(Id_xx));
  106.     }
  107.     /// <summary>
  108.     /// 操作
  109.     /// </summary>
  110.     /// <returns></returns>
  111.     public string CaoZuo()
  112.     {
  113.         string Id = Eval("Id").ToString();
  114.         //编辑 清空密码 删除
  115.         //string Rtstr = "<a href='ArticlesInfoAdd.aspx'>添加用品</a>&nbsp;&nbsp;";
  116.         //Rtstr += "<a href='ArticlesInfoEditor.aspx?id=" + Id + "'>修改用品</a>&nbsp;&nbsp;";
  117.         string Rtstr = "";
  118.         if (BR.GetCount(TiaoJian) > 0)
  119.         {
  120.             Rtstr = "<a href='EntertainEditor.aspx?id=" + Id + "'>修改</a>&nbsp;&nbsp;";
  121.         }
  122.         else
  123.         {
  124.             Rtstr = "还没有接待!";
  125.         }
  126.         return Rtstr;
  127.     }
  128.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  129.     {
  130.         MyDataBind(e.NewPageIndex);
  131.     }
  132.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  133.     {
  134.         for (int i = 0; i < GridView1.Rows.Count; i++)
  135.         {
  136.             //首先判断是否是数据行
  137.             if (e.Row.RowType == DataControlRowType.DataRow)
  138.             {
  139.                 //当鼠标停留时更改背景色
  140.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  141.                 //当鼠标移开时还原背景色
  142.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  143.             }
  144.         }
  145.     }
  146.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  147.     {
  148.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  149.         {
  150.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  151.             if (CheckBox1.Checked)
  152.             {
  153.                 cbox.Checked = true;
  154.             }
  155.             else
  156.             {
  157.                 cbox.Checked = false;
  158.             }
  159.         }
  160.     }
  161.     protected void DelButton1_Click(object sender, EventArgs e)
  162.     {
  163.         try
  164.         {
  165.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  166.             {
  167.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  168.                 if (cbox.Checked)
  169.                 {
  170.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  171.                     if (Id == 0)
  172.                     {
  173.                         throw new Exception("该记录不能删除!");
  174.                     }
  175.                     BR.Delete(Id);
  176.                 }
  177.                 else
  178.                 {
  179.                 }
  180.             }
  181.             MessageBox.Show("删除完成!");
  182.         }
  183.         catch (Exception exp)
  184.         { MessageBox.Show(exp.Message); }
  185.         MyDataBind(AspNetPager1.CurrentPageIndex);
  186.     }
  187. }