form_list.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:13k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. public partial class web_new_repair_form_list : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         SqlConnection conn = dbConnection.getConnection();
  17.         conn.Open();
  18.         if (!IsPostBack)
  19.         {
  20.             dl_company.Items.Clear();
  21.             dl_company.Items.Add("所有厂商");
  22.             SqlCommand sqlcom1 = new SqlCommand("select company from OA_COMPANY order by id", conn);
  23.             SqlDataReader dr1 = sqlcom1.ExecuteReader();
  24.             if (dr1.HasRows)
  25.             {
  26.                 while (dr1.Read())
  27.                 {
  28.                     dl_company.Items.Add(dr1["company"].ToString());
  29.                 }
  30.             }
  31.             dr1.Close();
  32.             dl_department.Items.Clear();
  33.             dl_department.Items.Add("所有门店");
  34.             SqlCommand sqlcom2 = new SqlCommand("select name FROM OA_DEPARTMENT WHERE (CHARINDEX('店', name) > 0)", conn);
  35.             SqlDataReader dr2 = sqlcom2.ExecuteReader();
  36.             if (dr2.HasRows)
  37.             {
  38.                 while (dr2.Read())
  39.                 {
  40.                     dl_department.Items.Add(dr2["name"].ToString());
  41.                 }
  42.             }
  43.             dr2.Close();
  44.             dl_type.Items.Clear();
  45.             dl_type.Items.Add("所有类型");
  46.             SqlCommand sqlcom3 = new SqlCommand("select type from OA_UNIT_TYPE order by id", conn);
  47.             SqlDataReader dr3 = sqlcom3.ExecuteReader();
  48.             if (dr3.HasRows)
  49.             {
  50.                 while (dr3.Read())
  51.                 {
  52.                     dl_type.Items.Add(dr3["type"].ToString());
  53.                 }
  54.             }
  55.             dr3.Close();
  56.             dl_name.Items.Clear();
  57.             dl_name.Items.Add("所有设备");
  58.             SqlCommand sqlcom = new SqlCommand("select eq_name from OA_UNIT_DETAIL order by id", conn);
  59.             SqlDataReader dr = sqlcom.ExecuteReader();
  60.             if (dr.HasRows)
  61.             {
  62.                 while (dr.Read())
  63.                 {
  64.                     dl_name.Items.Add(dr["eq_name"].ToString());
  65.                 }
  66.             }
  67.             dr.Close();
  68.         }
  69.         conn.Close();
  70.     }
  71.     protected void ApprovelList1_RowCreated(object sender, GridViewRowEventArgs e)
  72.     {
  73.         LinkButton lbRevoke = (LinkButton)e.Row.FindControl("LbRevoke1");
  74.         if (e.Row.RowType == DataControlRowType.DataRow)
  75.         {
  76.             lbRevoke.CommandArgument = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
  77.             lbRevoke.Click += new EventHandler(lbRevoke1_Click);
  78.         }
  79.     }
  80.     public void lbRevoke1_Click(object sender, EventArgs e)
  81.     {
  82.         SqlConnection conn = dbConnection.getConnection();
  83.         conn.Open();
  84.         SqlCommand sqlcom = new SqlCommand("");
  85.     }
  86.     protected void Begindate_SelectionChanged(object sender, EventArgs e)
  87.     {
  88.         Begindate.Visible = false;
  89.         string year = Begindate.SelectedDate.Year.ToString();
  90.         string month = Begindate.SelectedDate.Month.ToString();
  91.         if (month.Length == 1)
  92.         {
  93.             month = "0" + month;
  94.         }
  95.         string day = Begindate.SelectedDate.Day.ToString();
  96.         if (day.Length == 1)
  97.         {
  98.             day = "0" + day;
  99.         }
  100.         b_time.Text = year + month + day + "000000";
  101.         b_time.Focus();
  102.     }
  103.     protected void Enddate_SelectionChanged(object sender, EventArgs e)
  104.     {
  105.         Enddate.Visible = false;
  106.         string year = Enddate.SelectedDate.Year.ToString();
  107.         string month = Enddate.SelectedDate.Month.ToString();
  108.         if (month.Length == 1)
  109.         {
  110.             month = "0" + month;
  111.         }
  112.         string day = Enddate.SelectedDate.Day.ToString();
  113.         if (day.Length == 1)
  114.         {
  115.             day = "0" + day;
  116.         }
  117.         e_time.Text = year + month + day + "000000";
  118.         e_time.Focus();
  119.     }
  120.     protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
  121.     {
  122.         if (Enddate.Visible == true)
  123.         {
  124.             Enddate.Visible = false;
  125.             Enddate.Focus();
  126.         }
  127.         else
  128.         {
  129.             Enddate.Visible = true;
  130.             Enddate.Focus();
  131.         }
  132.     }
  133.     protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  134.     {
  135.         if (Begindate.Visible == true)
  136.         {
  137.             Begindate.Visible = false;
  138.             Begindate.Focus();
  139.         }
  140.         else
  141.         {
  142.             Begindate.Visible = true;
  143.             Begindate.Focus();
  144.         }
  145.     }
  146.     protected void dl_type_SelectedIndexChanged(object sender, EventArgs e)
  147.     {
  148.         SqlConnection conn = dbConnection.getConnection();
  149.         conn.Open();
  150.         if (dl_type.SelectedItem.ToString().Equals("所有类型"))
  151.         {
  152.             dl_name.Items.Clear();
  153.             dl_name.Items.Add("所有设备");
  154.             SqlCommand sqlcom1 = new SqlCommand("select eq_name from OA_UNIT_DETAIL order by id", conn);
  155.             SqlDataReader dr1 = sqlcom1.ExecuteReader();
  156.             if (dr1.HasRows)
  157.             {
  158.                 while (dr1.Read())
  159.                 {
  160.                     dl_name.Items.Add(dr1["eq_name"].ToString());
  161.                 }
  162.             }
  163.             dr1.Close();
  164.         }
  165.         else
  166.         {
  167.             dl_name.Items.Clear();
  168.             dl_name.Items.Add("所有设备");
  169.             SqlCommand sqlcom = new SqlCommand("select eq_name from OA_UNIT_DETAIL where eq_type='" + dl_type.SelectedItem.ToString() + "'", conn);
  170.             SqlDataReader dr = sqlcom.ExecuteReader();
  171.             if (dr.HasRows)
  172.             {
  173.                 while (dr.Read())
  174.                 {
  175.                     dl_name.Items.Add(dr["eq_name"].ToString());
  176.                 }
  177.             }
  178.             dr.Close();
  179.         }
  180.         conn.Close();
  181.     }
  182.     protected void dl_company_SelectedIndexChanged(object sender, EventArgs e)
  183.     {
  184.         SqlConnection conn = dbConnection.getConnection();
  185.         conn.Open();
  186.         dl_type.Items.Clear();
  187.         dl_type.Items.Add("所有类型");
  188.         if (dl_company.SelectedItem.ToString().Equals("所有厂商"))
  189.         {
  190.             SqlCommand sqlcom3 = new SqlCommand("select type from OA_UNIT_TYPE order by id", conn);
  191.             SqlDataReader dr3 = sqlcom3.ExecuteReader();
  192.             if (dr3.HasRows)
  193.             {
  194.                 while (dr3.Read())
  195.                 {
  196.                     dl_type.Items.Add(dr3["type"].ToString());
  197.                 }
  198.             }
  199.             dr3.Close();
  200.         }
  201.         else
  202.         {
  203.             SqlCommand sqlcom = new SqlCommand("select equipment from OA_company where company='" + dl_company.SelectedItem.ToString() + "'", conn);
  204.             SqlDataReader dr = sqlcom.ExecuteReader();
  205.             if (dr.HasRows)
  206.             {
  207.                 while (dr.Read())
  208.                 {
  209.                     dl_type.Items.Add(dr["equipment"].ToString());
  210.                 }
  211.             }
  212.             dr.Close();
  213.         }
  214.         conn.Close();
  215.     }
  216.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  217.     {
  218.         int i;
  219.         //执行循环,保证每条数据都可以更新
  220.         for (i = -1; i < GridView1.Rows.Count; i++)
  221.         {
  222.             //首先判断是否是数据行
  223.             if (e.Row.RowType == DataControlRowType.DataRow)
  224.             {
  225.                 //当鼠标停留时更改背景色
  226.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
  227.                 //当鼠标移开时还原背景色
  228.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  229.                 e.Row.Attributes.Add("onclick", "javascript:varwin=window.open('select.aspx?form_id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() +"',null,'width=800,height=600')");
  230.                 //e.Row.Attributes.Add("onclick", "location.href='select.aspx?form_id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
  231.             }
  232.         }
  233.     }
  234.     public void bind1()
  235.     {
  236.         ArrayList array = new ArrayList();
  237.         MultiView2.ActiveViewIndex = 0;
  238.         SqlConnection conn = dbConnection.getConnection();
  239.         conn.Open();
  240.         DataSet ds = new DataSet();
  241.         DataTable dt = new DataTable();
  242.         dt.Columns.Add("no", typeof(string));
  243.         dt.Columns.Add("form_id", typeof(string));
  244.         dt.Columns.Add("bxperson", typeof(string));
  245.         dt.Columns.Add("level", typeof(string));
  246.         dt.Columns.Add("department", typeof(string));
  247.         dt.Columns.Add("tel", typeof(string));
  248.         dt.Columns.Add("date", typeof(string));
  249.         dt.Columns.Add("lbperson", typeof(string));
  250.         dt.Columns.Add("type", typeof(string));
  251.         dt.Columns.Add("equipment", typeof(string));
  252.         dt.Columns.Add("comment", typeof(string));
  253.         dt.Columns.Add("company", typeof(string));
  254.         dt.Columns.Add("destine_time", typeof(string));
  255.         dt.Columns.Add("complete_time", typeof(string));
  256.         dt.Columns.Add("confirm", typeof(string));
  257.         dt.Columns.Add("remark", typeof(string));
  258.         string sqlstr = "select  f.area as area,f.level as level,f.bxperson as bxperson,f.form_id as form_id,f.department as department,f.lbperson as lbperson,f.type as type,f.equipment as equipment,f.comment as comment,f.create_time as create_time,g.company as company,g.destine_time as destine_time,g.complete_time as complete_time,g.confirm as confirm,g.remark as remark from oa_repair as f,oa_repair_d as g where g.form_id=f.form_id";
  259.         if (!dl_department.SelectedItem.ToString().Equals("所有门店"))
  260.         {
  261.             sqlstr = sqlstr + " and f.department='" + dl_department.SelectedItem.ToString()+"'";
  262.         }
  263.         if (!dl_company.SelectedItem.ToString().Equals("所有厂商"))
  264.         {
  265.             sqlstr = sqlstr + " and g.company='" + dl_company.SelectedItem.ToString()+"'";
  266.         }
  267.         if (!dl_type.SelectedItem.ToString().Equals("所有类型"))
  268.         {
  269.             sqlstr = sqlstr + " and f.type='" + dl_type.SelectedItem.ToString()+"'";
  270.         }
  271.         if (!dl_name.SelectedItem.ToString().Equals("所有设备"))
  272.         {
  273.             sqlstr = sqlstr + " and f.equipment='" + dl_name.SelectedItem.ToString()+"'";
  274.         }
  275.         if ((!b_time.Text.Equals("")) && (!e_time.Text.Equals("")))
  276.         {
  277.             sqlstr = sqlstr + " and f.form_id between '" + b_time.Text.ToString().Trim() + "' and '" + e_time.Text.ToString() + "'";
  278.         }
  279.         sqlstr = sqlstr + " order by form_id desc";
  280.         SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  281.         SqlDataReader dr = sqlcom.ExecuteReader();
  282.         if (dr.HasRows)
  283.         {
  284.             while (dr.Read())
  285.             {
  286.                 DataRow row = dt.NewRow();
  287.                 row["no"] = dr["area"].ToString().Trim();
  288.                 row["bxperson"] = dr["bxperson"].ToString().Trim();
  289.                 row["level"] = dr["level"].ToString().Trim();
  290.                 row["form_id"] = dr["form_id"].ToString();
  291.                 array.Add(dr["form_id"].ToString());
  292.                 row["department"] = dr["department"].ToString();
  293.                 SqlConnection conn1 = dbConnection.getConnection();
  294.                 conn1.Open();
  295.                 SqlCommand sqlcom2 = new SqlCommand("select tel from oa_department where name='" + dr["department"] + "'", conn1);
  296.                 SqlDataReader dr2 = sqlcom2.ExecuteReader();
  297.                 if (dr2.HasRows)
  298.                 {
  299.                     while (dr2.Read())
  300.                     {
  301.                         row["tel"] = dr2["tel"].ToString();
  302.                     }
  303.                 }
  304.                 dr2.Close();
  305.                 row["date"] = dr["create_time"].ToString();
  306.                 SqlCommand sqlcom1 = new SqlCommand("select emp_name from oa_employee where id='" + dr["lbperson"].ToString().Trim() + "'", conn1);
  307.                 SqlDataReader dr1 = sqlcom1.ExecuteReader();
  308.                 if (dr1.HasRows)
  309.                 {
  310.                     while (dr1.Read())
  311.                     {
  312.                         row["lbperson"] = dr1["emp_name"].ToString();
  313.                     }
  314.             }
  315.                 dr1.Close();
  316.                 row["type"] = dr["type"].ToString();
  317.                 row["equipment"] = dr["equipment"].ToString();
  318.                 row["comment"] = dr["comment"].ToString();
  319.                 row["company"] = dr["company"].ToString();
  320.                 row["destine_time"] = dr["destine_time"].ToString();
  321.                 row["complete_time"] = dr["complete_time"].ToString();
  322.                 row["confirm"] = dr["confirm"].ToString();
  323.                 row["remark"] = dr["remark"].ToString();
  324.                 dt.Rows.Add(row);
  325.                 conn1.Close();
  326.             }
  327.         }
  328.         dr.Close();
  329.         conn.Close();
  330.         ds.Tables.Add(dt);
  331.         GridView1.DataSource = ds;
  332.         GridView1.DataKeyNames = new string[] { "form_id" };
  333.         GridView1.DataBind();
  334.         Session["s"] = array;
  335.     }
  336.     protected void Button1_Click(object sender, EventArgs e)
  337.     {
  338.         bind1();
  339.     }
  340. }