employee_mendian.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:7k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Text;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Data.SqlClient;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Drawing;
- using System.Net.Mail;
- using System.Net;
- using System.Net.Sockets;
- public partial class web_EMPLOYEE_MENDIAN : System.Web.UI.Page
- {
- private Label[] labels = new Label[20];
- private Label[] labels1 = new Label[20];
- private DropDownList[] dropdownlists=new DropDownList[20];
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- int i = 160;
- int j = 56;
- int k = 307;
- int p = 180;
- int m = 0;
- DateMgr mgr = new DateMgr();
- string today = mgr.getDate();
- ArrayList num = new ArrayList();
- string user_id = Session["user_id"].ToString();
- this.Label2.Text = Convert.ToString(today.Substring(0, 10));
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- 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);
- string department = Convert.ToString(sqlcomm4.ExecuteScalar());
- conn1.Close();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcomm3 = new SqlCommand("select * from oa_pos_type where department='"+department+"'", conn);
- SqlDataReader comm = sqlcomm3.ExecuteReader();
- while (comm.Read())
- {
- num.Add(Convert.ToString(comm["type"]));
- Table1.Visible = true;
- TableRow tr1 = new TableRow();
- TableCell td1 = new TableCell();
- td1.BorderWidth = Unit.Pixel(1);
- Label label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = comm["type"].ToString();
- td1.Controls.Add(label);
- tr1.Cells.Add(td1);
- TableCell td2 = new TableCell();
- td2.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = comm["bengin_time"].ToString();
- td2.Controls.Add(label);
- tr1.Cells.Add(td2);
- TableCell td3 = new TableCell();
- td3.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = comm["end_time"].ToString();
- td3.Controls.Add(label);
- tr1.Cells.Add(td3);
- Table1.Rows.Add(tr1);
- }
- comm.Close();
- Label label1 = new Label();
- label1.Text = "姓名";
- label1.Style["height"] = "12px";
- label1.Style["width"] = "115px";
- label1.Style["top"] = i+"px";
- label1.Style["left"] = j+"px";
- label1.Style["position"] = "absolute";
- label1.Style["text-align"] = "center";
- label1.Style["vertical-align"] = "middle";
- this.form1.Controls.Add(label1);
- Label label2 = new Label();
- label2.Text = "工号";
- label2.Style["height"] = "12px";
- label2.Style["width"] = "115px";
- label2.Style["top"] = i+"px";
- label2.Style["left"] = p+"px";
- label2.Style["position"] = "absolute";
- label2.Style["text-align"] = "center";
- label2.Style["vertical-align"] = "middle";
- this.form1.Controls.Add(label2);
- Label label3 = new Label();
- label3.Text = "班别";
- label3.Style["height"] = "12px";
- label3.Style["width"] = "115px";
- label3.Style["top"] = i+"px";
- label3.Style["left"] = k+"px";
- label3.Style["position"] = "absolute";
- label3.Style["text-align"] = "center";
- label3.Style["vertical-align"] = "middle";
- this.form1.Controls.Add(label3);
- i = i + 22;
- 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);
- this.Label3.Text = Convert.ToString(sqlcomm1.ExecuteScalar());
- 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);
- SqlDataReader dr = sqlcomm2.ExecuteReader();
- while (dr.Read())
- {
- Label lb = new Label();
- lb.Text = Convert.ToString(dr["emp_name"]);
- lb.BorderWidth = Unit.Pixel(1);
- lb.Style["height"] = "12px";
- lb.Style["width"] = "115px";
- lb.Style["text-align"] = "center";
- lb.Style["top"] = i+"px";
- lb.Style["left"] = j + "px";
- lb.Style["position"] = "absolute";
- Label lb1 = new Label();
- lb1.Text = Convert.ToString(dr["emp_no"]);
- lb1.Style["height"] = "12px";
- lb1.Style["width"] = "115px";
- lb1.Style["text-align"] = "center";
- lb1.Style["top"] = i + "px";
- lb1.Style["left"] = p + "px";
- lb1.Style["position"] = "absolute";
- DropDownList dl = new DropDownList();
- dl.Style["height"] = "12px";
- dl.Style["width"] = "115px";
- dl.Style["top"] = i + "px";
- dl.Style["left"] = k + "px";
- dl.Style["position"] = "absolute";
- dl.BorderWidth = Unit.Pixel(1);
- foreach (string n in num)
- {
- dl.Items.Add(n);
- }
- this.form1.Controls.Add(lb1);
- this.form1.Controls.Add(lb);
- this.form1.Controls.Add(dl);
- i = i + 22;
- this.labels1[m] = lb1;
- this.dropdownlists[m] = dl;
- this.labels[m] = lb;
- m++;
- }
- Button Button1 = new Button();
- Button1.Text = "确定";
- Button1.Style["top"] = i + "px";
- Button1.Style["left"] = "210px";
- Button1.Style["position"] = "absolute";
- Button1.Style["height"] = "25px";
- Button1.Style["width"] = "55px";
- Button1.Click += new System.EventHandler(this.Button1_Click);
- this.form1.Controls.Add(Button1);
- dr.Close();
- conn.Close();
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- int id = 0;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- try
- {
- for (int q = 0; q < 20; q++)
- {
- if (labels[q]!= null)
- {
- 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);
- cmd.ExecuteNonQuery();
- id++;
- }
- }
- this.Label4.Text = "排班成功";
- this.Label4.ForeColor = System.Drawing.Color.Red;
- }
- catch (Exception e1)
- {
- this.Label4.Text = "该天已排班,请不要重复排班!";
- this.Label4.ForeColor = System.Drawing.Color.Red;
- }
- conn.Close();
- }
- }