CheckInManager.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.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 Articles_CheckInManager : System.Web.UI.Page
  13. {
  14.     /// <summary>
  15.     /// 模板 
  16.     /// </summary>
  17.     Model.UseThingsUse MU = new Model.UseThingsUse();
  18.     /// <summary>
  19.     /// 业务
  20.     /// </summary>
  21.     BLL.UseThingsUse BU = new BLL.UseThingsUse();
  22.     /// <summary>
  23.     /// 查询条件
  24.     /// </summary>
  25.     public string TiaoJian
  26.     {
  27.         get
  28.         {
  29.             if (ViewState["UseThingsUseTiaoJian"] == null)
  30.             {
  31.                 return "";
  32.             }
  33.             else
  34.             {
  35.                 return ViewState["UseThingsUseTiaoJian"].ToString();
  36.             }
  37.         }
  38.         set { ViewState["UseThingsUseTiaoJian"] = value; }
  39.     }
  40.     protected void Page_Load(object sender, EventArgs e)
  41.     {
  42.         LoginLogic.MatchLoad("../", "Articles_CheckInManager");
  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 = BU.GetCount(TiaoJian);
  60.         List<Model.UseThingsUse> LRData = BU.GetPageList(20, pidx, "ID", false, TiaoJian);
  61.         if (LRData.Count == 0)
  62.         {
  63.             Model.UseThingsUse MU = new Model.UseThingsUse();
  64.             LRData.Add(MU);
  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 = 0;
  76.         if (BU.GetCount(TiaoJian) > 0)
  77.         {
  78.             Id = EnumGet.GetDengJiIndex(Eval("DJBS").ToString());
  79.         }
  80.         return EnumGet.GetDengJiName(Id.ToString());
  81.     }
  82.     /// <summary>
  83.     /// 操作
  84.     /// </summary>
  85.     /// <returns></returns>
  86.     public string CaoZuo()
  87.     {
  88.         string Id = Eval("Id").ToString();
  89.         //编辑 清空密码 删除
  90.         //string Rtstr = "<a href='CheckInAdd.aspx'>库存登记</a>&nbsp;&nbsp;";
  91.         //Rtstr += "<a href='CheckInEditor.aspx?id=" + Id + "'>登记管理</a>&nbsp;&nbsp;";
  92.         string Rtstr = "";
  93.         if (BU.GetCount(TiaoJian) > 0)
  94.         {
  95.             Rtstr = "<a href='CheckInEditor.aspx?id=" + Id + "'>登记管理</a>&nbsp;&nbsp;";
  96.         }
  97.         else
  98.         {
  99.             Rtstr = "还没有登记信息";
  100.         }
  101.         return Rtstr;
  102.     }
  103.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  104.     {
  105.         MyDataBind(e.NewPageIndex);
  106.     }
  107.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  108.     {
  109.         for (int i = 0; i < GridView1.Rows.Count; i++)
  110.         {
  111.             //首先判断是否是数据行
  112.             if (e.Row.RowType == DataControlRowType.DataRow)
  113.             {
  114.                 //当鼠标停留时更改背景色
  115.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  116.                 //当鼠标移开时还原背景色
  117.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  118.             }
  119.         }
  120.     }
  121.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  122.     {
  123.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  124.         {
  125.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  126.             if (CheckBox1.Checked)
  127.             {
  128.                 cbox.Checked = true;
  129.             }
  130.             else
  131.             {
  132.                 cbox.Checked = false;
  133.             }
  134.         }
  135.     }
  136.     protected void DelButton1_Click(object sender, EventArgs e)
  137.     {
  138.         try
  139.         {
  140.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  141.             {
  142.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  143.                 if (cbox.Checked)
  144.                 {
  145.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  146.                     if (Id == 0)
  147.                     {
  148.                         throw new Exception("该记录不能删除!");
  149.                     }
  150.                     BU.Delete(Id);
  151.                 }
  152.                 else
  153.                 {
  154.                 }
  155.             }
  156.             MessageBox.Show("删除完成!");
  157.         }
  158.         catch (Exception exp)
  159.         { 
  160.             MessageBox.Show(exp.Message); 
  161.         }
  162.         MyDataBind(AspNetPager1.CurrentPageIndex);
  163.     }
  164. }