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

.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.DAL.FC;
  12. public partial class SearchP_ProjectSearch : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             EtongFlyChouWFPrj project = new EtongFlyChouWFPrj();
  19.             project.PrjType = Convert.ToInt32(this.RadioButtonList1.SelectedValue.ToString());
  20.             project.PrjStatus = Convert.ToInt32(this.RadioButtonList2.SelectedValue.ToString());
  21.             DataView dv = project.PrjQuery();
  22.             this.GridView1.DataSource = dv;
  23.             this.GridView1.DataBind();
  24.         }
  25.     }
  26.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  27.     {
  28.         int currentpageindex;
  29.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  30.         if (currentpageindex == -2)
  31.         {
  32.             TextBox txtNewPageIndex;
  33.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  34.             if (txtNewPageIndex != null)
  35.             {
  36.                 try
  37.                 {
  38.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  39.                 }
  40.                 catch
  41.                 {
  42.                     currentpageindex = 0;
  43.                 }
  44.             }
  45.         }
  46.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  47.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  48.         GridView1.PageIndex = currentpageindex;
  49.         EtongFlyChouWFPrj project = new EtongFlyChouWFPrj();
  50.         project.PrjType =Convert.ToInt32(this.RadioButtonList1.SelectedValue.ToString());
  51.         project.PrjStatus = Convert.ToInt32(this.RadioButtonList2.SelectedValue.ToString());
  52.         DataView dv = project.PrjQuery();
  53.         dv.Sort = (string)ViewState["sortFieldName"];
  54.         this.GridView1.DataSource = dv;
  55.         this.GridView1.DataBind();
  56.     }
  57.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  58.     {
  59.         if (e.Row.RowType == DataControlRowType.DataRow)
  60.         {
  61.             int iRow;
  62.             iRow = e.Row.DataItemIndex;
  63.             iRow = iRow % 2;
  64.             if (iRow > 0)
  65.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  66.             else
  67.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  68.             e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
  69.             int state;
  70.             int projectsort;
  71.             if (e.Row.Cells[7].Text != null || e.Row.Cells[7].Text != "")
  72.             {
  73.                 try
  74.                 {
  75.                     state = Convert.ToInt32(e.Row.Cells[7].Text);
  76.                 }
  77.                 catch
  78.                 {
  79.                     state = -1;
  80.                 }
  81.                 switch (state)
  82.                 {
  83.                     case 0:
  84.                         e.Row.Cells[7].Text = "正常";
  85.                         break;
  86.                     case 1:
  87.                         e.Row.Cells[7].Text = "申请完成";
  88.                         break;
  89.                     case 2:
  90.                         e.Row.Cells[7].Text = "作废";
  91.                         break;
  92.                     case 3:
  93.                         e.Row.Cells[7].Text = "施工";
  94.                         break;
  95.                     case 4:
  96.                         e.Row.Cells[7].Text = "竣工";
  97.                         break;
  98.                     case 5:
  99.                         e.Row.Cells[7].Text = "完成";
  100.                         break;
  101.                     default:
  102.                         e.Row.Cells[7].Text = "未知";
  103.                         break;
  104.                 }
  105.                 try
  106.                 {
  107.                     projectsort = Convert.ToInt32(e.Row.Cells[3].Text);
  108.                 }
  109.                 catch
  110.                 {
  111.                     projectsort = -1;
  112.                 }
  113.                 switch (projectsort)
  114.                 {                  
  115.                     case 1:
  116.                         e.Row.Cells[3].Text = "生产类";
  117.                         break;
  118.                     case 2:
  119.                         e.Row.Cells[3].Text = "科技类";
  120.                         break;
  121.                     case 3:
  122.                         e.Row.Cells[3].Text = "营销类";
  123.                         break;                   
  124.                     default:
  125.                         e.Row.Cells[3].Text = "未知";
  126.                         break;
  127.                 }
  128.             }
  129.         }
  130.     }
  131.     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  132.     {
  133.         if (e.CommandName == "save")
  134.         {
  135.             DataKey key = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)];
  136.             int projectid =Convert.ToInt32( key.Value.ToString());
  137.             //Session["projectid"] = projectid.ToString();
  138.             EtongFlyChouWFPrj project = new EtongFlyChouWFPrj();
  139.             //bool returnvalue = etongzwf.UserPwdUpdata(userid);
  140.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script> window.location.href='../Workflow/WFTaskBrowse.aspx?ProjectID=" + projectid+"';</script>");
  141.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:密码重置成功,\n          密码为:111111');</script>");
  142.         }
  143.     }
  144.     protected void search_Click(object sender, EventArgs e)
  145.     {
  146.         EtongFlyChouWFPrj project = new EtongFlyChouWFPrj();
  147.         project.PrjType = Convert.ToInt32(this.RadioButtonList1.SelectedValue.ToString());
  148.         project.PrjStatus = Convert.ToInt32(this.RadioButtonList2.SelectedValue.ToString());
  149.         DataView dv = project.PrjQuery();
  150.         this.GridView1.DataSource = dv;
  151.         this.GridView1.DataBind();
  152.     }    
  153. }