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