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

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_edit_deal : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.     }
  17.     public void bind()
  18.     {
  19.         string str_company = dl_company.SelectedItem.ToString().Trim();
  20.         string str_department = dl_department.SelectedValue.ToString().Trim();
  21.         string str_type = dl_type.SelectedItem.ToString().Trim();
  22.         string str_name = dl_name.SelectedItem.ToString().Trim();
  23.         string str_b_time = b_time.Text.ToString().Trim();
  24.         string str_e_time = e_time.Text.ToString().Trim();
  25.         SqlConnection conn = dbConnection.getConnection();
  26.         string sqlstr = "select f.form_id as form_id,f.apply_time as apply_time,f.finish_time as finish_time,f.total_result as total_result,g.department_id as department_id from OA_REPAIR_FORM as f,OA_REPAIR_FORM_DETAIL as g where g.form_id=f.form_id ";
  27.         conn.Open();
  28.         DataSet ds = new DataSet();
  29.         DataTable dt = new DataTable();
  30.         dt.Columns.Add("form_id", typeof(string));
  31.         dt.Columns.Add("department", typeof(string));
  32.         dt.Columns.Add("applytime", typeof(string));
  33.         dt.Columns.Add("finish_date", typeof(string));
  34.         dt.Columns.Add("total_result", typeof(string));
  35.         if (!(str_company.Equals("所有厂商")))
  36.         {
  37.             sqlstr = sqlstr + " and g.company='" + str_company + "'";
  38.         }
  39.         if(!(dl_department.SelectedItem.ToString().Equals("所有门店")))
  40.         {
  41.             sqlstr = sqlstr + " and g.department_id='" + str_department + "'";
  42.         }
  43.         if (!(str_type.Equals("所有类型")))
  44.         {
  45.             sqlstr = sqlstr + " and g.eq_type='" + str_type + "'";
  46.         }
  47.         if (!(str_name.Equals("所有设备")))
  48.         {
  49.             sqlstr = sqlstr + " and g.eq_detail='" + str_name + "'";
  50.         }
  51.         if((!(str_b_time.Equals("")))&&(!(str_e_time.Equals(""))))
  52.         {
  53.             sqlstr = sqlstr + " and (f.form_id between '" + str_b_time + "' and '" + str_e_time + "')";
  54.         }
  55.         sqlstr = sqlstr + "order by f.form_id desc";
  56.         SqlCommand sqlcom = new SqlCommand(sqlstr,conn);
  57.         SqlDataReader dr = sqlcom.ExecuteReader();
  58.         if (dr.HasRows)
  59.         {
  60.             while (dr.Read())
  61.             {
  62.                 DataRow row = dt.NewRow();
  63.                 row["form_id"] = dr["form_id"].ToString();
  64.                 row["applytime"] = SetTime(dr["apply_time"].ToString());
  65.                 row["finish_date"] = SetTime(dr["finish_time"].ToString());
  66.                 row["total_result"] = dr["total_result"].ToString();
  67.                 SqlConnection conn1 = dbConnection.getConnection();
  68.                 conn1.Open();
  69.                 SqlCommand sqlcom1 = new SqlCommand("select name from OA_DEPARTMENT where id=" + Convert.ToInt32(dr["department_id"]), conn1);
  70.                 SqlDataReader dr1 = sqlcom1.ExecuteReader();
  71.                 if (dr1.HasRows)
  72.                 {
  73.                     while (dr1.Read())
  74.                     {
  75.                         row["department"] = dr1["name"].ToString();
  76.                     }
  77.                 }
  78.                 dr1.Close();
  79.                 conn1.Close();
  80.                 dt.Rows.Add(row);
  81.             }
  82.         }
  83.         ds.Tables.Add(dt);
  84.         dr.Close();
  85.         conn.Close();
  86.         GridView1.DataSource = ds;
  87.         GridView1.DataBind();
  88.         GridView1.DataKeyNames = new string[] { "form_id" };
  89.     }
  90.     public string SetTime(string s)
  91.     {
  92.         string year = "";
  93.         string month = "";
  94.         string day = "";
  95.         string hour = "";
  96.         string minite = "";
  97.         string second = "";
  98.         if (s.Length == 14)
  99.         {
  100.             year = s.Substring(0, 4).ToString();
  101.             month = s.Substring(4, 2).ToString();
  102.             day = s.Substring(6, 2).ToString();
  103.             hour = s.Substring(8, 2).ToString();
  104.             minite = s.Substring(10, 2).ToString();
  105.             second = s.Substring(12, 2).ToString();
  106.             return year + "-" + month + "-" + day + " " + hour + ":" + minite + ":" + second;
  107.         }
  108.         else
  109.         {
  110.             return s;
  111.         }
  112.     }
  113.     protected void ShowMessageBox(string strMessage)
  114.     {
  115.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  116.     }
  117.     protected void Enddate_SelectionChanged(object sender, EventArgs e)
  118.     {
  119.         Enddate.Visible = false;
  120.         string year = Enddate.SelectedDate.Year.ToString();
  121.         string month =Enddate.SelectedDate.Month.ToString();
  122.         if (month.Length == 1)
  123.         {
  124.             month = "0" + month;
  125.         }
  126.         string day = Enddate.SelectedDate.Day.ToString();
  127.         if (day.Length == 1)
  128.         {
  129.             day = "0" + day;
  130.         }
  131.         e_time.Text = year + month + day + "000000";
  132.         e_time.Focus();
  133.     }
  134.     protected void Begindate_SelectionChanged(object sender, EventArgs e)
  135.     {
  136.         Begindate.Visible = false;
  137.         string year = Begindate.SelectedDate.Year.ToString();
  138.         string month = Begindate.SelectedDate.Month.ToString();
  139.         if (month.Length == 1)
  140.         {
  141.             month = "0" + month;
  142.         }
  143.         string day = Begindate.SelectedDate.Day.ToString();
  144.         if (day.Length == 1)
  145.         {
  146.             day = "0" + day;
  147.         }
  148.         b_time.Text = year + month + day + "000000";
  149.         b_time.Focus();
  150.     }
  151.     protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
  152.     {
  153.         if (Enddate.Visible == true)
  154.         {
  155.             Enddate.Visible = false;
  156.             Enddate.Focus();
  157.         }
  158.         else
  159.         {
  160.             Enddate.Visible = true;
  161.             Enddate.Focus();
  162.         }
  163.     }
  164.     protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  165.     {
  166.         if (Begindate.Visible == true)
  167.         {
  168.             Begindate.Visible = false;
  169.             Begindate.Focus();
  170.         }
  171.         else
  172.         {
  173.             Begindate.Visible = true;
  174.             Begindate.Focus();
  175.         }
  176.     }
  177.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  178.     {
  179.         if (e.Row.RowType == DataControlRowType.DataRow)
  180.         {
  181.             e.Row.Attributes.Add("onmouseover", "this.style.cursor='pointer';");
  182.             e.Row.Attributes.Add("onclick", "location.href='edit.aspx?form_id=" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + "'");
  183.         }
  184.     }
  185.     protected void btn_ok_Click(object sender, EventArgs e)
  186.     {
  187.         bind();
  188.     }
  189.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  190.     {
  191.         GridView1.PageIndex = e.NewPageIndex;
  192.         bind();
  193.     }
  194. }