show_work.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:15k
源码类别:
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.Reporting.WebForms;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using DataTable = System.Data.DataTable;
- public partial class web_pos_c_show_work : System.Web.UI.Page
- {
- int no = 0;
- ArrayList array1 = new ArrayList();
- ArrayList array2 = new ArrayList();
- ArrayList array3 = new ArrayList();
- ArrayList array_1 = new ArrayList();
- protected void Page_Load(object sender, EventArgs e)
- {
- ReportViewer1.Visible = false;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand comm1 = new SqlCommand("select id from OA_DEPARTMENT where name='中山隆成啟航商貿有限公司'", conn);
- no = Convert.ToInt32(comm1.ExecuteScalar());
- SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where last_id='" + no + "'", 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 + "'and id!='144'and id!='145'and id!='146'and id!='147'and id!='194'and id!='197'", 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();
- }
- public void getnum()
- {
- int k=0;
- string name = "";
- string emp_name = "";
- string nul=" ";
- string department="";
- double sum=0;
- string time1="";
- string time2="";
- string time3 = "";
- string time4 = "";
- ArrayList array_2 = new ArrayList();
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- 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 + "'", conn1);
- SqlDataReader comm1 = sqlcom1.ExecuteReader();
- if (comm1.HasRows)
- {
- while (comm1.Read())
- {
- array6.Add(Convert.ToString(comm1["emp_no"]));
- }
- }
- comm1.Close();
- }
- array3.Add(array6);
- }
- foreach (ArrayList i in array3)
- {
- if (k < array1.Count)
- {
- foreach (string j in i)
- {
- SqlConnection conn2 = dbConnection.getConnection();
- conn2.Open();
- SqlCommand sqlcom2 = new SqlCommand("select name from OA_DEPARTMENT where id='" + array1[k] + "'", conn2);
- name = Convert.ToString(sqlcom2.ExecuteScalar());
- SqlCommand sqlcom4 = 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 + "'", conn2);
- department = Convert.ToString(sqlcom4.ExecuteScalar());
- SqlCommand sqlcom3 = new SqlCommand("select emp_name from OA_EMPLOYEE where emp_no='" + j + "'", conn2);
- emp_name = Convert.ToString(sqlcom3.ExecuteScalar());
- SqlCommand sqlcom5 = new SqlCommand("select distinct data from OA_KAOQIN_JL where data between'" + TextBox1.Text + "'and'" + TextBox2.Text + "'order by data", conn2);
- SqlDataReader comm5 = sqlcom5.ExecuteReader();
- while (comm5.Read())
- {
- array_2.Add(name);
- array_2.Add(emp_name);
- array_2.Add(j);
- array_2.Add(Convert.ToString(comm5["data"]));
- array_2.Add(getweekday(Convert.ToDateTime(comm5["data"])));
- SqlConnection conn5 = dbConnection.getConnection();
- conn5.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(comm5["data"]) + "'", conn5);
- SqlDataReader comm8 = sqlcom8.ExecuteReader();
- if (comm8.HasRows)
- {
- while (comm8.Read())
- {
- time1 = Convert.ToString(comm8["zao"]);
- time2 = Convert.ToString(comm8["wan"]);
- time3 = Convert.ToString(comm8["wuxia"]);
- time4 = Convert.ToString(comm8["wushang"]);
- if (time1.Equals(""))
- {
- array_2.Add(nul);
- }
- else
- {
- array_2.Add(time1);
- }
- if (time3.Equals(""))
- {
- array_2.Add(nul);
- }
- else
- {
- array_2.Add(time3);
- }
- if (time4.Equals(""))
- {
- array_2.Add(nul);
- }
- else
- {
- array_2.Add(time4);
- }
- if (time2.Equals(""))
- {
- array_2.Add(nul);
- }
- else
- {
- array_2.Add(nul);
- }
- if (time1.Length == 5)
- {
- time1 = "0" + time1;
- }
- if (time2.Length == 5)
- {
- time2 = "0" + time2;
- }
- if (!(time1.Equals("")) && (!time2.Equals("")))
- {
- sum = (double)(Convert.ToInt32(time2.Substring(0, 2)) - Convert.ToInt32(time1.Substring(0, 2)) - 1.5 + (double)(Convert.ToInt32(time2.Substring(2, 2)) - Convert.ToInt32(time1.Substring(2, 2))) / 60);
- sum = Round(sum, 2);
- array_2.Add(Convert.ToString(sum));
- }
- else
- {
- array_2.Add(nul);
- }
- }
- }
- else
- {
- array_2.Add(nul);
- array_2.Add(nul);
- array_2.Add(nul);
- array_2.Add(nul);
- array_2.Add(nul);
- }
- comm8.Close();
- conn5.Close();
- array_1.Add(array_2);
- }
- comm5.Close();
- conn2.Close();
- }
- k++;
- }
- }
- conn1.Close();
- }
- public double Round(double v, int x)
- {
- bool flat = false;
- if (v < 0)
- {
- flat = true;
- v = -v;
- }
- int ivalue = 1;
- for (int i = 1; i <= x; i++)
- {
- ivalue = 10 * ivalue;
- }
- double num = Math.Round(v * ivalue + 0.5, 0);
- v = num / ivalue;
- if (flat)
- {
- v = -v;
- }
- return v;
- }
- 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 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)
- {
- getnum();
- foreach (ArrayList i in array_1)
- {
- foreach (string j in i)
- {
- Response.Write(j);
- }
- }
- /*DataTable dt = GetData();
- ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", dt);
- ReportViewer1.LocalReport.DataSources.Clear();
- ReportViewer1.LocalReport.DataSources.Add(rds);
- ReportViewer1.LocalReport.Refresh();
- ReportViewer1.Visible = true;*/
- }
- private DataTable GetData()
- {
- DataTable dt = new DataTable("dataname");
- dt.Columns.Add(new DataColumn("所屬部門", typeof(string)));
- dt.Columns.Add(new DataColumn("姓名", typeof(string)));
- dt.Columns.Add(new DataColumn("員工編號", typeof(string)));
- dt.Columns.Add(new DataColumn("日期", typeof(string)));
- dt.Columns.Add(new DataColumn("星期", typeof(string)));
- dt.Columns.Add(new DataColumn("早上上班", typeof(string)));
- dt.Columns.Add(new DataColumn("中午下班", typeof(string)));
- dt.Columns.Add(new DataColumn("下午上班", typeof(string)));
- dt.Columns.Add(new DataColumn("下午下班", typeof(string)));
- dt.Columns.Add(new DataColumn("簽到時數", typeof(string)));
- DataRow row = dt.NewRow();
- foreach (ArrayList i in array_1)
- {
- int n = 0;
- foreach (string j in i)
- {
- row = dt.NewRow();
- if (n < 10)
- {
- switch (n)
- {
- case 0:
- row["所屬部門"] = j;
- break;
- case 1:
- row["姓名"] = j;
- break;
- case 2:
- row["員工編號"] = j;
- break;
- case 3:
- row["日期"] = j;
- break;
- case 4:
- row["星期"] = j;
- break;
- case 5:
- row["早上上班"] = j;
- break;
- case 6:
- row["中午下班"] = j;
- break;
- case 7:
- row["下午上班"] = j;
- break;
- case 8:
- row["下午下班"] = j;
- break;
- case 9:
- row["簽到時數"] = j;
- break;
- }
- n++;
- }
- else
- {
- break;
- }
- }
- dt.Rows.Add(row);
- }
- return dt;
- }
- protected void TextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- protected void TextBox2_TextChanged(object sender, EventArgs e)
- {
- }
- }