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

.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.StatusSearch1();      
  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.StatusSearch1();
  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 = -1;
  68.             int userid;
  69.             //e.Row.Cells[0].Visible = true;
  70.             //HiddenField hid = (HiddenField)e.Row.FindControl("hid");
  71.             //if (hid.Value!=null||hid.Value!="")
  72.             //{
  73.             //    try
  74.             //    {
  75.             //        state = Convert.ToInt32(hid.Value);
  76.             //    }
  77.             //    catch
  78.             //    {
  79.             //        state = -1;
  80.             //    }
  81.             //    switch (state)
  82.             //    {
  83.             //        case 0:
  84.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/green2.gif"; 
  85.             //            break;
  86.             //        case 1:
  87.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/cengse.gif";       
  88.             //            break;
  89.             //        case 2:
  90.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/zise.gif";                        
  91.             //            break;
  92.             //        case 3:
  93.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/blue.gif";                       
  94.             //            break;
  95.             //        case 4:
  96.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/green.gif";
  97.             //            break;
  98.             //        case 5:
  99.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/yellow.gif";
  100.             //            break;
  101.             //        case 6:
  102.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/pink.gif";
  103.             //            break;
  104.             //        case 7:
  105.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/red.gif";
  106.             //            break;
  107.             //        case 8:
  108.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/Dep1.gif";
  109.             //            break;
  110.             //        case 9:
  111.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/Dep3.gif";
  112.             //            break; 
  113.             //        default:
  114.             //            ((Image)e.Row.FindControl("Image1")).ImageUrl = "Images/rizhi.gif";
  115.             //            break;
  116.             // }  
  117.             //if (e.Row.Cells[5].Text != null || e.Row.Cells[5].Text != "")
  118.             //{
  119.             //    try
  120.             //    {
  121.             //        state = Convert.ToInt32(e.Row.Cells[5].Text);
  122.             //    }
  123.             //    catch
  124.             //    {
  125.             //        state = -1;
  126.             //    }
  127.             //    switch (state)
  128.             //    {
  129.             //        case 0:
  130.             //            e.Row.Cells[6].Text = "正常";
  131.             //            break;
  132.             //        case 1:
  133.             //            e.Row.Cells[6].Text = "项目申请完成";
  134.             //            break;
  135.             //        case 2:
  136.             //            e.Row.Cells[6].Text = "作废";
  137.             //            break;
  138.             //        case 3:
  139.             //            e.Row.Cells[6].Text = "施工";
  140.             //            break;
  141.             //        case 4:
  142.             //            e.Row.Cells[6].Text = "竣工";
  143.             //            break;
  144.             //        case 5:
  145.             //            e.Row.Cells[6].Text = "完成";
  146.             //            break;
  147.             //        default:
  148.             //            e.Row.Cells[6].Text = "未知状态";
  149.             //            break;
  150.             //    }
  151.             //}
  152.             if (e.Row.Cells[4].Text != null || e.Row.Cells[4].Text != "")
  153.             {
  154.                 try
  155.                 {
  156.                     state = Convert.ToInt32(e.Row.Cells[4].Text);
  157.                 }
  158.                 catch
  159.                 {
  160.                     state = -1;
  161.                 }
  162.                 switch (state)
  163.                 {
  164.                     case 0:
  165.                         e.Row.Cells[4].Text = "正常";
  166.                         break;
  167.                     case 1:
  168.                         e.Row.Cells[4].Text = "项目申请完成";
  169.                         break;
  170.                     case 2:
  171.                         e.Row.Cells[4].Text = "作废";
  172.                         break;
  173.                     case 3:
  174.                         e.Row.Cells[4].Text = "施工";
  175.                         break;
  176.                     case 4:
  177.                         e.Row.Cells[4].Text = "竣工";
  178.                         break;
  179.                     case 5:
  180.                         e.Row.Cells[4].Text = "完成";
  181.                         break;
  182.                     default:
  183.                         e.Row.Cells[4].Text = "未知状态";
  184.                         break;
  185.                 }
  186.             }
  187.             if (e.Row.Cells[2].Text != null || e.Row.Cells[2].Text != "")
  188.             {
  189.                 try
  190.                 {
  191.                     userid = Convert.ToInt32(e.Row.Cells[2].Text);
  192.                 }
  193.                 catch
  194.                 {
  195.                     userid = -1;
  196.                 }
  197.                 Notice user = new Notice();
  198.                 string empname = user.GetEmpName(userid);
  199.                 e.Row.Cells[2].Text = empname;
  200.             }
  201.         }
  202.     }
  203.        
  204.     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  205.     {
  206.         if (e.CommandName == "save")
  207.         {
  208.             DataKey key = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)];
  209.             int projectid = Convert.ToInt32(key.Value.ToString());
  210.             string sURL = "CheAllStatus.aspx?ProjectID=" + projectid.ToString();
  211.             Response.Redirect(sURL);
  212.             //Session["projectid"] = projectid.ToString();
  213.             //EtongFlyChouWFPrj project = new EtongFlyChouWFPrj();
  214.             //bool returnvalue = etongzwf.UserPwdUpdata(userid);
  215.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script> window.location.href='AllStatus.aspx?ProjectID=" + projectid + "';</script>");
  216.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:密码重置成功,\n          密码为:111111');</script>");
  217.         }
  218.     }  
  219. }