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

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. public partial class web_new_repair_select : 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.             ArrayList array = new ArrayList();
  21.             array = (ArrayList)Session["s"];
  22.             if (array.Count != 0)
  23.             {
  24.                 for (int j = 0; j < array.Count; j++)
  25.                 {
  26.                     DropDownList1.Items.Add(Convert.ToString(j + 1));
  27.                 }
  28.             }
  29.             if (Request.QueryString["form_id"] != null)
  30.             {
  31.                 bind(Request.QueryString["form_id"]);
  32.                 for (int i = 0; i < array.Count; i++)
  33.                 {
  34.                     if (array[i].ToString().Equals(Request.QueryString["form_id"].ToString()))
  35.                     {
  36.                         DropDownList1.SelectedIndex = i;
  37.                     }
  38.                 }
  39.             }
  40.             
  41.             dll.Items.Clear();
  42.             dll.Items.Add("所有厂商");
  43.             SqlCommand sqlcom1 = new SqlCommand("select company from OA_COMPANY where equipment='" + type.Text.ToString() + "' order by id", conn);
  44.             SqlDataReader dr1 = sqlcom1.ExecuteReader();
  45.             if (dr1.HasRows)
  46.             {
  47.                 while (dr1.Read())
  48.                 {
  49.                     dll.Items.Add(dr1["company"].ToString());
  50.                 }
  51.             }
  52.             dr1.Close();
  53.         }
  54.     }
  55.     public void bind(string s)
  56.     {
  57.         string str = "";
  58.         SqlConnection conn = dbConnection.getConnection();
  59.         conn.Open();
  60.         form_id.Text = s;
  61.         SqlCommand sqlcom4 = new SqlCommand("select * from oa_repair where form_id='" + s + "'", conn);
  62.         SqlDataReader dr4 = sqlcom4.ExecuteReader();
  63.         if (dr4.HasRows)
  64.         {
  65.             while (dr4.Read())
  66.             {
  67.                 area.Text = dr4["area"].ToString().Trim();
  68.                 level.Text = dr4["Level"].ToString().Trim();
  69.                 bxperson.Text = dr4["bxperson"].ToString().Trim();
  70.                 department.Text = dr4["department"].ToString();
  71.                 type.Text = dr4["type"].ToString();
  72.                 equipment.Text = dr4["equipment"].ToString();
  73.                 create_time.Text = dr4["create_time"].ToString();
  74.                 SqlConnection conn1 = dbConnection.getConnection();
  75.                 conn1.Open();
  76.                 SqlCommand sqlcom5 = new SqlCommand("select emp_name from oa_employee where id=" + Convert.ToInt32(dr4["lbperson"]), conn1);
  77.                 SqlDataReader dr5 = sqlcom5.ExecuteReader();
  78.                 if (dr5.HasRows)
  79.                 {
  80.                     while (dr5.Read())
  81.                     {
  82.                         lbperson.Text = dr5["emp_name"].ToString();
  83.                     }
  84.                 }
  85.                 dr5.Close();
  86.                 SqlCommand sqlcom6 = new SqlCommand("select tel from oa_department where name='" + dr4["department"].ToString() + "'", conn1);
  87.                 SqlDataReader dr6 = sqlcom6.ExecuteReader();
  88.                 if (dr6.HasRows)
  89.                 {
  90.                     while (dr6.Read())
  91.                     {
  92.                         tel.Text = dr6["tel"].ToString();
  93.                     }
  94.                 }
  95.                 dr6.Close();
  96.             }
  97.         }
  98.         dr4.Close();
  99.         SqlCommand sqlcom7 = new SqlCommand("select destine_time from OA_REPAIR_D where form_id='" + s + "'", conn);
  100.         SqlDataReader dr7 = sqlcom7.ExecuteReader();
  101.         if (dr7.HasRows)
  102.         {
  103.             while (dr7.Read())
  104.             {
  105.                 if (!dr7["destine_time"].ToString().Equals(""))
  106.                 {
  107.                     ImageButton3.Enabled = false;
  108.                     destine_time.Text = dr7["destine_time"].ToString();
  109.                     destine_time.Enabled = false;
  110.                 }
  111.                 else
  112.                 {
  113.                     ImageButton3.Enabled = true;
  114.                     destine_time.Enabled = true;
  115.                 }
  116.             }
  117.         }
  118.         dr7.Close();
  119.         SqlCommand sqlcom9 = new SqlCommand("select complete_time from OA_REPAIR_D where form_id='" + s + "'", conn);
  120.         SqlDataReader dr9 = sqlcom9.ExecuteReader();
  121.         if (dr9.HasRows)
  122.         {
  123.             while (dr9.Read())
  124.             {
  125.                 if (!dr9["complete_time"].ToString().Equals(""))
  126.                 {
  127.                     complete_time.Text = dr9["complete_time"].ToString();
  128.                 }
  129.             }
  130.         }
  131.         dr9.Close();
  132.         SqlCommand sqlcom10 = new SqlCommand("select [confirm] from OA_REPAIR_D where form_id='" + s + "'", conn);
  133.         SqlDataReader dr10 = sqlcom10.ExecuteReader();
  134.         if (dr10.HasRows)
  135.         {
  136.             while (dr10.Read())
  137.             {
  138.                 if (!dr10["confirm"].ToString().Equals(""))
  139.                 {
  140.                     confirm.Text = dr10["confirm"].ToString();
  141.                 }
  142.             }
  143.         }
  144.         dr10.Close();
  145.         SqlCommand sqlcom11 = new SqlCommand("select remark from OA_REPAIR_D where form_id='" + s + "'", conn);
  146.         SqlDataReader dr11 = sqlcom11.ExecuteReader();
  147.         if (dr11.HasRows)
  148.         {
  149.             while (dr11.Read())
  150.             {
  151.                 if (!dr11["remark"].ToString().Equals(""))
  152.                 {
  153.                     remark.Text = dr11["remark"].ToString();
  154.                 }
  155.             }
  156.         }
  157.         dr11.Close();
  158.             SqlCommand sqlcom8 = new SqlCommand("select company from OA_repair_d where form_id='" + s + "'", conn);
  159.             str = sqlcom8.ExecuteScalar().ToString();
  160.             for (int j = 0; j < dll.Items.Count; j++)
  161.             {
  162.                 if (dll.Items[j].Text.ToString().Equals(str))
  163.                 {
  164.                     dll.SelectedIndex = j;
  165.                     break;
  166.                 }
  167.             }
  168.         conn.Close();
  169.     }
  170.     protected void Button1_Click(object sender, EventArgs e)
  171.     {
  172.        
  173.         SqlConnection conn = dbConnection.getConnection();
  174.         conn.Open();
  175.         if (!dll.SelectedItem.ToString().Equals(""))
  176.         {
  177.             string sqlstr = "update oa_repair_d set company='" + dll.SelectedItem.ToString() + "'";
  178.             if (!destine_time.Text.ToString().Equals(""))
  179.             {
  180.                 sqlstr = sqlstr + ",destine_time='" + destine_time.Text.ToString()+"'";
  181.             }
  182.             sqlstr = sqlstr + "where form_id='" + form_id.Text.ToString() + "'";
  183.             SqlCommand sqlcom = new SqlCommand(sqlstr,conn);
  184.             sqlcom.ExecuteNonQuery();
  185.             ShowMessageBox("操作成功");
  186.         }
  187.         else
  188.         {
  189.             ShowMessageBox("请选择维修厂商");
  190.         }
  191.         conn.Close();
  192.     }
  193.     protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
  194.     {
  195.         if (Calendar1.Visible == true)
  196.         {
  197.             Calendar1.Visible = false;
  198.             Calendar1.Focus();
  199.         }
  200.         else
  201.         {
  202.             Calendar1.Visible = true;
  203.             Calendar1.Focus();
  204.         }
  205.     }
  206.     protected void Calendar1_SelectionChanged(object sender, EventArgs e)
  207.     {
  208.         Calendar1.Visible = false;
  209.         string year = Calendar1.SelectedDate.Year.ToString();
  210.         string month = Calendar1.SelectedDate.Month.ToString();
  211.         if (month.Length == 1)
  212.         {
  213.             month = "0" + month;
  214.         }
  215.         string day = Calendar1.SelectedDate.Day.ToString();
  216.         if (day.Length == 1)
  217.         {
  218.             day = "0" + day;
  219.         }
  220.         destine_time.Text = year + month + day ;
  221.         destine_time.Focus();
  222.     }
  223.     protected void ShowMessageBox(string strMessage)
  224.     {
  225.         Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
  226.     }
  227.     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  228.     {
  229.         form_id.Text = "";
  230.         department.Text = "";
  231.         lbperson.Text = "";
  232.         create_time.Text = "";
  233.         type.Text="";
  234.         equipment.Text = "";
  235.         tel.Text = "";
  236.         confirm.Text = "";
  237.         destine_time.Text = "";
  238.         complete_time.Text = "";
  239.         remark.Text = "";
  240.         ArrayList array = new ArrayList();
  241.         array = (ArrayList)Session["s"];
  242.         int id = Convert.ToInt32(DropDownList1.SelectedItem.ToString());
  243.         id = id - 1;
  244.         bind(array[id].ToString());
  245.     }
  246. }