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

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. using System.Net.Mail;
  15. using System.Net;
  16. using System.Net.Sockets;
  17. public partial class web_EMPLOYEE_MENDIAN : System.Web.UI.Page
  18.     private Label[] labels = new Label[20];
  19.     private Label[] labels1 = new Label[20];
  20.     private DropDownList[] dropdownlists=new DropDownList[20];
  21.     protected void Page_Load(object sender, EventArgs e)
  22.     {
  23.         LoginDAO.CheckLogin(Session, Response, "../", 2);
  24.         int i = 160;
  25.         int j = 56;
  26.         int k = 307;
  27.         int p = 180;
  28.         int m = 0;
  29.         DateMgr mgr = new DateMgr();
  30.         string today = mgr.getDate();
  31.         ArrayList num = new ArrayList();
  32.         string user_id = Session["user_id"].ToString();
  33.         this.Label2.Text = Convert.ToString(today.Substring(0, 10));
  34.         SqlConnection conn1 = dbConnection.getConnection();
  35.         conn1.Open();
  36.         SqlCommand sqlcomm4 = 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='"+user_id+"'",conn1);
  37.         string department = Convert.ToString(sqlcomm4.ExecuteScalar());
  38.         conn1.Close();
  39.         SqlConnection conn = dbConnection.getConnection();
  40.         conn.Open();
  41.         SqlCommand sqlcomm3 = new SqlCommand("select * from oa_pos_type where department='"+department+"'", conn);
  42.         SqlDataReader comm = sqlcomm3.ExecuteReader();
  43.         while (comm.Read())
  44.         {
  45.             num.Add(Convert.ToString(comm["type"]));
  46.             Table1.Visible = true;
  47.             TableRow tr1 = new TableRow();
  48.             TableCell td1 = new TableCell();
  49.             td1.BorderWidth = Unit.Pixel(1);
  50.             Label label = new Label();
  51.             label.BorderStyle = BorderStyle.None;
  52.             label.Text = comm["type"].ToString();
  53.             td1.Controls.Add(label);
  54.             tr1.Cells.Add(td1);
  55.             TableCell td2 = new TableCell();
  56.             td2.BorderWidth = Unit.Pixel(1);
  57.             label = new Label();
  58.             label.BorderStyle = BorderStyle.None;
  59.             label.Text = comm["bengin_time"].ToString();
  60.             td2.Controls.Add(label);
  61.             tr1.Cells.Add(td2);
  62.             TableCell td3 = new TableCell();
  63.             td3.BorderWidth = Unit.Pixel(1);
  64.             label = new Label();
  65.             label.BorderStyle = BorderStyle.None;
  66.             label.Text = comm["end_time"].ToString();
  67.             td3.Controls.Add(label);
  68.             tr1.Cells.Add(td3);
  69.             Table1.Rows.Add(tr1);
  70.         }
  71.         comm.Close();
  72.         Label label1 = new Label();
  73.         label1.Text = "姓名";
  74.         label1.Style["height"] = "12px";
  75.         label1.Style["width"] = "115px";
  76.         label1.Style["top"] = i+"px";
  77.         label1.Style["left"] = j+"px";
  78.         label1.Style["position"] = "absolute";
  79.         label1.Style["text-align"] = "center";
  80.         label1.Style["vertical-align"] = "middle";
  81.         this.form1.Controls.Add(label1);
  82.         Label label2 = new Label();
  83.         label2.Text = "工号";
  84.         label2.Style["height"] = "12px";
  85.         label2.Style["width"] = "115px";
  86.         label2.Style["top"] = i+"px";
  87.         label2.Style["left"] = p+"px";
  88.         label2.Style["position"] = "absolute";
  89.         label2.Style["text-align"] = "center";
  90.         label2.Style["vertical-align"] = "middle";
  91.         this.form1.Controls.Add(label2);
  92.         Label label3 = new Label();
  93.         label3.Text = "班别";
  94.         label3.Style["height"] = "12px";
  95.         label3.Style["width"] = "115px";
  96.         label3.Style["top"] = i+"px";
  97.         label3.Style["left"] = k+"px";
  98.         label3.Style["position"] = "absolute";
  99.         label3.Style["text-align"] = "center";
  100.         label3.Style["vertical-align"] = "middle";
  101.         this.form1.Controls.Add(label3);
  102.         i = i + 22;
  103.         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);
  104.         this.Label3.Text = Convert.ToString(sqlcomm1.ExecuteScalar());
  105.         SqlCommand sqlcomm2 = new SqlCommand("select f.emp_name as emp_name ,f.emp_no as emp_no  from OA_EMPLOYEE as f ,OA_DEPARTMENT as g where f.department_id=g.id and g.name='" + Label3.Text + "'", conn);
  106.         SqlDataReader dr = sqlcomm2.ExecuteReader();
  107.         while (dr.Read())
  108.         {
  109.             Label lb = new Label();
  110.             lb.Text = Convert.ToString(dr["emp_name"]);
  111.             lb.BorderWidth = Unit.Pixel(1);
  112.             lb.Style["height"] = "12px";
  113.             lb.Style["width"] = "115px";
  114.             lb.Style["text-align"] = "center";
  115.             lb.Style["top"] = i+"px";
  116.             lb.Style["left"] = j + "px";
  117.             lb.Style["position"] = "absolute";
  118.             Label lb1 = new Label();
  119.             lb1.Text = Convert.ToString(dr["emp_no"]);
  120.             lb1.Style["height"] = "12px";
  121.             lb1.Style["width"] = "115px";
  122.             lb1.Style["text-align"] = "center";
  123.             lb1.Style["top"] = i + "px";
  124.             lb1.Style["left"] = p + "px";
  125.             lb1.Style["position"] = "absolute";
  126.             DropDownList dl = new DropDownList();
  127.             dl.Style["height"] = "12px";
  128.             dl.Style["width"] = "115px";
  129.             dl.Style["top"] = i + "px";
  130.             dl.Style["left"] = k + "px";
  131.             dl.Style["position"] = "absolute";
  132.             dl.BorderWidth = Unit.Pixel(1);
  133.             foreach (string n in num)
  134.             {
  135.                 dl.Items.Add(n);
  136.             }
  137.             this.form1.Controls.Add(lb1);
  138.             this.form1.Controls.Add(lb);
  139.             this.form1.Controls.Add(dl);
  140.             i = i + 22;
  141.             this.labels1[m] = lb1;
  142.             this.dropdownlists[m] = dl;
  143.             this.labels[m] = lb;
  144.             m++;
  145.         }
  146.         Button Button1 = new Button();
  147.         Button1.Text = "确定";
  148.         Button1.Style["top"] = i + "px";
  149.         Button1.Style["left"] = "210px";
  150.         Button1.Style["position"] = "absolute";
  151.         Button1.Style["height"] = "25px";
  152.         Button1.Style["width"] = "55px";
  153.         Button1.Click += new System.EventHandler(this.Button1_Click);
  154.         this.form1.Controls.Add(Button1);
  155.         dr.Close();
  156.         conn.Close();
  157.     }
  158.     protected void Button1_Click(object sender, EventArgs e)
  159.     {
  160.         int id = 0;
  161.         SqlConnection conn = dbConnection.getConnection();
  162.         conn.Open();
  163.         try
  164.         {
  165.         for (int q = 0; q < 20; q++)
  166.         {
  167.             if (labels[q]!= null)
  168.             {
  169.                 SqlCommand cmd = new SqlCommand("insert into OA_KAOQIN_PBB(data ,name,emp_no,department_name,banbie)values('" + Label2.Text + "','" + labels[q].Text + "','" + labels1[q].Text + "','" + Label3.Text + "','" + dropdownlists[q].Text + "')", conn);
  170.                 cmd.ExecuteNonQuery();
  171.                 id++;
  172.             }
  173.         }
  174.             this.Label4.Text = "排班成功";
  175.             this.Label4.ForeColor = System.Drawing.Color.Red;
  176.         }
  177.         catch (Exception e1)
  178.         {
  179.             this.Label4.Text = "该天已排班,请不要重复排班!";
  180.             this.Label4.ForeColor = System.Drawing.Color.Red;
  181.         }
  182.         conn.Close();
  183.     }
  184. }