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

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Text;
  3. using System.Data;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Data.SqlClient;
  7. using System.Web;
  8. using System.Web.Security;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Web.UI.HtmlControls;
  13. using System.Drawing;
  14. public partial class web_EMPLOYEE_MENDIAN : System.Web.UI.Page
  15.     private Label[] labels = new Label[20];
  16.     private DropDownList[] dropdownlists=new DropDownList[20];
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         int i = 110;
  20.         int j = 100;
  21.         int k = 290;
  22.         int m = 0;
  23.         DateMgr mgr = new DateMgr();
  24.         string today = mgr.getDate();
  25.         ArrayList num = new ArrayList();
  26.         this.Label2.Text = Convert.ToString(today.Substring(0, 10));
  27.         SqlConnection conn = dbConnection.getConnection();
  28.         conn.Open();
  29.         SqlCommand sqlcomm3 = new SqlCommand("select type from oa_pos_type", conn);
  30.         SqlDataReader comm = sqlcomm3.ExecuteReader();
  31.         while (comm.Read())
  32.         {
  33.             num.Add(Convert.ToString(comm["type"]));
  34.         }
  35.         comm.Close();
  36.         SqlCommand sqlcomm1 = new SqlCommand("select f.name as name from OA_DEPARTMENT as f ,OA_EMPLOYEE as g where f.id = g.department_id and g.id='"+Session["user_id"]+"'", conn);
  37.         this.Label3.Text = Convert.ToString(sqlcomm1.ExecuteScalar());
  38.         SqlCommand sqlcomm2 = new SqlCommand("select f.emp_name as emp_name from OA_EMPLOYEE as f ,OA_DEPARTMENT as g where f.department_id=g.id and g.name='"+Label3.Text+"'",conn);
  39.         SqlDataReader dr = sqlcomm2.ExecuteReader();
  40.         while (dr.Read())
  41.         {
  42.             Label lb = new Label();
  43.            // lb.Style["align"] = "center";
  44.             lb.Text = Convert.ToString(dr["emp_name"]);
  45.             lb.BorderWidth = Unit.Pixel(1);
  46.             lb.Style["height"] = "12px";
  47.             lb.Style["width"] = "115px";
  48.             lb.Style["top"] = i+"px";
  49.             lb.Style["left"] = j + "px";
  50.             lb.Style["position"] = "absolute";
  51.             DropDownList dl = new DropDownList();
  52.            // dl.Style["align"]="center";
  53.             dl.Style["height"] = "12px";
  54.             dl.Style["width"] = "115px";
  55.             dl.Style["top"] = i + "px";
  56.             dl.Style["left"] = k + "px";
  57.             dl.Style["position"] = "absolute";
  58.             dl.BorderWidth = Unit.Pixel(1);
  59.             foreach (string n in num)
  60.             {
  61.                 dl.Items.Add(n);
  62.             }
  63.             this.form1.Controls.Add(lb);
  64.             this.form1.Controls.Add(dl);
  65.             i = i + 22;
  66.             this.dropdownlists[m] = dl;
  67.             this.labels[m] = lb;
  68.             m++;
  69.         }
  70.         Button Button1 = new Button();
  71.         Button1.Text = "确定";
  72.         Button1.Style["top"] = i + "px";
  73.         Button1.Style["left"] = "232px";
  74.         Button1.Style["position"] = "absolute";
  75.         Button1.Style["height"] = "25px";
  76.         Button1.Style["width"] = "55px";
  77.         Button1.Click += new System.EventHandler(this.Button1_Click);
  78.         this.form1.Controls.Add(Button1);
  79.         dr.Close();
  80.         conn.Close();
  81.     }
  82.     protected void Button1_Click(object sender, EventArgs e)
  83.     {
  84.         int id = 0;
  85.         SqlConnection conn = dbConnection.getConnection();
  86.         conn.Open();
  87.         try
  88.         {
  89.         for (int q = 0; q < 20; q++)
  90.         {
  91.             if (labels[q]!= null)
  92.             {
  93.                 SqlCommand cmd = new SqlCommand("insert into OA_KAOQIN_PBB(data ,name,department_name,banbie)values('" + Label2.Text + "','" + labels[q].Text + "','" + Label3.Text + "','" + dropdownlists[q].Text + "')", conn);
  94.                 cmd.ExecuteNonQuery();
  95.                 id++;
  96.             }
  97.         }
  98.             Response.Write("<script>更新成功!</script>");
  99.             Response.Write("更新成功!");
  100.         }
  101.         catch (Exception e1)
  102.         {
  103.             Response.Write(e1.Message);
  104.             Response.Write("<script>更新失败!</script>");
  105.             Response.Write("更新失败!");
  106.         }
  107.         conn.Close();
  108.     }
  109. }