p_work1.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:4k
源码类别:
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;
- public partial class web_EMPLOYEE_MENDIAN : System.Web.UI.Page
- {
- private Label[] labels = new Label[20];
- private DropDownList[] dropdownlists=new DropDownList[20];
- protected void Page_Load(object sender, EventArgs e)
- {
- int i = 110;
- int j = 100;
- int k = 290;
- int m = 0;
- DateMgr mgr = new DateMgr();
- string today = mgr.getDate();
- ArrayList num = new ArrayList();
- this.Label2.Text = Convert.ToString(today.Substring(0, 10));
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcomm3 = new SqlCommand("select type from oa_pos_type", conn);
- SqlDataReader comm = sqlcomm3.ExecuteReader();
- while (comm.Read())
- {
- num.Add(Convert.ToString(comm["type"]));
- }
- comm.Close();
- 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 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.Style["align"] = "center";
- lb.Text = Convert.ToString(dr["emp_name"]);
- lb.BorderWidth = Unit.Pixel(1);
- lb.Style["height"] = "12px";
- lb.Style["width"] = "115px";
- lb.Style["top"] = i+"px";
- lb.Style["left"] = j + "px";
- lb.Style["position"] = "absolute";
- DropDownList dl = new DropDownList();
- // dl.Style["align"]="center";
- 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(lb);
- this.form1.Controls.Add(dl);
- i = i + 22;
- this.dropdownlists[m] = dl;
- this.labels[m] = lb;
- m++;
- }
- Button Button1 = new Button();
- Button1.Text = "确定";
- Button1.Style["top"] = i + "px";
- Button1.Style["left"] = "232px";
- 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,department_name,banbie)values('" + Label2.Text + "','" + labels[q].Text + "','" + Label3.Text + "','" + dropdownlists[q].Text + "')", conn);
- cmd.ExecuteNonQuery();
- id++;
- }
- }
- Response.Write("<script>更新成功!</script>");
- Response.Write("更新成功!");
- }
- catch (Exception e1)
- {
- Response.Write(e1.Message);
- Response.Write("<script>更新失败!</script>");
- Response.Write("更新失败!");
- }
- conn.Close();
- }
- }