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

.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.DBUtility;
  12. public partial class SearchP_StructureSearch : 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.             string sql = "select * from [tb_construct]";
  23.             if (this.RadioButtonList1.SelectedValue.ToString() == "-1")
  24.             {
  25.                 if (this.RadioButtonList2.SelectedValue.ToString() != "-1")
  26.                 {
  27.                     sql = sql + " where [Status]=" + this.RadioButtonList2.SelectedValue.ToString();
  28.                 }
  29.             }
  30.             else
  31.             {
  32.                 if (this.RadioButtonList2.SelectedValue.ToString() == "-1")
  33.                 {
  34.                     sql = sql + " where [ConSort]=" + this.RadioButtonList1.SelectedValue.ToString();
  35.                 }
  36.                 else
  37.                 {
  38.                     sql = sql + " where [ConSort]=" + this.RadioButtonList1.SelectedValue.ToString() + " and [Status]=" + this.RadioButtonList2.SelectedValue.ToString();
  39.                 }
  40.             }
  41.             DataView dv = SqlServer.GetDataView(sql);
  42.             this.GridView1.DataSource = dv;
  43.             this.GridView1.DataBind();
  44.         }
  45.     }
  46.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  47.     {
  48.         int currentpageindex;
  49.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  50.         if (currentpageindex == -2)
  51.         {
  52.             TextBox txtNewPageIndex;
  53.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  54.             if (txtNewPageIndex != null)
  55.             {
  56.                 try
  57.                 {
  58.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  59.                 }
  60.                 catch
  61.                 {
  62.                     currentpageindex = 0;
  63.                 }
  64.             }
  65.         }
  66.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  67.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  68.         GridView1.PageIndex = currentpageindex;
  69.         string sql = "select * from [tb_construct]";
  70.         if (this.RadioButtonList1.SelectedValue.ToString() == "-1")
  71.         {
  72.             if (this.RadioButtonList2.SelectedValue.ToString() != "-1")
  73.             {
  74.                 sql = sql + " where [Status]=" + this.RadioButtonList2.SelectedValue.ToString();
  75.             }
  76.         }
  77.         else
  78.         {
  79.             if (this.RadioButtonList2.SelectedValue.ToString() == "-1")
  80.             {
  81.                 sql = sql + " where [ConSort]=" + this.RadioButtonList1.SelectedValue.ToString();
  82.             }
  83.             else
  84.             {
  85.                 sql = sql + " where [ConSort]=" + this.RadioButtonList1.SelectedValue.ToString() + " and [Status]=" + this.RadioButtonList2.SelectedValue.ToString();
  86.             }
  87.         }
  88.         DataView dv = SqlServer.GetDataView(sql);
  89.         dv.Sort = (string)ViewState["sortFieldName"];
  90.         this.GridView1.DataSource = dv;
  91.         this.GridView1.DataBind();
  92.     }
  93.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  94.     {
  95.         if (e.Row.RowType == DataControlRowType.DataRow)
  96.         {
  97.             int iRow;
  98.             iRow = e.Row.DataItemIndex;
  99.             iRow = iRow % 2;
  100.             if (iRow > 0)
  101.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  102.             else
  103.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  104.             e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
  105.             int state;
  106.             int consort;
  107.             if (e.Row.Cells[3].Text != null || e.Row.Cells[3].Text != "")
  108.             {
  109.                 try
  110.                 {
  111.                     state = Convert.ToInt32(e.Row.Cells[3].Text);
  112.                 }
  113.                 catch
  114.                 {
  115.                     state = -1;
  116.                 }
  117.                 switch (state)
  118.                 {
  119.                     case 1:
  120.                         e.Row.Cells[3].Text = "正常";
  121.                         break;
  122.                     case 2:
  123.                         e.Row.Cells[3].Text = "施工完成";
  124.                         break;
  125.                     case 3:
  126.                         e.Row.Cells[3].Text = "作废";
  127.                         break;
  128.                     default:
  129.                         e.Row.Cells[7].Text = "未知";
  130.                         break;
  131.                 }
  132.                 try
  133.                 {
  134.                     consort = Convert.ToInt32(e.Row.Cells[2].Text);
  135.                 }
  136.                 catch
  137.                 {
  138.                     consort = -1;
  139.                 }
  140.                 switch (consort)
  141.                 {
  142.                     case 1:
  143.                         e.Row.Cells[2].Text = "生产类";
  144.                         break;
  145.                     case 2:
  146.                         e.Row.Cells[2].Text = "科技类";
  147.                         break;
  148.                     case 3:
  149.                         e.Row.Cells[2].Text = "营销类";
  150.                         break;
  151.                     default:
  152.                         e.Row.Cells[2].Text = "未知";
  153.                         break;
  154.                 }
  155.             }
  156.         }
  157.     }
  158.     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  159.     {
  160.         if (e.CommandName == "save")
  161.         {
  162.             DataKey key = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)];
  163.             int conid = Convert.ToInt32(key.Value.ToString());
  164.             //Session["projectid"] = projectid.ToString();
  165.             //EtongFlyChouWFPrj project = new EtongFlyChouWFPrj();
  166.             //bool returnvalue = etongzwf.UserPwdUpdata(userid);
  167.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script> window.location.href='../Workflow/ProjectImplement.aspx?ConID=" + conid + "';</script>");
  168.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:密码重置成功,\n          密码为:111111');</script>");
  169.         }
  170.     }
  171.     protected void search_Click(object sender, EventArgs e)
  172.     {
  173.         //EtongFlyChouWFPrj project = new EtongFlyChouWFPrj();
  174.         //project.PrjType = Convert.ToInt32(this.RadioButtonList1.SelectedValue.ToString());
  175.         //project.PrjStatus = Convert.ToInt32(this.RadioButtonList2.SelectedValue.ToString());
  176.         //DataView dv = project.PrjQuery();
  177.         //this.GridView1.DataSource = dv;
  178.         //this.GridView1.DataBind();
  179.         string sql = "select * from [tb_construct]";
  180.         if (this.RadioButtonList1.SelectedValue.ToString() == "-1")
  181.         {
  182.             if (this.RadioButtonList2.SelectedValue.ToString() != "-1")
  183.             {
  184.                 sql = sql + " where [Status]=" + this.RadioButtonList2.SelectedValue.ToString();
  185.             }
  186.         }
  187.         else
  188.         {
  189.             if (this.RadioButtonList2.SelectedValue.ToString() == "-1")
  190.             {
  191.                 sql = sql + " where [ConSort]=" + this.RadioButtonList1.SelectedValue.ToString();
  192.             }
  193.             else
  194.             {
  195.                 sql = sql + " where [ConSort]=" + this.RadioButtonList1.SelectedValue.ToString() + " and [Status]=" + this.RadioButtonList2.SelectedValue.ToString();
  196.             }
  197.         }
  198.         DataView dv = SqlServer.GetDataView(sql);
  199.         this.GridView1.DataSource = dv;
  200.         this.GridView1.DataBind();
  201.     }    
  202. }