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

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_data_repair_select_select_index : 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 where eq_type='" + dl_type.SelectedValue.ToString() + "'", 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 Begindate_SelectionChanged(object sender, EventArgs e)
  72.     {
  73.         Begindate.Visible = false;
  74.         string year = Begindate.SelectedDate.Year.ToString();
  75.         string month = Begindate.SelectedDate.Month.ToString();
  76.         if (month.Length == 1)
  77.         {
  78.             month = "0" + month;
  79.         }
  80.         string day = Begindate.SelectedDate.Day.ToString();
  81.         if (day.Length == 1)
  82.         {
  83.             day = "0" + day;
  84.         }
  85.         b_time.Text = year + month + day + "000000";
  86.         b_time.Focus();
  87.     }
  88.     protected void Enddate_SelectionChanged(object sender, EventArgs e)
  89.     {
  90.         Enddate.Visible = false;
  91.         string year = Enddate.SelectedDate.Year.ToString();
  92.         string month = Enddate.SelectedDate.Month.ToString();
  93.         if (month.Length == 1)
  94.         {
  95.             month = "0" + month;
  96.         }
  97.         string day = Enddate.SelectedDate.Day.ToString();
  98.         if (day.Length == 1)
  99.         {
  100.             day = "0" + day;
  101.         }
  102.         e_time.Text = year + month + day + "000000";
  103.         e_time.Focus();
  104.     }
  105.     protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
  106.     {
  107.         if (Enddate.Visible == true)
  108.         {
  109.             Enddate.Visible = false;
  110.             Enddate.Focus();
  111.         }
  112.         else
  113.         {
  114.             Enddate.Visible = true;
  115.             Enddate.Focus();
  116.         }
  117.     }
  118.     protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  119.     {
  120.         if (Begindate.Visible == true)
  121.         {
  122.             Begindate.Visible = false;
  123.             Begindate.Focus();
  124.         }
  125.         else
  126.         {
  127.             Begindate.Visible = true;
  128.             Begindate.Focus();
  129.         }
  130.     }
  131.     protected void btn_ok_Click(object sender, EventArgs e)
  132.     {
  133.         string str = DropDownList2.SelectedItem.ToString();
  134.         if (str.Equals("按厂商查询"))
  135.         {
  136.             MultiView2.ActiveViewIndex = 0;
  137.             bind1();
  138.         }
  139.         else if (str.Equals("按门店查询"))
  140.         {
  141.             MultiView2.ActiveViewIndex = 1;
  142.             bind2();
  143.         }
  144.         else if (str.Equals("按设备-厂商查询"))
  145.         {
  146.             MultiView2.ActiveViewIndex = 2;
  147.             bind3();
  148.         }
  149.         else if (str.Equals("按设备-门店查询"))
  150.         {
  151.             MultiView2.ActiveViewIndex = 3;
  152.             bind4();
  153.         }
  154.         else
  155.         {
  156.         }
  157.     }
  158.     public string SetTime(string s)
  159.     {
  160.         string year = "";
  161.         string month = "";
  162.         string day = "";
  163.         string hour = "";
  164.         string minite = "";
  165.         string second = "";
  166.         if (s.Length == 14)
  167.         {
  168.             year = s.Substring(0, 4).ToString();
  169.             month = s.Substring(4, 2).ToString();
  170.             day = s.Substring(6, 2).ToString();
  171.             hour = s.Substring(8, 2).ToString();
  172.             minite = s.Substring(10, 2).ToString();
  173.             second = s.Substring(12, 2).ToString();
  174.             return year + "-" + month + "-" + day + " " + hour + ":" + minite + ":" + second;
  175.         }
  176.         else
  177.         {
  178.             return s;
  179.         }
  180.     }
  181.     protected void dl_type_SelectedIndexChanged(object sender, EventArgs e)
  182.     {
  183.         SqlConnection conn = dbConnection.getConnection();
  184.         conn.Open();
  185.         dl_name.Items.Clear();
  186.         dl_name.Items.Add("所有设备");
  187.         SqlCommand sqlcom = new SqlCommand("select eq_name from OA_UNIT_DETAIL where eq_type='" + dl_type.SelectedItem.ToString() + "'", conn);
  188.         SqlDataReader dr = sqlcom.ExecuteReader();
  189.         if (dr.HasRows)
  190.         {
  191.             while (dr.Read())
  192.             {
  193.                 dl_name.Items.Add(dr["eq_name"].ToString());
  194.             }
  195.         }
  196.         dr.Close();
  197.         conn.Close();
  198.     }
  199.     protected void ShowMessageBox(string strMessage)
  200.     {
  201.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  202.     }
  203.     protected void bind1()
  204.     {
  205.         string str = dl_company.SelectedItem.ToString();
  206.         string str_department = dl_department.SelectedItem.ToString();
  207.         string str_type = dl_type.SelectedItem.ToString();
  208.         string str_name = dl_name.SelectedItem.ToString();
  209.         string str_b_time = b_time.Text.ToString();
  210.         string str_e_time = e_time.ToString();
  211.         string sqlstr = "select id,company from OA_COMPANY  where company='" + str + "'";
  212.         SqlConnection conn = dbConnection.getConnection();
  213.         conn.Open();
  214.         DataSet ds = new DataSet();
  215.         DataTable dt = new DataTable();
  216.         dt.Columns.Add("id", typeof(Int32));
  217.         dt.Columns.Add("company", typeof(string));
  218.         dt.Columns.Add("num", typeof(Int32));
  219.         if (str.Equals("所有厂商"))
  220.         {
  221.             sqlstr = "select id,company from OA_COMPANY order by id";
  222.         }
  223.         SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  224.         SqlDataReader dr = sqlcom.ExecuteReader();
  225.         if (dr.HasRows)
  226.         {
  227.             while (dr.Read())
  228.             {
  229.                 SqlConnection conn1 = dbConnection.getConnection();
  230.                 conn1.Open();
  231.                 string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where company='" + dr["company"].ToString() + "'";
  232.                 if (!(str_department.Equals("所有门店")))
  233.                 {
  234.                     SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  235.                     SqlDataReader dr2 = sqlcom2.ExecuteReader();
  236.                     if (dr2.HasRows)
  237.                     {
  238.                         while (dr2.Read())
  239.                         {
  240.                             sqlstr1 = sqlstr1 + " and department_id=" + Convert.ToInt32(dr2["id"]);
  241.                         }
  242.                     }
  243.                     dr2.Close();
  244.                 }
  245.                 if (!(str_type.Equals("所有类型")))
  246.                 {
  247.                     sqlstr1 = sqlstr1 + " and eq_type='" + str_type + "'";
  248.                 }
  249.                 if (!(str_name.Equals("所有设备")))
  250.                 {
  251.                     sqlstr1 = sqlstr1 + " and eq_detail='" + str_name + "'";
  252.                 }
  253.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  254.                 {
  255.                     sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  256.                 }
  257.                 SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  258.                 SqlDataReader dr1 = sqlcom1.ExecuteReader();
  259.                 if (dr1.HasRows)
  260.                 {
  261.                     while (dr1.Read())
  262.                     {
  263.                         if (Convert.ToInt32(dr1["num"]) > 0)
  264.                         {
  265.                             DataRow row = dt.NewRow();
  266.                             row["id"] = Convert.ToInt32(dr["id"]);
  267.                             row["company"] = dr["company"].ToString();
  268.                             row["num"] = Convert.ToInt32(dr1["num"]);
  269.                             dt.Rows.Add(row);
  270.                         }
  271.                     }
  272.                 }
  273.                 dr1.Close();
  274.                 conn1.Close();
  275.             }
  276.         }
  277.         dr.Close();
  278.         conn.Close();
  279.         ds.Tables.Add(dt);
  280.         gvParent.DataSource = ds;
  281.         gvParent.DataBind();
  282.         gvParent.DataKeyNames = new string[] { "company" };
  283.     }
  284.     protected void gvParent_RowDataBound(object sender, GridViewRowEventArgs e)
  285.     {
  286.         if (e.Row.RowType == DataControlRowType.DataRow)
  287.         {
  288.             GridView oGridView = (GridView)e.Row.FindControl("gvChild");
  289.             if (oGridView != null)
  290.             {
  291.                 string str_company = dl_company.SelectedItem.ToString();
  292.                 string str_department = dl_department.SelectedItem.ToString();
  293.                 string str_type = dl_type.SelectedItem.ToString();
  294.                 string str_name = dl_name.SelectedItem.ToString();
  295.                 string str_b_time = b_time.Text.ToString();
  296.                 string str_e_time = e_time.ToString();
  297.                 string sqlstr = "select id,type from OA_UNIT_TYPE where type='" + str_type + "'";
  298.                 if (str_type.Equals("所有类型"))
  299.                 {
  300.                     sqlstr = "select id,type from OA_UNIT_TYPE";
  301.                 }
  302.                 Label lblID = (Label)e.Row.FindControl("lb1_ID");
  303.                 SqlConnection conn = dbConnection.getConnection();
  304.                 conn.Open();
  305.                 DataSet ds = new DataSet();
  306.                 DataTable dt = new DataTable();
  307.                 dt.Columns.Add("id", typeof(Int32));
  308.                 dt.Columns.Add("type", typeof(string));
  309.                 dt.Columns.Add("num", typeof(Int32));
  310.                 dt.Columns.Add("company", typeof(string));
  311.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  312.                 SqlDataReader dr = sqlcom.ExecuteReader();
  313.                 if (dr.HasRows)
  314.                 {
  315.                     while (dr.Read())
  316.                     {
  317.                         SqlConnection conn1 = dbConnection.getConnection();
  318.                         conn1.Open();
  319.                         string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where company='" + lblID.Text + "' and eq_type='" + dr["type"].ToString() + "'";
  320.                         if (!(str_department.Equals("所有门店")))
  321.                         {
  322.                             SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  323.                             SqlDataReader dr2 = sqlcom2.ExecuteReader();
  324.                             if (dr2.HasRows)
  325.                             {
  326.                                 while (dr2.Read())
  327.                                 {
  328.                                     sqlstr1 = sqlstr1 + " and department_id=" + Convert.ToInt32(dr2["id"]);
  329.                                 }
  330.                             }
  331.                             dr2.Close();
  332.                         }
  333.                         if (!(str_name.Equals("所有设备")))
  334.                         {
  335.                             sqlstr1 = sqlstr1 + " and eq_detail='" + str_name + "'";
  336.                         }
  337.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  338.                         {
  339.                             sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  340.                         }
  341.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  342.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  343.                         if (dr1.HasRows)
  344.                         {
  345.                             while (dr1.Read())
  346.                             {
  347.                                 if ((Convert.ToInt32(dr1["num"])) != 0)
  348.                                 {
  349.                                     DataRow row = dt.NewRow();
  350.                                     row["id"] = Convert.ToInt32(dr["id"]);
  351.                                     row["type"] = dr["type"].ToString();
  352.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  353.                                     row["company"] = lblID.Text;
  354.                                     dt.Rows.Add(row);
  355.                                 }
  356.                             }
  357.                         }
  358.                         dr1.Close();
  359.                         conn1.Close();
  360.                     }
  361.                 }
  362.                 ds.Tables.Add(dt);
  363.                 dr.Close();
  364.                 conn.Close();
  365.                 oGridView.DataSource = ds;
  366.                 oGridView.DataBind();
  367.                 oGridView.DataKeyNames = new string[] { "type", "company" };
  368.             }
  369.         }
  370.     }
  371.     protected void gvChild_RowDataBound(object sender, GridViewRowEventArgs e)
  372.     {
  373.         if (e.Row.RowType == DataControlRowType.DataRow)
  374.         {
  375.             GridView oGridView = (GridView)e.Row.FindControl("gvthird");
  376.             if (oGridView != null)
  377.             {
  378.                 Label lbltype = (Label)e.Row.FindControl("lb2_type");
  379.                 Label lblcompany = (Label)e.Row.FindControl("lb2_company");
  380.                 string str_company = dl_company.SelectedItem.ToString();
  381.                 string str_department = dl_department.SelectedItem.ToString();
  382.                 string str_type = dl_type.SelectedItem.ToString();
  383.                 string str_name = dl_name.SelectedItem.ToString();
  384.                 string str_b_time = b_time.Text.ToString();
  385.                 string str_e_time = e_time.ToString();
  386.                 string sqlstr = "select id,eq_name from OA_UNIT_DETAIL where eq_name='" + str_name + "' and eq_type='" + lbltype.Text.ToString() + "'";
  387.                 if (dl_name.SelectedItem.ToString().Equals("所有设备"))
  388.                 {
  389.                     sqlstr = "select id, eq_name from OA_UNIT_DETAIL where eq_type='" + lbltype.Text + "'";
  390.                 }
  391.                 else if (dl_type.SelectedItem.ToString().Equals("所有类型"))
  392.                 {
  393.                     sqlstr = "select id,eq_name from OA_UNIT_DETAIL where eq_type='" + lbltype.Text + "'";
  394.                 }
  395.                 else
  396.                 {
  397.                 }
  398.                 SqlConnection conn = dbConnection.getConnection();
  399.                 conn.Open();
  400.                 DataSet ds = new DataSet();
  401.                 DataTable dt = new DataTable();
  402.                 dt.Columns.Add("id", typeof(Int32));
  403.                 dt.Columns.Add("eq_detail", typeof(string));
  404.                 dt.Columns.Add("num", typeof(string));
  405.                 dt.Columns.Add("type", typeof(string));
  406.                 dt.Columns.Add("company", typeof(string));
  407.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  408.                 SqlDataReader dr = sqlcom.ExecuteReader();
  409.                 if (dr.HasRows)
  410.                 {
  411.                     while (dr.Read())
  412.                     {
  413.                         SqlConnection conn1 = dbConnection.getConnection();
  414.                         conn1.Open();
  415.                         string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + lbltype.Text + "'and eq_detail='" + dr["eq_name"].ToString() + "'and company='" + lblcompany.Text + "'";
  416.                         if (!(str_department.Equals("所有门店")))
  417.                         {
  418.                             SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  419.                             SqlDataReader dr2 = sqlcom2.ExecuteReader();
  420.                             if (dr2.HasRows)
  421.                             {
  422.                                 while (dr2.Read())
  423.                                 {
  424.                                     sqlstr1 = sqlstr1 + " and department_id=" + Convert.ToInt32(dr2["id"]);
  425.                                 }
  426.                             }
  427.                             dr2.Close();
  428.                         }
  429.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  430.                         {
  431.                             sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  432.                         }
  433.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  434.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  435.                         if (dr1.HasRows)
  436.                         {
  437.                             while (dr1.Read())
  438.                             {
  439.                                 if (Convert.ToInt32(dr1["num"]) != 0)
  440.                                 {
  441.                                     DataRow row = dt.NewRow();
  442.                                     row["type"] = lbltype.Text;
  443.                                     row["company"] = lblcompany.Text;
  444.                                     row["id"] = Convert.ToInt32(dr["id"]);
  445.                                     row["eq_detail"] = dr["eq_name"].ToString();
  446.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  447.                                     dt.Rows.Add(row);
  448.                                 }
  449.                             }
  450.                         }
  451.                         dr1.Close();
  452.                         conn1.Close();
  453.                     }
  454.                 }
  455.                 ds.Tables.Add(dt);
  456.                 dr.Close();
  457.                 conn.Close();
  458.                 oGridView.DataSource = ds;
  459.                 oGridView.DataBind();
  460.             }
  461.         }
  462.     }
  463.     protected void gvthird_RowDataBound(object sender, GridViewRowEventArgs e)
  464.     {
  465.         if (e.Row.RowType == DataControlRowType.DataRow)
  466.         {
  467.             GridView oGridView = (GridView)e.Row.FindControl("gvfourth");
  468.             if (oGridView != null)
  469.             {
  470.                 Label lblname = (Label)e.Row.FindControl("lb3_detail");
  471.                 Label lbltype = (Label)e.Row.FindControl("lb3_type");
  472.                 Label lblcompany = (Label)e.Row.FindControl("lb3_company");
  473.                 string str_b_time = b_time.Text.ToString();
  474.                 string str_e_time = e_time.ToString();
  475.                 string str = dl_department.SelectedItem.ToString();
  476.                 string sqlstr = "select id,name from OA_DEPARTMENT WHERE name='" + str + "'";
  477.                 if (str.Equals("所有门店"))
  478.                 {
  479.                     sqlstr = "SELECT id, name FROM OA_DEPARTMENT WHERE (CHARINDEX('店', name) > 0)";
  480.                 }
  481.                 SqlConnection conn = dbConnection.getConnection();
  482.                 conn.Open();
  483.                 DataSet ds = new DataSet();
  484.                 DataTable dt = new DataTable();
  485.                 dt.Columns.Add("id", typeof(Int32));
  486.                 dt.Columns.Add("name", typeof(string));
  487.                 dt.Columns.Add("eq_detail", typeof(string));
  488.                 dt.Columns.Add("eq_type", typeof(string));
  489.                 dt.Columns.Add("eq_company", typeof(string));
  490.                 dt.Columns.Add("num", typeof(Int32));
  491.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  492.                 SqlDataReader dr = sqlcom.ExecuteReader();
  493.                 if (dr.HasRows)
  494.                 {
  495.                     while (dr.Read())
  496.                     {
  497.                         SqlConnection conn1 = dbConnection.getConnection();
  498.                         conn1.Open();
  499.                         string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where department_id=" + Convert.ToInt32(dr["id"]) + " and eq_type='" + lbltype.Text + "'and eq_detail='" + lblname.Text + "'and company='" + lblcompany.Text + "'";
  500.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  501.                         {
  502.                             sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  503.                         }
  504.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  505.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  506.                         if (dr1.HasRows)
  507.                         {
  508.                             while (dr1.Read())
  509.                             {
  510.                                 if ((Convert.ToInt32(dr1["num"])) != 0)
  511.                                 {
  512.                                     DataRow row = dt.NewRow();
  513.                                     row["id"] = Convert.ToInt32(dr["id"]);
  514.                                     row["name"] = dr["name"].ToString();
  515.                                     row["eq_detail"] = lblname.Text;
  516.                                     row["eq_type"] = lbltype.Text;
  517.                                     row["eq_company"] = lblcompany.Text;
  518.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  519.                                     dt.Rows.Add(row);
  520.                                 }
  521.                             }
  522.                         }
  523.                         dr1.Close();
  524.                         conn1.Close();
  525.                     }
  526.                 }
  527.                 ds.Tables.Add(dt);
  528.                 dr.Close();
  529.                 conn.Close();
  530.                 oGridView.DataSource = ds;
  531.                 oGridView.DataBind();
  532.             }
  533.         }
  534.     }
  535.     protected void gvfourth_RowDataBound(object sender, GridViewRowEventArgs e)
  536.     {
  537.         if (e.Row.RowType == DataControlRowType.DataRow)
  538.         {
  539.             GridView oGridView = (GridView)e.Row.FindControl("gvdetail");
  540.             if (oGridView != null)
  541.             {
  542.                 Label lblname = (Label)e.Row.FindControl("lb4_detail");
  543.                 Label lbltype = (Label)e.Row.FindControl("lb4_type");
  544.                 Label lblcompany = (Label)e.Row.FindControl("lb4_company");
  545.                 Label lblid = (Label)e.Row.FindControl("lb4_id");
  546.                 string str_b_time = b_time.Text.ToString();
  547.                 string str_e_time = e_time.ToString();
  548.                 int step = 1;
  549.                 DataSet ds = new DataSet();
  550.                 DataTable dt = new DataTable();
  551.                 dt.Columns.Add(new DataColumn("form_id", typeof(string)));
  552.                 dt.Columns.Add(new DataColumn("department", typeof(string)));
  553.                 dt.Columns.Add(new DataColumn("apply_time", typeof(string)));
  554.                 dt.Columns.Add(new DataColumn("emp_name", typeof(string)));
  555.                 dt.Columns.Add(new DataColumn("eq_type", typeof(string)));
  556.                 dt.Columns.Add(new DataColumn("eq_detail", typeof(string)));
  557.                 dt.Columns.Add(new DataColumn("company", typeof(string)));
  558.                 dt.Columns.Add(new DataColumn("content", typeof(string)));
  559.                 dt.Columns.Add(new DataColumn("check_md", typeof(string)));
  560.                 dt.Columns.Add(new DataColumn("check_company", typeof(string)));
  561.                 dt.Columns.Add(new DataColumn("comment", typeof(string)));
  562.                 dt.Columns.Add(new DataColumn("check_time", typeof(string)));
  563.                 SqlConnection conn = dbConnection.getConnection();
  564.                 conn.Open();
  565.                 string sqlstr = "select a.form_id as form_id,c.emp_name as emp_name,a.eq_type as eq_type,a.eq_detail as eq_detail,a.company as company,a.content as content from OA_REPAIR_FORM_DETAIL as a,OA_REPAIR_FORM as b,OA_EMPLOYEE as c where b.form_id=a.form_id and b.emp_id=c.id and a.department_id='" + lblid.Text + "' and a.eq_type='" + lbltype.Text + "' and a.eq_detail='" + lblname.Text + "' and a.company='" + lblcompany.Text + "'";
  566.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  567.                 {
  568.                     sqlstr = sqlstr + " and (a.form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  569.                 }
  570.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  571.                 SqlDataReader dr1 = sqlcom.ExecuteReader();
  572.                 if (dr1.HasRows)
  573.                 {
  574.                     while (dr1.Read())
  575.                     {
  576.                         DataRow row = dt.NewRow();
  577.                         row["form_id"] = dr1["form_id"].ToString();
  578.                         row["emp_name"] = dr1["emp_name"].ToString();
  579.                         row["eq_type"] = dr1["eq_type"].ToString();
  580.                         row["eq_detail"] = dr1["eq_detail"].ToString();
  581.                         row["company"] = dr1["company"].ToString();
  582.                         row["content"] = dr1["content"].ToString();
  583.                         row["apply_time"] = SetTime(dr1["form_id"].ToString());
  584.                         SqlConnection conn1 = dbConnection.getConnection();
  585.                         conn1.Open();
  586.                         SqlCommand sqlcom5 = new SqlCommand("select name from OA_DEPARTMENT where id='" + lblid.Text + "'", conn1);
  587.                         SqlDataReader dr5 = sqlcom5.ExecuteReader();
  588.                         if (dr5.HasRows)
  589.                         {
  590.                             while (dr5.Read())
  591.                             {
  592.                                 row["department"] = dr5["name"].ToString();
  593.                             }
  594.                         }
  595.                         dr5.Close();
  596.                         SqlCommand sqlcom1 = new SqlCommand("select max(step) as step from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'", conn1);
  597.                         SqlDataReader dr4 = sqlcom1.ExecuteReader();
  598.                         if (dr4.HasRows)
  599.                         {
  600.                             while (dr4.Read())
  601.                             {
  602.                                 if (!(dr4["step"].ToString().Equals("")))
  603.                                 {
  604.                                     step = Convert.ToInt32(dr4["step"]);
  605.                                 }
  606.                             }
  607.                         }
  608.                         dr4.Close();
  609.                         SqlCommand sqlcom2 = new SqlCommand("select is_agree from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'and step=" + step, conn1);
  610.                         SqlDataReader dr2 = sqlcom2.ExecuteReader();
  611.                         if (dr2.HasRows)
  612.                         {
  613.                             while (dr2.Read())
  614.                             {
  615.                                 if (dr2["is_agree"].ToString().Equals("Y"))
  616.                                 {
  617.                                     row["check_md"] = "已完工";
  618.                                 }
  619.                                 else if (dr2["is_agree"].ToString().Equals("N"))
  620.                                 {
  621.                                     row["check_md"] = "未处理";
  622.                                 }
  623.                                 else
  624.                                 {
  625.                                     row["check_md"] = "";
  626.                                 }
  627.                             }
  628.                         }
  629.                         dr2.Close();
  630.                         SqlCommand sqlcom3 = new SqlCommand("select is_agree,comment,check_time from OA_COMPANY_CHECK where form_id='" + dr1["form_id"].ToString() + "' and company='" + dr1["company"].ToString() + "'", conn1);
  631.                         SqlDataReader dr3 = sqlcom3.ExecuteReader();
  632.                         if (dr3.HasRows)
  633.                         {
  634.                             while (dr3.Read())
  635.                             {
  636.                                 if (dr3["is_agree"].ToString().Equals("Y"))
  637.                                 {
  638.                                     row["check_company"] = "已完工";
  639.                                 }
  640.                                 else if (dr3["is_agree"].ToString().Equals("N"))
  641.                                 {
  642.                                     row["check_company"] = "未处理";
  643.                                 }
  644.                                 else
  645.                                 {
  646.                                     row["check_company"] = "";
  647.                                 }
  648.                                 row["comment"] = dr3["comment"].ToString().Replace("/n", "<br>").ToString();
  649.                                 row["check_time"] = SetTime(dr3["check_time"].ToString());
  650.                             }
  651.                         }
  652.                         dr3.Close();
  653.                         conn1.Close();
  654.                         dt.Rows.Add(row);
  655.                     }
  656.                 }
  657.                 ds.Tables.Add(dt);
  658.                 oGridView.DataSource = ds;
  659.                 oGridView.DataBind();
  660.                 dr1.Close();
  661.                 conn.Close();
  662.             }
  663.         }
  664.     }
  665.     protected void bind2()
  666.     {
  667.         string str_company = dl_company.SelectedItem.ToString();
  668.         string str_department = dl_department.SelectedItem.ToString();
  669.         string str_type = dl_type.SelectedItem.ToString();
  670.         string str_name = dl_name.SelectedItem.ToString();
  671.         string str_b_time = b_time.Text.ToString();
  672.         string str_e_time = e_time.ToString();
  673.         SqlConnection conn = dbConnection.getConnection();
  674.         conn.Open();
  675.         DataSet ds = new DataSet();
  676.         DataTable dt = new DataTable();
  677.         dt.Columns.Add("id", typeof(Int32));
  678.         dt.Columns.Add("department", typeof(string));
  679.         dt.Columns.Add("num", typeof(Int32));
  680.         string sqlstr = "select id,name from OA_DEPARTMENT where name='" + str_department + "'";
  681.         if (str_department.Equals("所有门店"))
  682.         {
  683.             sqlstr = "SELECT id, name FROM OA_DEPARTMENT WHERE (CHARINDEX('店', name) > 0)";
  684.         }
  685.         SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  686.         SqlDataReader dr = sqlcom.ExecuteReader();
  687.         if (dr.HasRows)
  688.         {
  689.             while (dr.Read())
  690.             {
  691.                 SqlConnection conn1 = dbConnection.getConnection();
  692.                 conn1.Open();
  693.                 string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where department_id=" + Convert.ToInt32(dr["id"]);
  694.                 if (!(str_company.Equals("所有厂商")))
  695.                 {
  696.                     sqlstr1 = sqlstr1 + " and company='" + str_company + "'";
  697.                 }
  698.                 if (!(str_type.Equals("所有类型")))
  699.                 {
  700.                     sqlstr1 = sqlstr1 + " and eq_type='" + str_type + "'";
  701.                 }
  702.                 if (!(str_name.Equals("所有设备")))
  703.                 {
  704.                     sqlstr1 = sqlstr1 + " and eq_detail='" + str_name + "'";
  705.                 }
  706.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  707.                 {
  708.                     sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  709.                 }
  710.                 SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  711.                 SqlDataReader dr1 = sqlcom1.ExecuteReader();
  712.                 if (dr1.HasRows)
  713.                 {
  714.                     while (dr1.Read())
  715.                     {
  716.                         if (Convert.ToInt32(dr1["num"]) > 0)
  717.                         {
  718.                             DataRow row = dt.NewRow();
  719.                             row["id"] = Convert.ToInt32(dr["id"]);
  720.                             row["department"] = dr["name"].ToString();
  721.                             row["num"] = Convert.ToInt32(dr1["num"]);
  722.                             dt.Rows.Add(row);
  723.                         }
  724.                     }
  725.                 }
  726.                 dr1.Close();
  727.                 conn1.Close();
  728.             }
  729.         }
  730.         ds.Tables.Add(dt);
  731.         dr.Close();
  732.         conn.Close();
  733.         gvParent1.DataSource = ds;
  734.         gvParent1.DataBind();
  735.     }
  736.     protected void gvParent1_RowDataBound(object sender, GridViewRowEventArgs e)
  737.     {
  738.         if (e.Row.RowType == DataControlRowType.DataRow)
  739.         {
  740.             GridView oGridView = (GridView)e.Row.FindControl("gvChild1");
  741.             if (oGridView != null)
  742.             {
  743.                 string str_company = dl_company.SelectedItem.ToString();
  744.                 string str_department = dl_department.SelectedItem.ToString();
  745.                 string str_type = dl_type.SelectedItem.ToString();
  746.                 string str_name = dl_name.SelectedItem.ToString();
  747.                 string str_b_time = b_time.Text.ToString();
  748.                 string str_e_time = e_time.ToString();
  749.                 string sqlstr = "select id,type from OA_UNIT_TYPE where type='" + str_type + "'";
  750.                 if (str_type.Equals("所有类型"))
  751.                 {
  752.                     sqlstr = "select id,type from OA_UNIT_TYPE";
  753.                 }
  754.                 Label lblID = (Label)e.Row.FindControl("lbl1_ID");
  755.                 SqlConnection conn = dbConnection.getConnection();
  756.                 conn.Open();
  757.                 DataSet ds = new DataSet();
  758.                 DataTable dt = new DataTable();
  759.                 dt.Columns.Add("id", typeof(Int32));
  760.                 dt.Columns.Add("type", typeof(string));
  761.                 dt.Columns.Add("num", typeof(Int32));
  762.                 dt.Columns.Add("department", typeof(string));
  763.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  764.                 SqlDataReader dr = sqlcom.ExecuteReader();
  765.                 if (dr.HasRows)
  766.                 {
  767.                     while (dr.Read())
  768.                     {
  769.                         SqlConnection conn1 = dbConnection.getConnection();
  770.                         conn1.Open();
  771.                         string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where department_id='" + lblID.Text + "' and eq_type='" + dr["type"].ToString() + "'";
  772.                         if (!(str_name.Equals("所有设备")))
  773.                         {
  774.                             sqlstr1 = sqlstr1 + " and eq_detail='" + str_name + "'";
  775.                         }
  776.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  777.                         {
  778.                             sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  779.                         }
  780.                         if (!(str_company.Equals("所有厂商")))
  781.                         {
  782.                             sqlstr1 = sqlstr1 + " and company='" + str_company + "'";
  783.                         }
  784.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  785.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  786.                         if (dr1.HasRows)
  787.                         {
  788.                             while (dr1.Read())
  789.                             {
  790.                                 if ((Convert.ToInt32(dr1["num"])) != 0)
  791.                                 {
  792.                                     DataRow row = dt.NewRow();
  793.                                     row["id"] = Convert.ToInt32(dr["id"]);
  794.                                     row["type"] = dr["type"].ToString();
  795.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  796.                                     row["department"] = lblID.Text;
  797.                                     dt.Rows.Add(row);
  798.                                 }
  799.                             }
  800.                         }
  801.                         dr1.Close();
  802.                         conn1.Close();
  803.                     }
  804.                 }
  805.                 ds.Tables.Add(dt);
  806.                 dr.Close();
  807.                 conn.Close();
  808.                 oGridView.DataSource = ds;
  809.                 oGridView.DataBind();
  810.             }
  811.         }
  812.     }
  813.     protected void gvChild1_RowDataBound(object sender, GridViewRowEventArgs e)
  814.     {
  815.         if (e.Row.RowType == DataControlRowType.DataRow)
  816.         {
  817.             GridView oGridView = (GridView)e.Row.FindControl("gvthird1");
  818.             if (oGridView != null)
  819.             {
  820.                 Label lbltype = (Label)e.Row.FindControl("lbl2_type");
  821.                 Label lblid = (Label)e.Row.FindControl("lbl2_department");
  822.                 string str_company = dl_company.SelectedItem.ToString();
  823.                 string str_department = dl_department.SelectedItem.ToString();
  824.                 string str_type = dl_type.SelectedItem.ToString();
  825.                 string str_name = dl_name.SelectedItem.ToString();
  826.                 string str_b_time = b_time.Text.ToString();
  827.                 string str_e_time = e_time.ToString();
  828.                 string sqlstr = "select id,eq_name from OA_UNIT_DETAIL where eq_name='" + str_name + "' and eq_type='" + lbltype.Text.ToString() + "'";
  829.                 if (dl_name.SelectedItem.ToString().Equals("所有设备"))
  830.                 {
  831.                     sqlstr = "select id, eq_name from OA_UNIT_DETAIL where eq_type='" + lbltype.Text + "'";
  832.                 }
  833.                 else if (dl_type.SelectedItem.ToString().Equals("所有类型"))
  834.                 {
  835.                     sqlstr = "select id,eq_name from OA_UNIT_DETAIL where eq_type='" + lbltype.Text + "'";
  836.                 }
  837.                 else
  838.                 {
  839.                 }
  840.                 SqlConnection conn = dbConnection.getConnection();
  841.                 conn.Open();
  842.                 DataSet ds = new DataSet();
  843.                 DataTable dt = new DataTable();
  844.                 dt.Columns.Add("id", typeof(Int32));
  845.                 dt.Columns.Add("eq_detail", typeof(string));
  846.                 dt.Columns.Add("num", typeof(string));
  847.                 dt.Columns.Add("type", typeof(string));
  848.                 dt.Columns.Add("department", typeof(string));
  849.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  850.                 SqlDataReader dr = sqlcom.ExecuteReader();
  851.                 if (dr.HasRows)
  852.                 {
  853.                     while (dr.Read())
  854.                     {
  855.                         SqlConnection conn1 = dbConnection.getConnection();
  856.                         conn1.Open();
  857.                         string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + lbltype.Text + "'and eq_detail='" + dr["eq_name"].ToString() + "'and department_id='" + lblid.Text + "'";
  858.                         if (!(str_company.Equals("所有厂商")))
  859.                         {
  860.                             sqlstr1 = sqlstr1 + " and company='" + str_company + "'";
  861.                         }
  862.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  863.                         {
  864.                             sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  865.                         }
  866.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  867.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  868.                         if (dr1.HasRows)
  869.                         {
  870.                             while (dr1.Read())
  871.                             {
  872.                                 if (Convert.ToInt32(dr1["num"]) != 0)
  873.                                 {
  874.                                     DataRow row = dt.NewRow();
  875.                                     row["type"] = lbltype.Text;
  876.                                     row["department"] = lblid.Text;
  877.                                     row["id"] = Convert.ToInt32(dr["id"]);
  878.                                     row["eq_detail"] = dr["eq_name"].ToString();
  879.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  880.                                     dt.Rows.Add(row);
  881.                                 }
  882.                             }
  883.                         }
  884.                         dr1.Close();
  885.                         conn1.Close();
  886.                     }
  887.                 }
  888.                 ds.Tables.Add(dt);
  889.                 dr.Close();
  890.                 conn.Close();
  891.                 oGridView.DataSource = ds;
  892.                 oGridView.DataBind();
  893.             }
  894.         }
  895.     }
  896.     protected void gvthird1_RowDataBound(object sender, GridViewRowEventArgs e)
  897.     {
  898.         if (e.Row.RowType == DataControlRowType.DataRow)
  899.         {
  900.             GridView oGridView = (GridView)e.Row.FindControl("gvfourth1");
  901.             if (oGridView != null)
  902.             {
  903.                 Label lblname = (Label)e.Row.FindControl("lbl3_detail");
  904.                 Label lbltype = (Label)e.Row.FindControl("lbl3_type");
  905.                 Label lblid = (Label)e.Row.FindControl("lbl3_department");
  906.                 string str_b_time = b_time.Text.ToString();
  907.                 string str_e_time = e_time.ToString();
  908.                 string str_company = dl_company.SelectedItem.ToString();
  909.                 string str_department = dl_department.SelectedItem.ToString();
  910.                 string str_type = dl_type.SelectedItem.ToString();
  911.                 string str_name = dl_name.SelectedItem.ToString();
  912.                 string sqlstr = "select id,company from OA_COMPANY WHERE company='" + str_company + "'";
  913.                 if (str_company.Equals("所有厂商"))
  914.                 {
  915.                     sqlstr = "select id,company from OA_COMPANY";
  916.                 }
  917.                 SqlConnection conn = dbConnection.getConnection();
  918.                 conn.Open();
  919.                 DataSet ds = new DataSet();
  920.                 DataTable dt = new DataTable();
  921.                 dt.Columns.Add("id", typeof(Int32));
  922.                 dt.Columns.Add("department", typeof(string));
  923.                 dt.Columns.Add("eq_detail", typeof(string));
  924.                 dt.Columns.Add("eq_type", typeof(string));
  925.                 dt.Columns.Add("eq_company", typeof(string));
  926.                 dt.Columns.Add("num", typeof(Int32));
  927.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  928.                 SqlDataReader dr = sqlcom.ExecuteReader();
  929.                 if (dr.HasRows)
  930.                 {
  931.                     while (dr.Read())
  932.                     {
  933.                         SqlConnection conn1 = dbConnection.getConnection();
  934.                         conn1.Open();
  935.                         string sqlstr1 = "select count(*) as num from OA_REPAIR_FORM_DETAIL where company='" + dr["company"].ToString() + "' and eq_type='" + lbltype.Text + "'and eq_detail='" + lblname.Text + "'and department_id='" + lblid.Text + "'";
  936.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  937.                         {
  938.                             sqlstr1 = sqlstr1 + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  939.                         }
  940.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr1, conn1);
  941.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  942.                         if (dr1.HasRows)
  943.                         {
  944.                             while (dr1.Read())
  945.                             {
  946.                                 if ((Convert.ToInt32(dr1["num"])) != 0)
  947.                                 {
  948.                                     DataRow row = dt.NewRow();
  949.                                     row["id"] = Convert.ToInt32(dr["id"]);
  950.                                     row["department"] = lblid.Text;
  951.                                     row["eq_detail"] = lblname.Text;
  952.                                     row["eq_type"] = lbltype.Text;
  953.                                     row["eq_company"] = dr["company"].ToString();
  954.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  955.                                     dt.Rows.Add(row);
  956.                                 }
  957.                             }
  958.                         }
  959.                         dr1.Close();
  960.                         conn1.Close();
  961.                     }
  962.                 }
  963.                 ds.Tables.Add(dt);
  964.                 dr.Close();
  965.                 conn.Close();
  966.                 oGridView.DataSource = ds;
  967.                 oGridView.DataBind();
  968.             }
  969.         }
  970.     }
  971.     protected void gvfourth1_RowDataBound(object sender, GridViewRowEventArgs e)
  972.     {
  973.         if (e.Row.RowType == DataControlRowType.DataRow)
  974.         {
  975.             GridView oGridView = (GridView)e.Row.FindControl("gvdetail1");
  976.             if (oGridView != null)
  977.             {
  978.                 Label lblname = (Label)e.Row.FindControl("lbl4_detail");
  979.                 Label lbltype = (Label)e.Row.FindControl("lbl4_type");
  980.                 Label lblid = (Label)e.Row.FindControl("lbl4_department");
  981.                 Label lblcompany = (Label)e.Row.FindControl("lbl4_company");
  982.                 string str_b_time = b_time.Text.ToString();
  983.                 string str_e_time = e_time.ToString();
  984.                 int step = 1;
  985.                 DataSet ds = new DataSet();
  986.                 DataTable dt = new DataTable();
  987.                 dt.Columns.Add(new DataColumn("form_id", typeof(string)));
  988.                 dt.Columns.Add(new DataColumn("department", typeof(string)));
  989.                 dt.Columns.Add(new DataColumn("apply_time", typeof(string)));
  990.                 dt.Columns.Add(new DataColumn("emp_name", typeof(string)));
  991.                 dt.Columns.Add(new DataColumn("eq_type", typeof(string)));
  992.                 dt.Columns.Add(new DataColumn("eq_detail", typeof(string)));
  993.                 dt.Columns.Add(new DataColumn("company", typeof(string)));
  994.                 dt.Columns.Add(new DataColumn("content", typeof(string)));
  995.                 dt.Columns.Add(new DataColumn("check_md", typeof(string)));
  996.                 dt.Columns.Add(new DataColumn("check_company", typeof(string)));
  997.                 dt.Columns.Add(new DataColumn("comment", typeof(string)));
  998.                 dt.Columns.Add(new DataColumn("check_time", typeof(string)));
  999.                 SqlConnection conn = dbConnection.getConnection();
  1000.                 conn.Open();
  1001.                 string sqlstr = "select a.form_id as form_id,c.emp_name as emp_name,a.eq_type as eq_type,a.eq_detail as eq_detail,a.company as company,a.content as content from OA_REPAIR_FORM_DETAIL as a,OA_REPAIR_FORM as b,OA_EMPLOYEE as c where b.form_id=a.form_id and b.emp_id=c.id and a.department_id='" + lblid.Text + "' and a.eq_type='" + lbltype.Text + "' and a.eq_detail='" + lblname.Text + "' and a.company='" + lblcompany.Text + "'";
  1002.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1003.                 {
  1004.                     sqlstr = sqlstr + " and (a.form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1005.                 }
  1006.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  1007.                 SqlDataReader dr1 = sqlcom.ExecuteReader();
  1008.                 if (dr1.HasRows)
  1009.                 {
  1010.                     while (dr1.Read())
  1011.                     {
  1012.                         DataRow row = dt.NewRow();
  1013.                         row["form_id"] = dr1["form_id"].ToString();
  1014.                         row["emp_name"] = dr1["emp_name"].ToString();
  1015.                         row["eq_type"] = dr1["eq_type"].ToString();
  1016.                         row["eq_detail"] = dr1["eq_detail"].ToString();
  1017.                         row["company"] = dr1["company"].ToString();
  1018.                         row["content"] = dr1["content"].ToString();
  1019.                         row["apply_time"] = SetTime(dr1["form_id"].ToString());
  1020.                         SqlConnection conn1 = dbConnection.getConnection();
  1021.                         conn1.Open();
  1022.                         SqlCommand sqlcom5 = new SqlCommand("select name from OA_DEPARTMENT where id='" + lblid.Text + "'", conn1);
  1023.                         SqlDataReader dr5 = sqlcom5.ExecuteReader();
  1024.                         if (dr5.HasRows)
  1025.                         {
  1026.                             while (dr5.Read())
  1027.                             {
  1028.                                 row["department"] = dr5["name"].ToString();
  1029.                             }
  1030.                         }
  1031.                         dr5.Close();
  1032.                         SqlCommand sqlcom1 = new SqlCommand("select max(step) as step from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'", conn1);
  1033.                         SqlDataReader dr4 = sqlcom1.ExecuteReader();
  1034.                         if (dr4.HasRows)
  1035.                         {
  1036.                             while (dr4.Read())
  1037.                             {
  1038.                                 if (!(dr4["step"].ToString().Equals("")))
  1039.                                 {
  1040.                                     step = Convert.ToInt32(dr4["step"]);
  1041.                                 }
  1042.                             }
  1043.                         }
  1044.                         dr4.Close();
  1045.                         SqlCommand sqlcom2 = new SqlCommand("select is_agree from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'and step=" + step, conn1);
  1046.                         SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1047.                         if (dr2.HasRows)
  1048.                         {
  1049.                             while (dr2.Read())
  1050.                             {
  1051.                                 if (dr2["is_agree"].ToString().Equals("Y"))
  1052.                                 {
  1053.                                     row["check_md"] = "已完工";
  1054.                                 }
  1055.                                 else if (dr2["is_agree"].ToString().Equals("N"))
  1056.                                 {
  1057.                                     row["check_md"] = "未处理";
  1058.                                 }
  1059.                                 else
  1060.                                 {
  1061.                                     row["check_md"] = "";
  1062.                                 }
  1063.                             }
  1064.                         }
  1065.                         dr2.Close();
  1066.                         SqlCommand sqlcom3 = new SqlCommand("select is_agree,comment,check_time from OA_COMPANY_CHECK where form_id='" + dr1["form_id"].ToString() + "' and company='" + dr1["company"].ToString() + "'", conn1);
  1067.                         SqlDataReader dr3 = sqlcom3.ExecuteReader();
  1068.                         if (dr3.HasRows)
  1069.                         {
  1070.                             while (dr3.Read())
  1071.                             {
  1072.                                 if (dr3["is_agree"].ToString().Equals("Y"))
  1073.                                 {
  1074.                                     row["check_company"] = "已完工";
  1075.                                 }
  1076.                                 else if (dr3["is_agree"].ToString().Equals("N"))
  1077.                                 {
  1078.                                     row["check_company"] = "未处理";
  1079.                                 }
  1080.                                 else
  1081.                                 {
  1082.                                     row["check_company"] = "";
  1083.                                 }
  1084.                                 row["comment"] = dr3["comment"].ToString().Replace("/n", "<br>").ToString();
  1085.                                 row["check_time"] = SetTime(dr3["check_time"].ToString());
  1086.                             }
  1087.                         }
  1088.                         dr3.Close();
  1089.                         conn1.Close();
  1090.                         dt.Rows.Add(row);
  1091.                     }
  1092.                 }
  1093.                 ds.Tables.Add(dt);
  1094.                 oGridView.DataSource = ds;
  1095.                 oGridView.DataBind();
  1096.                 dr1.Close();
  1097.                 conn.Close();
  1098.             }
  1099.         }
  1100.     }
  1101.     protected void bind3()
  1102.     {
  1103.         string str_company = dl_company.SelectedItem.ToString();
  1104.         string str_department = dl_department.SelectedItem.ToString();
  1105.         string str_type = dl_type.SelectedItem.ToString();
  1106.         string str_name = dl_name.SelectedItem.ToString();
  1107.         string str_b_time = b_time.Text.ToString();
  1108.         string str_e_time = e_time.ToString();
  1109.         SqlConnection conn = dbConnection.getConnection();
  1110.         conn.Open();
  1111.         DataSet ds = new DataSet();
  1112.         DataTable dt = new DataTable();
  1113.         dt.Columns.Add("id", typeof(Int32));
  1114.         dt.Columns.Add("type", typeof(string));
  1115.         dt.Columns.Add("num", typeof(Int32));
  1116.         string str = "select id,type from OA_UNIT_TYPE where type='" + str_type + "'";
  1117.         if(str_type.Equals("所有类型"))
  1118.         {
  1119.             str = "select id,type from OA_UNIT_TYPE order by id";
  1120.         }
  1121.         SqlCommand sqlcom = new SqlCommand(str,conn);
  1122.         SqlDataReader dr = sqlcom.ExecuteReader();
  1123.         if (dr.HasRows)
  1124.         {
  1125.             while (dr.Read())
  1126.             {
  1127.                 SqlConnection conn1 = dbConnection.getConnection();
  1128.                 conn1.Open();
  1129.                 string sqlstr = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + dr["type"] + "'";
  1130.                 if (!(str_name.Equals("所有设备")))
  1131.                 {
  1132.                     sqlstr = sqlstr + " and eq_detail='" + str_name + "'";
  1133.                 }
  1134.                 if (!(str_company.Equals("所有厂商")))
  1135.                 {
  1136.                     sqlstr = sqlstr + " and company='" + str_company + "'";
  1137.                 }
  1138.                 if (!(str_department.Equals("所有门店")))
  1139.                 {
  1140.                     SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  1141.                     SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1142.                     if (dr2.HasRows)
  1143.                     {
  1144.                         while (dr2.Read())
  1145.                         {
  1146.                             sqlstr = sqlstr + " and department_id=" + Convert.ToInt32(dr2["id"]);
  1147.                         }
  1148.                     }
  1149.                     dr2.Close();
  1150.                 }
  1151.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1152.                 {
  1153.                     sqlstr = sqlstr + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1154.                 }
  1155.                 SqlCommand sqlcom1 = new SqlCommand(sqlstr,conn1);
  1156.                 SqlDataReader dr1 = sqlcom1.ExecuteReader();
  1157.                 if (dr1.HasRows)
  1158.                 {
  1159.                     while (dr1.Read())
  1160.                     {
  1161.                         if (Convert.ToInt32(dr1["num"]) > 0)
  1162.                         {
  1163.                             DataRow row = dt.NewRow();
  1164.                             row["id"] = Convert.ToInt32(dr["id"]);
  1165.                             row["type"] = dr["type"].ToString();
  1166.                             row["num"] = Convert.ToInt32(dr1["num"]);
  1167.                             dt.Rows.Add(row);
  1168.                         }
  1169.                     }
  1170.                 }
  1171.                 dr1.Close();
  1172.                 conn1.Close();
  1173.             }
  1174.         }
  1175.         dr.Close();
  1176.         conn.Close();
  1177.         ds.Tables.Add(dt);
  1178.         gvParent2.DataSource = ds;
  1179.         gvParent2.DataBind();
  1180.     }
  1181.     protected void gvParent2_RowDataBound(object sender, GridViewRowEventArgs e)
  1182.     {
  1183.         if (e.Row.RowType == DataControlRowType.DataRow)
  1184.         {
  1185.             GridView oGridView = (GridView)e.Row.FindControl("gvChild2");
  1186.             if (oGridView != null)
  1187.             {
  1188.                 string str_company = dl_company.SelectedItem.ToString();
  1189.                 string str_department = dl_department.SelectedItem.ToString();
  1190.                 string str_type = dl_type.SelectedItem.ToString();
  1191.                 string str_name = dl_name.SelectedItem.ToString();
  1192.                 string str_b_time = b_time.Text.ToString();
  1193.                 string str_e_time = e_time.ToString();
  1194.                  Label lblID = (Label)e.Row.FindControl("lbll1_ID");
  1195.                  string str = "select id,eq_name from OA_UNIT_DETAIL where eq_type='" + lblID.Text + "' and eq_name='" + str_name + "'";
  1196.                  if (str_name.Equals("所有设备"))
  1197.                  {
  1198.                      str = "select id,eq_name from OA_UNIT_DETAIL where eq_type='" + lblID.Text + "'";
  1199.                  }
  1200.                  SqlConnection conn = dbConnection.getConnection();
  1201.                  conn.Open();
  1202.                  DataSet ds = new DataSet();
  1203.                  DataTable dt = new DataTable();
  1204.                  dt.Columns.Add("id", typeof(Int32));
  1205.                  dt.Columns.Add("name", typeof(string));
  1206.                  dt.Columns.Add("type", typeof(string));
  1207.                  dt.Columns.Add("num", typeof(Int32));
  1208.                  SqlCommand sqlcom = new SqlCommand(str,conn);
  1209.                  SqlDataReader dr = sqlcom.ExecuteReader();
  1210.                  if (dr.HasRows)
  1211.                  {
  1212.                      while (dr.Read())
  1213.                      {
  1214.                          SqlConnection conn1 = dbConnection.getConnection();
  1215.                          conn1.Open();
  1216.                          string sqlstr = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + lblID.Text + "' and eq_detail='" + dr["eq_name"].ToString() + "'";
  1217.                          if(!(str_company.Equals("所有厂商")))
  1218.                          {
  1219.                              sqlstr = sqlstr + " and company='" + str_company + "'";
  1220.                          }
  1221.                          if (!(str_department.Equals("所有门店")))
  1222.                          {
  1223.                              SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  1224.                              SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1225.                              if (dr2.HasRows)
  1226.                              {
  1227.                                  while (dr2.Read())
  1228.                                  {
  1229.                                      sqlstr = sqlstr + " and department_id=" + Convert.ToInt32(dr2["id"]);
  1230.                                  }
  1231.                              }
  1232.                              dr2.Close();
  1233.                          }
  1234.                          if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1235.                          {
  1236.                              sqlstr = sqlstr + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1237.                          }
  1238.                          SqlCommand sqlcom1 = new SqlCommand(sqlstr,conn1);
  1239.                          SqlDataReader dr1 = sqlcom1.ExecuteReader();
  1240.                          if (dr1.HasRows)
  1241.                          {
  1242.                              while (dr1.Read())
  1243.                              {
  1244.                                  if (Convert.ToInt32(dr1["num"]) > 0)
  1245.                                  {
  1246.                                      DataRow row = dt.NewRow();
  1247.                                      row["id"] = Convert.ToInt32(dr["id"]);
  1248.                                      row["name"] = dr["eq_name"].ToString();
  1249.                                      row["num"] = Convert.ToInt32(dr1["num"]);
  1250.                                      row["type"] = lblID.Text.ToString();
  1251.                                      dt.Rows.Add(row);
  1252.                                  }
  1253.                              }
  1254.                          }
  1255.                          dr1.Close();
  1256.                          conn1.Close();
  1257.                      }
  1258.                  }
  1259.                  dr.Close();
  1260.                  conn.Close();
  1261.                  ds.Tables.Add(dt);
  1262.                  oGridView.DataSource = ds;
  1263.                  oGridView.DataBind();
  1264.             }
  1265.         }
  1266.     }
  1267.     protected void gvChild2_RowDataBound(object sender, GridViewRowEventArgs e)
  1268.     {
  1269.         if (e.Row.RowType == DataControlRowType.DataRow)
  1270.         {
  1271.             GridView oGridView = (GridView)e.Row.FindControl("gvthird2");
  1272.             if (oGridView != null)
  1273.             {
  1274.                 string str_company = dl_company.SelectedItem.ToString();
  1275.                 string str_department = dl_department.SelectedItem.ToString();
  1276.                 string str_type = dl_type.SelectedItem.ToString();
  1277.                 string str_name = dl_name.SelectedItem.ToString();
  1278.                 string str_b_time = b_time.Text.ToString();
  1279.                 string str_e_time = e_time.ToString();
  1280.                 Label lbltype = (Label)e.Row.FindControl("lbll2_type");
  1281.                 Label lblid = (Label)e.Row.FindControl("lbll2_name");
  1282.                 string str = "select id,company from OA_COMPANY where company='" + str_company + "'";
  1283.                 if (str_company.Equals("所有厂商"))
  1284.                 {
  1285.                     str = "select id,company from OA_COMPANY";
  1286.                 }
  1287.                 SqlConnection conn = dbConnection.getConnection();
  1288.                 conn.Open();
  1289.                 DataSet ds = new DataSet();
  1290.                 DataTable dt = new DataTable();
  1291.                 dt.Columns.Add("id", typeof(Int32));
  1292.                 dt.Columns.Add("company", typeof(string));
  1293.                 dt.Columns.Add("num", typeof(Int32));
  1294.                 dt.Columns.Add("type", typeof(string));
  1295.                 dt.Columns.Add("name", typeof(string));
  1296.                 SqlCommand sqlcom = new SqlCommand(str,conn);
  1297.                 SqlDataReader dr = sqlcom.ExecuteReader();
  1298.                 if (dr.HasRows)
  1299.                 {
  1300.                     while (dr.Read())
  1301.                     {
  1302.                         SqlConnection conn1 = dbConnection.getConnection();
  1303.                         conn1.Open();
  1304.                         string sqlstr = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + lbltype.Text + "' and eq_detail='" + lblid.Text + "' and company='" + dr["company"].ToString() + "'";
  1305.                         if (!(str_department.Equals("所有门店")))
  1306.                         {
  1307.                             SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  1308.                             SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1309.                             if (dr2.HasRows)
  1310.                             {
  1311.                                 while (dr2.Read())
  1312.                                 {
  1313.                                     sqlstr = sqlstr + " and department_id=" + Convert.ToInt32(dr2["id"]);
  1314.                                 }
  1315.                             }
  1316.                             dr2.Close();
  1317.                         }
  1318.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1319.                         {
  1320.                             sqlstr = sqlstr + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1321.                         }
  1322.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr, conn1);
  1323.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  1324.                         if (dr1.HasRows)
  1325.                         {
  1326.                             while (dr1.Read())
  1327.                             {
  1328.                                 if (Convert.ToInt32(dr1["num"]) > 0)
  1329.                                 {
  1330.                                     DataRow row = dt.NewRow();
  1331.                                     row["type"] = lbltype.Text;
  1332.                                     row["name"] = lblid.Text;
  1333.                                     row["id"] = Convert.ToInt32(dr["id"]);
  1334.                                     row["company"] = dr["company"].ToString();
  1335.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  1336.                                     dt.Rows.Add(row);
  1337.                                 }
  1338.                             }
  1339.                         }
  1340.                         dr1.Close();
  1341.                         conn1.Close();
  1342.                     }
  1343.                 }
  1344.                 dr.Close();
  1345.                 conn.Close();
  1346.                 ds.Tables.Add(dt);
  1347.                 oGridView.DataSource = ds;
  1348.                 oGridView.DataBind();
  1349.             }
  1350.         }
  1351.     }
  1352.     protected void gvthird2_RowDataBound(object sender, GridViewRowEventArgs e)
  1353.     {
  1354.         if (e.Row.RowType == DataControlRowType.DataRow)
  1355.         {
  1356.             GridView oGridView = (GridView)e.Row.FindControl("gvdetail2");
  1357.             if (oGridView != null)
  1358.             {
  1359.                 Label lblname = (Label)e.Row.FindControl("lbll3_detail");
  1360.                 Label lbltype = (Label)e.Row.FindControl("lbll3_type");
  1361.                 Label lblcompany = (Label)e.Row.FindControl("lbll3_company");
  1362.                 string str_department = dl_department.SelectedItem.ToString();
  1363.                 string str_b_time = b_time.Text.ToString();
  1364.                 string str_e_time = e_time.ToString();
  1365.                 int step = 1;
  1366.                 DataSet ds = new DataSet();
  1367.                 DataTable dt = new DataTable();
  1368.                 dt.Columns.Add(new DataColumn("form_id", typeof(string)));
  1369.                 dt.Columns.Add(new DataColumn("department", typeof(string)));
  1370.                 dt.Columns.Add(new DataColumn("apply_time", typeof(string)));
  1371.                 dt.Columns.Add(new DataColumn("emp_name", typeof(string)));
  1372.                 dt.Columns.Add(new DataColumn("eq_type", typeof(string)));
  1373.                 dt.Columns.Add(new DataColumn("eq_detail", typeof(string)));
  1374.                 dt.Columns.Add(new DataColumn("company", typeof(string)));
  1375.                 dt.Columns.Add(new DataColumn("content", typeof(string)));
  1376.                 dt.Columns.Add(new DataColumn("check_md", typeof(string)));
  1377.                 dt.Columns.Add(new DataColumn("check_company", typeof(string)));
  1378.                 dt.Columns.Add(new DataColumn("comment", typeof(string)));
  1379.                 dt.Columns.Add(new DataColumn("check_time", typeof(string)));
  1380.                 SqlConnection conn = dbConnection.getConnection();
  1381.                 conn.Open();
  1382.                 string sqlstr = "select a.department_id as department_id,a.form_id as form_id,c.emp_name as emp_name,a.eq_type as eq_type,a.eq_detail as eq_detail,a.company as company,a.content as content from OA_REPAIR_FORM_DETAIL as a,OA_REPAIR_FORM as b,OA_EMPLOYEE as c where b.form_id=a.form_id and b.emp_id=c.id  and a.eq_type='" + lbltype.Text + "' and a.eq_detail='" + lblname.Text + "' and a.company='" + lblcompany.Text + "'";
  1383.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1384.                 {
  1385.                     sqlstr = sqlstr + " and (a.form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1386.                 }
  1387.                 if (!(str_department.Equals("所有门店")))
  1388.                 {
  1389.                     SqlCommand sqlcom6 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn);
  1390.                     SqlDataReader dr6 = sqlcom6.ExecuteReader();
  1391.                     if (dr6.HasRows)
  1392.                     {
  1393.                         while (dr6.Read())
  1394.                         {
  1395.                             sqlstr = sqlstr + " and a.department_id=" + Convert.ToInt32(dr6["id"]);
  1396.                         }
  1397.                     }
  1398.                     dr6.Close();
  1399.                 }
  1400.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  1401.                 SqlDataReader dr1 = sqlcom.ExecuteReader();
  1402.                 if (dr1.HasRows)
  1403.                 {
  1404.                     while (dr1.Read())
  1405.                     {
  1406.                         DataRow row = dt.NewRow();
  1407.                         row["form_id"] = dr1["form_id"].ToString();
  1408.                         row["emp_name"] = dr1["emp_name"].ToString();
  1409.                         row["eq_type"] = dr1["eq_type"].ToString();
  1410.                         row["eq_detail"] = dr1["eq_detail"].ToString();
  1411.                         row["company"] = dr1["company"].ToString();
  1412.                         row["content"] = dr1["content"].ToString();
  1413.                         row["apply_time"] = SetTime(dr1["form_id"].ToString());
  1414.                         SqlConnection conn1 = dbConnection.getConnection();
  1415.                         conn1.Open();
  1416.                         SqlCommand sqlcom5 = new SqlCommand("select name from OA_DEPARTMENT where id='" + dr1["department_id"].ToString() + "'", conn1);
  1417.                         SqlDataReader dr5 = sqlcom5.ExecuteReader();
  1418.                         if (dr5.HasRows)
  1419.                         {
  1420.                             while (dr5.Read())
  1421.                             {
  1422.                                 row["department"] = dr5["name"].ToString();
  1423.                             }
  1424.                         }
  1425.                         dr5.Close();
  1426.                         SqlCommand sqlcom1 = new SqlCommand("select max(step) as step from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'", conn1);
  1427.                         SqlDataReader dr4 = sqlcom1.ExecuteReader();
  1428.                         if (dr4.HasRows)
  1429.                         {
  1430.                             while (dr4.Read())
  1431.                             {
  1432.                                 if (!(dr4["step"].ToString().Equals("")))
  1433.                                 {
  1434.                                     step = Convert.ToInt32(dr4["step"]);
  1435.                                 }
  1436.                             }
  1437.                         }
  1438.                         dr4.Close();
  1439.                         SqlCommand sqlcom2 = new SqlCommand("select is_agree from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'and step=" + step, conn1);
  1440.                         SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1441.                         if (dr2.HasRows)
  1442.                         {
  1443.                             while (dr2.Read())
  1444.                             {
  1445.                                 if (dr2["is_agree"].ToString().Equals("Y"))
  1446.                                 {
  1447.                                     row["check_md"] = "已完工";
  1448.                                 }
  1449.                                 else if (dr2["is_agree"].ToString().Equals("N"))
  1450.                                 {
  1451.                                     row["check_md"] = "未处理";
  1452.                                 }
  1453.                                 else
  1454.                                 {
  1455.                                     row["check_md"] = "";
  1456.                                 }
  1457.                             }
  1458.                         }
  1459.                         dr2.Close();
  1460.                         SqlCommand sqlcom3 = new SqlCommand("select is_agree,comment,check_time from OA_COMPANY_CHECK where form_id='" + dr1["form_id"].ToString() + "' and company='" + dr1["company"].ToString() + "'", conn1);
  1461.                         SqlDataReader dr3 = sqlcom3.ExecuteReader();
  1462.                         if (dr3.HasRows)
  1463.                         {
  1464.                             while (dr3.Read())
  1465.                             {
  1466.                                 if (dr3["is_agree"].ToString().Equals("Y"))
  1467.                                 {
  1468.                                     row["check_company"] = "已完工";
  1469.                                 }
  1470.                                 else if (dr3["is_agree"].ToString().Equals("N"))
  1471.                                 {
  1472.                                     row["check_company"] = "未处理";
  1473.                                 }
  1474.                                 else
  1475.                                 {
  1476.                                     row["check_company"] = "";
  1477.                                 }
  1478.                                 row["comment"] = dr3["comment"].ToString().Replace("/n", "<br>").ToString();
  1479.                                 row["check_time"] = SetTime(dr3["check_time"].ToString());
  1480.                             }
  1481.                         }
  1482.                         dr3.Close();
  1483.                         conn1.Close();
  1484.                         dt.Rows.Add(row);
  1485.                     }
  1486.                 }
  1487.                 ds.Tables.Add(dt);
  1488.                 oGridView.DataSource = ds;
  1489.                 oGridView.DataBind();
  1490.                 dr1.Close();
  1491.                 conn.Close();
  1492.             }
  1493.         }
  1494.     }
  1495.     protected void bind4()
  1496.     {
  1497.         string str_company = dl_company.SelectedItem.ToString();
  1498.         string str_department = dl_department.SelectedItem.ToString();
  1499.         string str_type = dl_type.SelectedItem.ToString();
  1500.         string str_name = dl_name.SelectedItem.ToString();
  1501.         string str_b_time = b_time.Text.ToString();
  1502.         string str_e_time = e_time.ToString();
  1503.         SqlConnection conn = dbConnection.getConnection();
  1504.         conn.Open();
  1505.         DataSet ds = new DataSet();
  1506.         DataTable dt = new DataTable();
  1507.         dt.Columns.Add("id", typeof(Int32));
  1508.         dt.Columns.Add("type", typeof(string));
  1509.         dt.Columns.Add("num", typeof(Int32));
  1510.         string str = "select id,type from OA_UNIT_TYPE where type='" + str_type + "'";
  1511.         if (str_type.Equals("所有类型"))
  1512.         {
  1513.             str = "select id,type from OA_UNIT_TYPE order by id";
  1514.         }
  1515.         SqlCommand sqlcom = new SqlCommand(str, conn);
  1516.         SqlDataReader dr = sqlcom.ExecuteReader();
  1517.         if (dr.HasRows)
  1518.         {
  1519.             while (dr.Read())
  1520.             {
  1521.                 SqlConnection conn1 = dbConnection.getConnection();
  1522.                 conn1.Open();
  1523.                 string sqlstr = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + dr["type"].ToString() + "'";
  1524.                 if (!(str_name.Equals("所有设备")))
  1525.                 {
  1526.                     sqlstr = sqlstr + " and eq_detail='" + str_name + "'";
  1527.                 }
  1528.                 if (!(str_company.Equals("所有厂商")))
  1529.                 {
  1530.                     sqlstr = sqlstr + " and company='" + str_company + "'";
  1531.                 }
  1532.                 if (!(str_department.Equals("所有门店")))
  1533.                 {
  1534.                     SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  1535.                     SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1536.                     if (dr2.HasRows)
  1537.                     {
  1538.                         while (dr2.Read())
  1539.                         {
  1540.                             sqlstr = sqlstr + " and department_id=" + Convert.ToInt32(dr2["id"]);
  1541.                         }
  1542.                     }
  1543.                     dr2.Close();
  1544.                 }
  1545.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1546.                 {
  1547.                     sqlstr = sqlstr + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1548.                 }
  1549.                 SqlCommand sqlcom1 = new SqlCommand(sqlstr, conn1);
  1550.                 SqlDataReader dr1 = sqlcom1.ExecuteReader();
  1551.                 if (dr1.HasRows)
  1552.                 {
  1553.                     while (dr1.Read())
  1554.                     {
  1555.                         if (Convert.ToInt32(dr1["num"]) > 0)
  1556.                         {
  1557.                             DataRow row = dt.NewRow();
  1558.                             row["id"] = Convert.ToInt32(dr["id"]);
  1559.                             row["type"] = dr["type"].ToString();
  1560.                             row["num"] = Convert.ToInt32(dr1["num"]);
  1561.                             dt.Rows.Add(row);
  1562.                         }
  1563.                     }
  1564.                 }
  1565.                 dr1.Close();
  1566.                 conn1.Close();
  1567.             }
  1568.         }
  1569.         dr.Close();
  1570.         conn.Close();
  1571.         ds.Tables.Add(dt);
  1572.         gvParent3.DataSource = ds;
  1573.         gvParent3.DataBind();
  1574.     }
  1575.     protected void gvParent3_RowDataBound(object sender, GridViewRowEventArgs e)
  1576.     {
  1577.         if (e.Row.RowType == DataControlRowType.DataRow)
  1578.         {
  1579.             GridView oGridView = (GridView)e.Row.FindControl("gvChild3");
  1580.             if (oGridView != null)
  1581.             {
  1582.                 string str_company = dl_company.SelectedItem.ToString();
  1583.                 string str_department = dl_department.SelectedItem.ToString();
  1584.                 string str_type = dl_type.SelectedItem.ToString();
  1585.                 string str_name = dl_name.SelectedItem.ToString();
  1586.                 string str_b_time = b_time.Text.ToString();
  1587.                 string str_e_time = e_time.ToString();
  1588.                 Label lblID = (Label)e.Row.FindControl("lblll1_ID");
  1589.                 string str = "select id,eq_name from OA_UNIT_DETAIL where eq_type='" + lblID.Text + "' and eq_name='" + str_name + "'";
  1590.                 if (str_name.Equals("所有设备"))
  1591.                 {
  1592.                     str = "select id,eq_name from OA_UNIT_DETAIL where eq_type='" + lblID.Text + "'";
  1593.                 }
  1594.                 SqlConnection conn = dbConnection.getConnection();
  1595.                 conn.Open();
  1596.                 DataSet ds = new DataSet();
  1597.                 DataTable dt = new DataTable();
  1598.                 dt.Columns.Add("id", typeof(Int32));
  1599.                 dt.Columns.Add("name", typeof(string));
  1600.                 dt.Columns.Add("type", typeof(string));
  1601.                 dt.Columns.Add("num", typeof(Int32));
  1602.                 SqlCommand sqlcom = new SqlCommand(str, conn);
  1603.                 SqlDataReader dr = sqlcom.ExecuteReader();
  1604.                 if (dr.HasRows)
  1605.                 {
  1606.                     while (dr.Read())
  1607.                     {
  1608.                         SqlConnection conn1 = dbConnection.getConnection();
  1609.                         conn1.Open();
  1610.                         string sqlstr = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + lblID.Text + "' and eq_detail='" + dr["eq_name"].ToString() + "'";
  1611.                         if (!(str_company.Equals("所有厂商")))
  1612.                         {
  1613.                             sqlstr = sqlstr + " and company='" + str_company + "'";
  1614.                         }
  1615.                         if (!(str_department.Equals("所有门店")))
  1616.                         {
  1617.                             SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where name='" + str_department + "'", conn1);
  1618.                             SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1619.                             if (dr2.HasRows)
  1620.                             {
  1621.                                 while (dr2.Read())
  1622.                                 {
  1623.                                     sqlstr = sqlstr + " and department_id=" + Convert.ToInt32(dr2["id"]);
  1624.                                 }
  1625.                             }
  1626.                             dr2.Close();
  1627.                         }
  1628.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1629.                         {
  1630.                             sqlstr = sqlstr + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1631.                         }
  1632.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr, conn1);
  1633.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  1634.                         if (dr1.HasRows)
  1635.                         {
  1636.                             while (dr1.Read())
  1637.                             {
  1638.                                 if (Convert.ToInt32(dr1["num"]) > 0)
  1639.                                 {
  1640.                                     DataRow row = dt.NewRow();
  1641.                                     row["id"] = Convert.ToInt32(dr["id"]);
  1642.                                     row["name"] = dr["eq_name"].ToString();
  1643.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  1644.                                     row["type"] = lblID.Text.ToString();
  1645.                                     dt.Rows.Add(row);
  1646.                                 }
  1647.                             }
  1648.                         }
  1649.                         dr1.Close();
  1650.                         conn1.Close();
  1651.                     }
  1652.                 }
  1653.                 dr.Close();
  1654.                 conn.Close();
  1655.                 ds.Tables.Add(dt);
  1656.                 oGridView.DataSource = ds;
  1657.                 oGridView.DataBind();
  1658.             }
  1659.         }
  1660.     }
  1661.     protected void gvChild3_RowDataBound(object sender, GridViewRowEventArgs e)
  1662.     {
  1663.         if (e.Row.RowType == DataControlRowType.DataRow)
  1664.         {
  1665.             GridView oGridView = (GridView)e.Row.FindControl("gvthird3");
  1666.             if (oGridView != null)
  1667.             {
  1668.                 string str_company = dl_company.SelectedItem.ToString();
  1669.                 string str_department = dl_department.SelectedItem.ToString();
  1670.                 string str_type = dl_type.SelectedItem.ToString();
  1671.                 string str_name = dl_name.SelectedItem.ToString();
  1672.                 string str_b_time = b_time.Text.ToString();
  1673.                 string str_e_time = e_time.ToString();
  1674.                 Label lbltype = (Label)e.Row.FindControl("lblll2_type");
  1675.                 Label lblid = (Label)e.Row.FindControl("lblll2_name");
  1676.                 string str = "select id,name from OA_DEPARTMENT where name='" + str_department + "'";
  1677.                 if (str_department.Equals("所有门店"))
  1678.                 {
  1679.                     str = "select id,name from OA_DEPARTMENT where (charindex('店', name) > 0)";
  1680.                 }
  1681.                 SqlConnection conn = dbConnection.getConnection();
  1682.                 conn.Open();
  1683.                 DataSet ds = new DataSet();
  1684.                 DataTable dt = new DataTable();
  1685.                 dt.Columns.Add("id", typeof(Int32));
  1686.                 dt.Columns.Add("department", typeof(string));
  1687.                 dt.Columns.Add("num", typeof(Int32));
  1688.                 dt.Columns.Add("type", typeof(string));
  1689.                 dt.Columns.Add("name", typeof(string));
  1690.                 SqlCommand sqlcom = new SqlCommand(str, conn);
  1691.                 SqlDataReader dr = sqlcom.ExecuteReader();
  1692.                 if (dr.HasRows)
  1693.                 {
  1694.                     while (dr.Read())
  1695.                     {
  1696.                         SqlConnection conn1 = dbConnection.getConnection();
  1697.                         conn1.Open();
  1698.                         string sqlstr = "select count(*) as num from OA_REPAIR_FORM_DETAIL where eq_type='" + lbltype.Text + "' and eq_detail='" + lblid.Text + "' and department_id=" + Convert.ToInt32(dr["id"]);
  1699.                         if (!(str_company.Equals("所有厂商")))
  1700.                         {
  1701.                             sqlstr = sqlstr + " and company='" + str_company + "'";
  1702.                         }
  1703.                         if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1704.                         {
  1705.                             sqlstr = sqlstr + " and (form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1706.                         }
  1707.                         ShowMessageBox(sqlstr);
  1708.                         SqlCommand sqlcom1 = new SqlCommand(sqlstr,conn1);
  1709.                         SqlDataReader dr1 = sqlcom1.ExecuteReader();
  1710.                         if (dr1.HasRows)
  1711.                         {
  1712.                             while (dr1.Read())
  1713.                             {
  1714.                                 if (Convert.ToInt32(dr1["num"]) > 0)
  1715.                                 {
  1716.                                     DataRow row = dt.NewRow();
  1717.                                     row["type"] = lbltype.Text;
  1718.                                     row["name"] = lblid.Text;
  1719.                                     row["id"] = Convert.ToInt32(dr["id"]);
  1720.                                     row["department"] = dr["name"].ToString();
  1721.                                     row["num"] = Convert.ToInt32(dr1["num"]);
  1722.                                     dt.Rows.Add(row);
  1723.                                 }
  1724.                             }
  1725.                         }
  1726.                         dr1.Close();
  1727.                         conn1.Close();
  1728.                     }
  1729.                 }
  1730.                 dr.Close();
  1731.                 conn.Close();
  1732.                 ds.Tables.Add(dt);
  1733.                 oGridView.DataSource = ds;
  1734.                 oGridView.DataBind();
  1735.             }
  1736.         }
  1737.     }
  1738.     protected void gvthird3_RowDataBound(object sender, GridViewRowEventArgs e)
  1739.     {
  1740.         if (e.Row.RowType == DataControlRowType.DataRow)
  1741.         {
  1742.             GridView oGridView = (GridView)e.Row.FindControl("gvdetail3");
  1743.             if (oGridView != null)
  1744.             {
  1745.                 Label lblname = (Label)e.Row.FindControl("lblll3_detail");
  1746.                 Label lbltype = (Label)e.Row.FindControl("lblll3_type");
  1747.                 Label lbldepartment = (Label)e.Row.FindControl("lblll3_department");
  1748.                 string str_company = dl_company.SelectedItem.ToString();
  1749.                 string str_b_time = b_time.Text.ToString();
  1750.                 string str_e_time = e_time.ToString();
  1751.                 int step = 1;
  1752.                 DataSet ds = new DataSet();
  1753.                 DataTable dt = new DataTable();
  1754.                 dt.Columns.Add(new DataColumn("form_id", typeof(string)));
  1755.                 dt.Columns.Add(new DataColumn("department", typeof(string)));
  1756.                 dt.Columns.Add(new DataColumn("apply_time", typeof(string)));
  1757.                 dt.Columns.Add(new DataColumn("emp_name", typeof(string)));
  1758.                 dt.Columns.Add(new DataColumn("eq_type", typeof(string)));
  1759.                 dt.Columns.Add(new DataColumn("eq_detail", typeof(string)));
  1760.                 dt.Columns.Add(new DataColumn("company", typeof(string)));
  1761.                 dt.Columns.Add(new DataColumn("content", typeof(string)));
  1762.                 dt.Columns.Add(new DataColumn("check_md", typeof(string)));
  1763.                 dt.Columns.Add(new DataColumn("check_company", typeof(string)));
  1764.                 dt.Columns.Add(new DataColumn("comment", typeof(string)));
  1765.                 dt.Columns.Add(new DataColumn("check_time", typeof(string)));
  1766.                 SqlConnection conn = dbConnection.getConnection();
  1767.                 conn.Open();
  1768.                 string sqlstr = "select a.form_id as form_id,c.emp_name as emp_name,a.eq_type as eq_type,a.eq_detail as eq_detail,a.company as company,a.content as content from OA_REPAIR_FORM_DETAIL as a,OA_REPAIR_FORM as b,OA_EMPLOYEE as c where b.form_id=a.form_id and b.emp_id=c.id  and a.eq_type='" + lbltype.Text + "' and a.eq_detail='" + lblname.Text + "' and a.department_id='" + lbldepartment.Text + "'";
  1769.                 if ((!(str_b_time.Equals(""))) && (!(str_e_time.Equals(""))))
  1770.                 {
  1771.                     sqlstr = sqlstr + " and (a.form_id between'" + str_b_time + "' and '" + str_e_time + "')";
  1772.                 }
  1773.                 if (!(str_company.Equals("所有厂商")))
  1774.                 {
  1775.                     sqlstr = sqlstr + " and a.company='" + str_company + "'";
  1776.                 }
  1777.                 SqlCommand sqlcom = new SqlCommand(sqlstr, conn);
  1778.                 SqlDataReader dr1 = sqlcom.ExecuteReader();
  1779.                 if (dr1.HasRows)
  1780.                 {
  1781.                     while (dr1.Read())
  1782.                     {
  1783.                         DataRow row = dt.NewRow();
  1784.                         row["form_id"] = dr1["form_id"].ToString();
  1785.                         row["emp_name"] = dr1["emp_name"].ToString();
  1786.                         row["eq_type"] = dr1["eq_type"].ToString();
  1787.                         row["eq_detail"] = dr1["eq_detail"].ToString();
  1788.                         row["company"] = dr1["company"].ToString();
  1789.                         row["content"] = dr1["content"].ToString();
  1790.                         row["apply_time"] = SetTime(dr1["form_id"].ToString());
  1791.                         SqlConnection conn1 = dbConnection.getConnection();
  1792.                         conn1.Open();
  1793.                         SqlCommand sqlcom5 = new SqlCommand("select name from OA_DEPARTMENT where id='" + lbldepartment.Text + "'", conn1);
  1794.                         SqlDataReader dr5 = sqlcom5.ExecuteReader();
  1795.                         if (dr5.HasRows)
  1796.                         {
  1797.                             while (dr5.Read())
  1798.                             {
  1799.                                 row["department"] = dr5["name"].ToString();
  1800.                             }
  1801.                         }
  1802.                         dr5.Close();
  1803.                         SqlCommand sqlcom1 = new SqlCommand("select max(step) as step from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'", conn1);
  1804.                         SqlDataReader dr4 = sqlcom1.ExecuteReader();
  1805.                         if (dr4.HasRows)
  1806.                         {
  1807.                             while (dr4.Read())
  1808.                             {
  1809.                                 if (!(dr4["step"].ToString().Equals("")))
  1810.                                 {
  1811.                                     step = Convert.ToInt32(dr4["step"]);
  1812.                                 }
  1813.                             }
  1814.                         }
  1815.                         dr4.Close();
  1816.                         SqlCommand sqlcom2 = new SqlCommand("select is_agree from OA_REPAIR_FLOW where form_id='" + dr1["form_id"].ToString() + "'and step=" + step, conn1);
  1817.                         SqlDataReader dr2 = sqlcom2.ExecuteReader();
  1818.                         if (dr2.HasRows)
  1819.                         {
  1820.                             while (dr2.Read())
  1821.                             {
  1822.                                 if (dr2["is_agree"].ToString().Equals("Y"))
  1823.                                 {
  1824.                                     row["check_md"] = "已完工";
  1825.                                 }
  1826.                                 else if (dr2["is_agree"].ToString().Equals("N"))
  1827.                                 {
  1828.                                     row["check_md"] = "未处理";
  1829.                                 }
  1830.                                 else
  1831.                                 {
  1832.                                     row["check_md"] = "";
  1833.                                 }
  1834.                             }
  1835.                         }
  1836.                         dr2.Close();
  1837.                         SqlCommand sqlcom3 = new SqlCommand("select is_agree,comment,check_time from OA_COMPANY_CHECK where form_id='" + dr1["form_id"].ToString() + "' and company='" + dr1["company"].ToString() + "'", conn1);
  1838.                         SqlDataReader dr3 = sqlcom3.ExecuteReader();
  1839.                         if (dr3.HasRows)
  1840.                         {
  1841.                             while (dr3.Read())
  1842.                             {
  1843.                                 if (dr3["is_agree"].ToString().Equals("Y"))
  1844.                                 {
  1845.                                     row["check_company"] = "已完工";
  1846.                                 }
  1847.                                 else if (dr3["is_agree"].ToString().Equals("N"))
  1848.                                 {
  1849.                                     row["check_company"] = "未处理";
  1850.                                 }
  1851.                                 else
  1852.                                 {
  1853.                                     row["check_company"] = "";
  1854.                                 }
  1855.                                 row["comment"] = dr3["comment"].ToString().Replace("/n", "<br>").ToString();
  1856.                                 row["check_time"] = SetTime(dr3["check_time"].ToString());
  1857.                             }
  1858.                         }
  1859.                         dr3.Close();
  1860.                         conn1.Close();
  1861.                         dt.Rows.Add(row);
  1862.                     }
  1863.                 }
  1864.                 ds.Tables.Add(dt);
  1865.                 oGridView.DataSource = ds;
  1866.                 oGridView.DataBind();
  1867.                 dr1.Close();
  1868.                 conn.Close();
  1869.             }
  1870.         }
  1871.     }
  1872. }