class.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:6k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Collections;
- 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;
- public partial class web_class : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- shift_table.Visible = false;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand comm = 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='156'", conn);
- try
- {
- Label1.Text = comm.ExecuteScalar().ToString();
- }
- catch
- {
- }
- conn.Close();
- set_table();
- }
- }
- private void set_table()
- {
- int num = 1;
- shift_table.Visible = true;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- td.Text = "工号";
- tr.Cells.Add(td);
- td = new TableCell();
- td.Text = "姓名";
- tr.Cells.Add(td);
- SqlCommand sqlcom1 = new SqlCommand("select day_of_month,the_day from time_demo where the_year='" + dr_year.SelectedValue.ToString() + "'and the_month='" + dr_month.SelectedValue.ToString() + "'", conn);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- td = new TableCell();
- if ((dr1["the_day"].ToString().Equals("星期日")) || (dr1["the_day"].ToString().Equals("星期六")))
- {
- td.Text = dr1["day_of_month"].ToString() + "<br>" + dr1["the_day"].ToString();
- td.ForeColor = System.Drawing.Color.Red;
- }
- else
- {
- td.Text = dr1["day_of_month"].ToString() + "<br>" + dr1["the_day"].ToString();
- }
- tr.Cells.Add(td);
- num = num + 1;
- }
- }
- shift_table.Rows.Add(tr);
- dr1.Close();
- SqlCommand sqlcom2 = new SqlCommand("select f.emp_no as emp_no,f.emp_name as emp_name from oa_employee as f , oa_department as g where f.department_id=g.id and g.name='" + Label1.Text + "'", conn);
- SqlDataReader dr2 = sqlcom2.ExecuteReader();
- if (dr2.HasRows)
- {
- while (dr2.Read())
- {
- TableRow tr_1 = new TableRow();
- TableCell td_1 = new TableCell();
- td_1.Text = dr2["emp_no"].ToString();
- tr_1.Cells.Add(td_1);
- td_1 = new TableCell();
- td_1.Text = dr2["emp_name"].ToString();
- tr_1.Cells.Add(td_1);
- for (int i = 0; i < (num-1); i++)
- {
- TableCell td_2 = new TableCell();
- DropDownList dl = new DropDownList();
- dl.Items.Add("");
- SqlConnection sqlcon = dbConnection.getConnection();
- sqlcon.Open();
- SqlCommand sqlcom = new SqlCommand("select type from oa_pos_type where department='" + Label1.Text + "'", sqlcon);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- dl.Items.Add(dr["type"].ToString());
- }
- }
- dr.Close();
- td_2.Controls.Add(dl);
- tr_1.Cells.Add(td_2);
- sqlcon.Close();
- }
- shift_table.Rows.Add(tr_1);
- }
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- for (int i = 1; i < shift_table.Rows.Count; i++)
- {
- for (int j = 2; j < shift_table.Rows[i].Cells.Count; j++)
- {
- string str = dr_year.SelectedValue.ToString();
- if (dr_month.SelectedValue.ToString().Length == 1)
- {
- str = str + "0" + dr_month.SelectedValue.ToString();
- }
- else
- {
- str = str + dr_month.SelectedValue.ToString();
- }
- string str_1 = shift_table.Rows[0].Cells[j].Text.ToString();
- string [] str_2 = str_1.Split('<');
- if (str[0].ToString().Length == 1)
- {
- str = str + "0" +str_2[0];
- }
- else
- {
- str = str + str_2[0];
- }
- if (!(((DropDownList)(shift_table.Rows[i].Cells[j].Controls[0])).SelectedValue.ToString().Equals("")))
- {
- SqlCommand comm = new SqlCommand("insert into oa_kaoqin_pbb (data,name,emp_no,banbie) values('" + str + "','" + shift_table.Rows[i].Cells[1].Text.ToString() + "','" + shift_table.Rows[i].Cells[0].Text.ToString() + "','" +((DropDownList)(shift_table.Rows[i].Cells[j].Controls[0])).SelectedValue.ToString() + "')", conn);
- comm.ExecuteNonQuery();
- }
- else
- {
- continue;
- }
- }
- }
- conn.Close();
- }
- }