show_work_2.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:24k
源码类别:
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;
- using Microsoft.Office.Interop.Excel;
- using Microsoft.Office.Interop;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using ExcelApplication = Microsoft.Office.Interop.Excel.Application;
- using Label = System.Web.UI.WebControls.Label;
- public partial class web_pos_c_show_work : System.Web.UI.Page
- {
- int id = 0;
- ArrayList array1 = new ArrayList();
- ArrayList array2 = new ArrayList();
- ArrayList array3 = new ArrayList();
- protected void Page_Load(object sender, EventArgs e)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand comm1 = new SqlCommand("select id from OA_DEPARTMENT where name='中山隆成啟航商貿有限公司'", conn);
- id = Convert.ToInt32(comm1.ExecuteScalar());
- SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where last_id='" + id + "'", conn);
- SqlDataReader comm2 = sqlcom2.ExecuteReader();
- while (comm2.Read())
- {
- array1.Add(Convert.ToInt32(comm2["id"]));
- }
- comm2.Close();
- foreach (int i in array1)
- {
- ArrayList array5 = new ArrayList();
- array5.Add(i);
- SqlCommand sqlcom3 = new SqlCommand("select id from OA_DEPARTMENT where last_id='" + i + "'", conn);
- SqlDataReader comm3 = sqlcom3.ExecuteReader();
- if (comm3.HasRows)
- {
- while (comm3.Read())
- {
- array5.Add(Convert.ToInt32(comm3["id"]));
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom4 = new SqlCommand("select id from OA_DEPARTMENT where last_id='" + Convert.ToInt32(comm3["id"]) + "'", conn1);
- SqlDataReader comm4 = sqlcom4.ExecuteReader();
- if (comm4.HasRows)
- {
- while (comm4.Read())
- {
- array5.Add(Convert.ToInt32(comm4["id"]));
- }
- }
- comm4.Close();
- conn1.Close();
- }
- }
- comm3.Close();
- array2.Add(array5);
- }
- conn.Close();
- }
- protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
- {
- if (Calendar1.Visible == true)
- {
- Calendar1.Visible = false;
- Calendar1.Focus();
- }
- else
- {
- Calendar1.Visible = true;
- Calendar1.Focus();
- }
- }
- protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
- {
- if (Calendar2.Visible == true)
- {
- Calendar2.Visible = false;
- Calendar2.Focus();
- }
- else
- {
- Calendar2.Visible = true;
- Calendar2.Focus();
- }
- }
- protected void Calendar1_SelectionChanged(object sender, EventArgs e)
- {
- Calendar1.Visible = false;
- string year = Calendar1.SelectedDate.Year.ToString();
- string month = Calendar1.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Calendar1.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- TextBox1.Text = year + "-" + month + "-" + day;
- TextBox1.Focus();
- }
- protected void Calendar2_SelectionChanged(object sender, EventArgs e)
- {
- Calendar2.Visible = false;
- string year = Calendar2.SelectedDate.Year.ToString();
- string month = Calendar2.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Calendar2.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- TextBox2.Text = year + "-" + month + "-" + day;
- TextBox2.Focus();
- }
- public void show_work()
- {
- int k = 0;
- string nul = " ";
- string department = null;
- float sum = 0;
- string time1 = null;
- string time2 = null;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand sqlcom = new SqlCommand();
- foreach (ArrayList i in array2)
- {
- ArrayList array6 = new ArrayList();
- foreach (int j in i)
- {
- SqlCommand sqlcom1 = new SqlCommand("select emp_no from OA_EMPLOYEE where department_id='" + j + "'", conn);
- SqlDataReader comm1 = sqlcom1.ExecuteReader();
- if (comm1.HasRows)
- {
- while (comm1.Read())
- {
- array6.Add(Convert.ToString(comm1["emp_no"]));
- }
- }
- comm1.Close();
- }
- array3.Add(array6);
- }
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Style["Width"] = "90px";
- td.Text = "中山隆成启航商贸有限公司";
- tr.Cells.Add(td);
- Table1.Rows.Add(tr);
- foreach (ArrayList i in array3)
- {
- if (k < array1.Count)
- {
- SqlConnection conn4 = dbConnection.getConnection();
- conn4.Open();
- SqlCommand sqlcom2 = new SqlCommand("select name from OA_DEPARTMENT where id='" + array1[k] + "'", conn4);
- TableRow tr1 = new TableRow();
- TableCell td1 = new TableCell();
- td1.BorderWidth = Unit.Pixel(1);
- td1.Style["Width"] = "90px";
- d1.Text = Convert.ToString(sqlcom2.ExecuteScalar());
- tr1.Cells.Add(td1);
- Table1.Rows.Add(tr1);
- conn4.Close();
- foreach (string j in i)
- {
- TableRow tr2 = new TableRow();
- TableCell tdd1 = new TableCell();
- tdd1.BorderWidth = Unit.Pixel(1);
- tdd1.Style["Width"] = "90px";
- tdd1.Text = "员工编号";
- tr2.Cells.Add(tdd1);
- TableCell tdd2 = new TableCell();
- tdd2.BorderWidth = Unit.Pixel(1);
- tdd2.Style["Width"] = "90px";
- tdd2.Text = j;
- tr2.Cells.Add(tdd2);
- TableCell tdd3 = new TableCell();
- tdd3.BorderWidth = Unit.Pixel(1);
- tdd3.Style["Width"] = "90px";
- tdd3.Text = "员工名称";
- tr2.Cells.Add(tdd3);
- SqlCommand sqlcom3 = new SqlCommand("select emp_name from OA_EMPLOYEE where emp_no='" + j + "'", conn);
- TableCell tdd4 = new TableCell();
- tdd4.BorderWidth = Unit.Pixel(1);
- tdd4.Style["Width"] = "90px";
- tdd4.Text = Convert.ToString(sqlcom3.ExecuteScalar());
- tr2.Cells.Add(tdd4);
- TableCell tdd5 = new TableCell();
- tdd5.BorderWidth = Unit.Pixel(1);
- tdd5.Style["Width"] = "90px";
- tdd5.Text = "所属部门";
- tr2.Cells.Add(tdd5);
- SqlCommand sqlcom7 = new SqlCommand("select f.name as name from OA_DEPARTMENT as f ,OA_EMPLOYEE as g where f.id=g.department_id and g.emp_no='" + j + "'", conn);
- department = Convert.ToString(sqlcom7.ExecuteScalar());
- TableCell tdd6 = new TableCell();
- tdd6.BorderWidth = Unit.Pixel(1);
- tdd6.Style["Width"] = "90px";
- tdd6.Text = department;
- tr2.Cells.Add(tdd6);
- Table1.Rows.Add(tr2);
- TableRow tr3 = new TableRow();
- TableCell t1 = new TableCell();
- t1.BorderWidth = Unit.Pixel(1);
- t1.Style["Width"] = "90px";
- t1.Text = "日期";
- tr3.Cells.Add(t1);
- TableCell t2 = new TableCell();
- t2.BorderWidth = Unit.Pixel(1);
- t2.Style["Width"] = "90px";
- t2.Text = "星期";
- tr3.Cells.Add(t2);
- TableCell t3 = new TableCell();
- t3.BorderWidth = Unit.Pixel(1);
- t3.Style["Width"] = "90px";
- t3.Text = "班别";
- tr3.Cells.Add(t3);
- TableCell t4 = new TableCell();
- t4.BorderWidth = Unit.Pixel(1);
- t4.Style["Width"] = "90px";
- t4.Text = "排班时间";
- tr3.Cells.Add(t4);
- TableCell t5 = new TableCell();
- t5.BorderWidth = Unit.Pixel(1);
- t5.Style["Width"] = "90px";
- t5.Text = nul;
- tr3.Cells.Add(t5);
- TableCell t6 = new TableCell();
- t6.BorderWidth = Unit.Pixel(1);
- t6.Style["Width"] = "90px";
- t6.Text = "排班门店";
- tr3.Cells.Add(t6);
- TableCell t7 = new TableCell();
- t7.BorderWidth = Unit.Pixel(1);
- t7.Style["Width"] = "90px";
- t7.Text = "签到退时间";
- tr3.Cells.Add(t7);
- TableCell t8 = new TableCell();
- t8.BorderWidth = Unit.Pixel(1);
- t8.Style["Width"] = "90px";
- t8.Text = nul;
- tr3.Cells.Add(t8);
- TableCell t9 = new TableCell();
- t9.BorderWidth = Unit.Pixel(1);
- t9.Style["Width"] = "90px";
- t9.Text = nul;
- tr3.Cells.Add(t9);
- TableCell t10 = new TableCell();
- t10.BorderWidth = Unit.Pixel(1);
- t10.Style["Width"] = "90px";
- t10.Text = nul;
- tr3.Cells.Add(t10);
- TableCell t11 = new TableCell();
- t11.BorderWidth = Unit.Pixel(1);
- t11.Style["Width"] = "90px";
- t11.Text = "签到时数";
- tr3.Cells.Add(t11);
- Table1.Rows.Add(tr3);
- SqlCommand sqlcom4 = new SqlCommand("select distinct data from OA_KAOQIN_JL where data between '" + TextBox1.Text + "'and '" + TextBox2.Text + "' order by data", conn);
- SqlDataReader comm4 = sqlcom4.ExecuteReader();
- while (comm4.Read())
- {
- TableRow tr4 = new TableRow();
- TableCell d1 = new TableCell();
- d1.BorderWidth = Unit.Pixel(1);
- d1.Style["Width"] = "90px";
- d1.Text = Convert.ToString(comm4["data"]);
- tr4.Cells.Add(d1);
- TableCell d2 = new TableCell();
- d2.BorderWidth = Unit.Pixel(1);
- d2.Style["Width"] = "90px";
- d2.Text = getweekday(Convert.ToDateTime(comm4["data"]));
- tr4.Cells.Add(d2);
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom5 = new SqlCommand("select banbie from OA_KAOQIN_PBB where data='" + Convert.ToString(comm4["data"]) + "' and emp_no='" + j + "'", conn1);
- SqlDataReader comm5 = sqlcom5.ExecuteReader();
- if (comm5.HasRows)
- {
- while (comm5.Read())
- {
- TableCell d3 = new TableCell();
- d3.BorderWidth = Unit.Pixel(1);
- d3.Style["Width"] = "90px";
- d3.Text = Convert.ToString(comm5["banbie"]);
- tr4.Cells.Add(d3);
- SqlConnection conn2 = dbConnection.getConnection();
- conn2.Open();
- SqlCommand sqlcom6 = new SqlCommand("select bengin_time,end_time from oa_pos_type where department='" + department + "' and type='" + Convert.ToString(comm5["banbie"]) + "'", conn2);
- SqlDataReader comm6 = sqlcom6.ExecuteReader();
- if (comm6.HasRows)
- {
- while (comm6.Read())
- {
- TableCell d4 = new TableCell();
- d4.BorderWidth = Unit.Pixel(1);
- d4.Style["Width"] = "90px";
- d4.Text = Convert.ToString(comm6["bengin_time"]);
- tr4.Cells.Add(d3);
- TableCell d5 = new TableCell();
- d5.BorderWidth = Unit.Pixel(1);
- d5.Style["Width"] = "90px";
- d5.Text = Convert.ToString(comm6["end_time"]);
- tr4.Cells.Add(d5);
- }
- }
- else
- {
- TableCell d4 = new TableCell();
- d4.BorderWidth = Unit.Pixel(1);
- d4.Style["Width"] = "90px";
- d4.Text = nul;
- tr4.Cells.Add(d3);
- TableCell d5 = new TableCell();
- d5.BorderWidth = Unit.Pixel(1);
- d5.Style["Width"] = "90px";
- d5.Text = nul;
- tr4.Cells.Add(d5);
- }
- comm6.Close();
- conn2.Close();
- TableCell d6 = new TableCell();
- d6.BorderWidth = Unit.Pixel(1);
- d6.Style["Width"] = "90px";
- d6.Text = department;
- tr4.Cells.Add(d6);
- }
- }
- else
- {
- TableCell d3 = new TableCell();
- d3.BorderWidth = Unit.Pixel(1);
- d3.Style["Width"] = "90px";
- d3.Visible = true;
- d3.Text = nul;
- tr4.Cells.Add(d3);
- TableCell d4 = new TableCell();
- d4.BorderWidth = Unit.Pixel(1);
- d4.Style["Width"] = "90px";
- d4.Text = nul;
- tr4.Cells.Add(d3);
- TableCell d5 = new TableCell();
- d5.BorderWidth = Unit.Pixel(1);
- d5.Style["Width"] = "90px";
- d5.Text = nul;
- tr4.Cells.Add(d5);
- TableCell d6 = new TableCell();
- d6.BorderWidth = Unit.Pixel(1);
- d6.Style["Width"] = "90px";
- d6.Text = nul;
- tr4.Cells.Add(d6);
- //}
- }
- comm5.Close();
- conn1.Close();
- SqlConnection conn3 = dbConnection.getConnection();
- conn3.Open();
- SqlCommand sqlcom8 = new SqlCommand("select f.zao as zao,f.wan as wan,f.wuxia as wuxia,f.wushang as wushang from OA_KAOQIN_JL as f,OA_EMPLOYEE as g where f.card_id=g.work_card_no1 and g.emp_no='" + j + "'and data='" + Convert.ToString(comm4["data"]) + "'", conn3);
- SqlDataReader comm8 = sqlcom8.ExecuteReader();
- if (comm8.HasRows)
- {
- while (comm8.Read())
- {
- time1 = Convert.ToString(comm8["zao"]);
- time2 = Convert.ToString(comm8["wan"]);
- TableCell d7 = new TableCell();
- d7.BorderWidth = Unit.Pixel(1);
- d7.Style["Width"] = "90px";
- d7.Text = Convert.ToString(comm8["zao"]);
- if (d7.Text.Equals(""))
- {
- d7.Text = nul;
- }
- tr4.Cells.Add(d7);
- TableCell d8 = new TableCell();
- d8.BorderWidth = Unit.Pixel(1);
- d8.Style["Width"] = "90px";
- d8.Text = Convert.ToString(comm8["wuxia"]);
- if (d8.Text.Equals(""))
- {
- d8.Text = nul;
- }
- tr4.Cells.Add(d8);
- TableCell d9 = new TableCell();
- d9.BorderWidth = Unit.Pixel(1);
- d9.Style["Width"] = "90px";
- d9.Text = Convert.ToString(comm8["wushang"]);
- if (d9.Text.Equals(""))
- {
- d9.Text = nul;
- }
- tr4.Cells.Add(d9);
- TableCell d10 = new TableCell();
- d10.BorderWidth = Unit.Pixel(1);
- d10.Style["Width"] = "90px";
- d10.Text = Convert.ToString(comm8["wan"]);
- if (d10.Text.Equals(""))
- {
- d10.Text = nul;
- }
- tr4.Controls.Add(d10);
- if (time1.Length == 5)
- {
- time1 = "0" + time1;
- }
- if (time2.Length == 5)
- {
- time2 = "0" + time2;
- }
- TableCell d11 = new TableCell();
- d11.BorderWidth = Unit.Pixel(1);
- d11.Style["Width"] = "90px";
- if (!(time1.Equals("")) && (!time2.Equals("")))
- {
- sum = (float)(Convert.ToInt32(time2.Substring(0, 2)) - Convert.ToInt32(time1.Substring(0, 2)) - 1.5 + (float)(Convert.ToInt32(time2.Substring(2, 2)) - Convert.ToInt32(time1.Substring(2, 2))) / 60 + (float)(Convert.ToInt32(time2.Substring(4, 2)) - Convert.ToInt32(time1.Substring(4, 2))) / 120);
- d11.Text = Convert.ToString(sum);
- }
- else
- {
- d11.Text = nul;
- }
- tr4.Cells.Add(d11);
- Table1.Rows.Add(tr4);
- }
- }
- else
- {
- TableCell d6 = new TableCell();
- d6.BorderWidth = Unit.Pixel(1);
- d6.Style["Width"] = "90px";
- d6.Text = nul;
- tr4.Cells.Add(d6);
- TableCell d7 = new TableCell();
- d7.BorderWidth = Unit.Pixel(1);
- d7.Style["Width"] = "90px";
- d7.Text = nul;
- tr4.Cells.Add(d7);
- TableCell d8 = new TableCell();
- d8.BorderWidth = Unit.Pixel(1);
- d8.Style["Width"] = "90px";
- d8.Text = nul;
- tr4.Cells.Add(d8);
- TableCell d9 = new TableCell();
- d9.BorderWidth = Unit.Pixel(1);
- d9.Style["Width"] = "90px";
- d9.Text = nul;
- tr4.Cells.Add(d9);
- TableCell d10 = new TableCell();
- d10.BorderWidth = Unit.Pixel(1);
- d10.Style["Width"] = "90px";
- d10.Text = nul;
- tr4.Cells.Add(d10);
- TableCell d11 = new TableCell();
- d11.BorderWidth = Unit.Pixel(1);
- d11.Style["Width"] = "90px";
- d11.Text = nul;
- tr4.Cells.Add(d11);
- Table1.Rows.Add(tr4);
- }
- comm8.Close();
- conn3.Close();
- }
- comm4.Close();
- }
- }
- k++;
- }
- conn.Close();
- }
- public string getweekday(DateTime data)
- {
- string str = null;
- switch (data.DayOfWeek.ToString())
- {
- case "Monday":
- str = "星期一";
- break;
- case "Tuesday":
- str = "星期二";
- break;
- case "Wednesday":
- str = "星期三";
- break;
- case "Thursday":
- str = "星期四";
- break;
- case "Friday":
- str = "星期五";
- break;
- case "Saturday":
- str = "星期六";
- break;
- case "Sunday":
- str = "星期日";
- break;
- }
- return str;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- show_work();
- }
- protected void TextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- protected void TextBox2_TextChanged(object sender, EventArgs e)
- {
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- }
- }