StatusSearchPrjAlert.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:5k
源码类别:

.net编程

开发平台:

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 com.etong.BusinessRule.Zwf;
  12. using com.etong.user;
  13. public partial class SearchP_StatusSearchPrjAlert : System.Web.UI.Page
  14. {
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.         if (!IsPostBack)
  18.         {
  19.             EtongZwf etongzwf = new EtongZwf();
  20.             DataView dv = etongzwf.StatusSearchPrjAlert();      
  21.             this.GridView1.DataSource = dv;
  22.             this.GridView1.DataBind();
  23.         }  
  24.     }
  25.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  26.     {
  27.         int currentpageindex;
  28.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  29.         if (currentpageindex == -2)
  30.         {
  31.             TextBox txtNewPageIndex;
  32.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  33.             if (txtNewPageIndex != null)
  34.             {
  35.                 try
  36.                 {
  37.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  38.                 }
  39.                 catch
  40.                 {
  41.                     currentpageindex = 0;
  42.                 }
  43.             }
  44.         }
  45.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  46.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  47.         GridView1.PageIndex = currentpageindex;
  48.         EtongZwf etongzwf = new EtongZwf();
  49.         DataView dv = etongzwf.StatusSearchPrjAlert();     
  50.         dv.Sort = (string)ViewState["sortFieldName"];
  51.         this.GridView1.DataSource = dv;
  52.         this.GridView1.DataBind();
  53.     }
  54.     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  55.     {
  56.         if (e.CommandName == "save")
  57.         {
  58.             DataKey key = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)];
  59.             int projectid = Convert.ToInt32(key.Value.ToString());
  60.             string sURL = "AllStatus.aspx?ProjectID=" + projectid.ToString() +"&typeid=2";
  61.             Response.Redirect(sURL);
  62.         }
  63.     }  
  64.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  65.     {
  66.         if (e.Row.RowType == DataControlRowType.DataRow)
  67.         {
  68.             int iRow;
  69.             iRow = e.Row.DataItemIndex;
  70.             iRow = iRow % 2;
  71.             if (iRow > 0)
  72.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  73.             else
  74.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  75.             e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
  76.             int state;
  77.             int userid;
  78.             e.Row.Cells[0].Visible = true;
  79.             if (e.Row.Cells[4].Text != null || e.Row.Cells[4].Text != "")
  80.             {
  81.                 try
  82.                 {
  83.                     state = Convert.ToInt32(e.Row.Cells[4].Text);
  84.                 }
  85.                 catch
  86.                 {
  87.                     state = -1;
  88.                 }
  89.                 switch (state)
  90.                 {
  91.                     case 0:
  92.                         e.Row.Cells[4].Text = "正常";
  93.                         break;
  94.                     case 1:
  95.                         e.Row.Cells[4].Text = "项目申请完成";
  96.                         break;
  97.                     case 2:
  98.                         e.Row.Cells[4].Text = "作废";
  99.                         break;
  100.                     case 3:
  101.                         e.Row.Cells[4].Text = "施工";
  102.                         break;
  103.                     case 4:
  104.                         e.Row.Cells[4].Text = "竣工";
  105.                         break;
  106.                     case 5:
  107.                         e.Row.Cells[4].Text = "完成";
  108.                         break;
  109.                     //default:
  110.                     //    e.Row.Cells[6].Text = "未知状态";
  111.                     //    break;
  112.                 }
  113.             }
  114.             if (e.Row.Cells[2].Text != null || e.Row.Cells[2].Text != "")
  115.             {
  116.                 try
  117.                 {
  118.                     userid = Convert.ToInt32(e.Row.Cells[2].Text);
  119.                 }
  120.                 catch
  121.                 {
  122.                     userid = -1;
  123.                 }
  124.                 Notice user = new Notice();
  125.                 string empname = user.GetEmpName(userid);
  126.                 e.Row.Cells[2].Text = empname;
  127.             }
  128.         }
  129.     }   
  130. }