MaintenanceManager.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.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 Vehicles_MaintenanceManager : System.Web.UI.Page
  13. {
  14.     /// <summary>
  15.     /// 模板 
  16.     /// </summary>
  17.     Model.CarsKeep MF = new Model.CarsKeep();
  18.     /// <summary>
  19.     /// 业务
  20.     /// </summary>
  21.     BLL.CarsKeep BF = new BLL.CarsKeep();
  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("../", "Vehicles_MaintenanceManager");
  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.CarsKeep> LRData = BF.GetPageList(20, pidx, "ID", false, TiaoJian);
  61.         if (LRData.Count == 0)
  62.         {
  63.             Model.CarsKeep MF = new Model.CarsKeep();
  64.             LRData.Add(MF);
  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 CPH()
  84.     {
  85.         int id = 0;
  86.         if (BF.GetCount(TiaoJian) > 0)
  87.         {
  88.             id = int.Parse(Eval("CPH").ToString());
  89.         }
  90.         return EnumGet.GetCarNumberName(id);
  91.     }
  92.     /// <summary>
  93.     /// 维护类型
  94.     /// </summary>
  95.     /// <returns></returns>
  96.     public string WHLX()
  97.     {
  98.         string id = "0";
  99.         if (BF.GetCount(TiaoJian) > 0)
  100.         {
  101.             id = Eval("WHLX").ToString();
  102.         }
  103.         return EnumGet.GetWeiHuName(id);
  104.     }
  105.     /// <summary>
  106.     /// 维护日期
  107.     /// </summary>
  108.     /// <returns></returns>
  109.     public string WHRQ()
  110.     {
  111.         return Convert.ToDateTime(Eval("WHRQ")).ToString("yyyy-MM-dd");
  112.     }
  113.     /// <summary>
  114.     /// 维护费用
  115.     /// </summary>
  116.     /// <returns></returns>
  117.     public string WHFY()
  118.     {
  119.         return Convert.ToDecimal(Eval("WHFY").ToString()).ToString("0.00");
  120.     }
  121.     /// <summary>
  122.     /// 操作
  123.     /// </summary>
  124.     /// <returns></returns>
  125.     public string CaoZuo()
  126.     {
  127.         string Id = Eval("Id").ToString();
  128.         //编辑 清空密码 删除
  129.         //string Rtstr = "<a href='ArticlesInfoAdd.aspx'>添加用品</a>&nbsp;&nbsp;";
  130.         //Rtstr += "<a href='ArticlesInfoEditor.aspx?id=" + Id + "'>修改用品</a>&nbsp;&nbsp;";
  131.         string Rtstr = "";
  132.         if (BF.GetCount(TiaoJian) > 0)
  133.         {
  134.             Rtstr = "<a href='MaintenanceEditor.aspx?id=" + Id + "'>修改</a>&nbsp;&nbsp;";
  135.         }
  136.         else
  137.         {
  138.             Rtstr = "还没有维护的车辆!";
  139.         }
  140.         return Rtstr;
  141.     }
  142.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  143.     {
  144.         MyDataBind(e.NewPageIndex);
  145.     }
  146.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  147.     {
  148.         for (int i = 0; i < GridView1.Rows.Count; i++)
  149.         {
  150.             //首先判断是否是数据行
  151.             if (e.Row.RowType == DataControlRowType.DataRow)
  152.             {
  153.                 //当鼠标停留时更改背景色
  154.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  155.                 //当鼠标移开时还原背景色
  156.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  157.             }
  158.         }
  159.     }
  160.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  161.     {
  162.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  163.         {
  164.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  165.             if (CheckBox1.Checked)
  166.             {
  167.                 cbox.Checked = true;
  168.             }
  169.             else
  170.             {
  171.                 cbox.Checked = false;
  172.             }
  173.         }
  174.     }
  175.     protected void DelButton1_Click(object sender, EventArgs e)
  176.     {
  177.         try
  178.         {
  179.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  180.             {
  181.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  182.                 if (cbox.Checked)
  183.                 {
  184.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  185.                     if (Id == 0)
  186.                     {
  187.                         throw new Exception("该记录不能删除!");
  188.                     }
  189.                     BF.Delete(Id);
  190.                 }
  191.                 else
  192.                 {
  193.                 }
  194.             }
  195.             MessageBox.Show("删除完成!");
  196.         }
  197.         catch (Exception exp)
  198.         { MessageBox.Show(exp.Message); }
  199.         MyDataBind(AspNetPager1.CurrentPageIndex);
  200.     }
  201. }