show_work_2.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:24k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. using Microsoft.Office.Interop.Excel;
  13. using Microsoft.Office.Interop;
  14. using System.Reflection;
  15. using System.Runtime.InteropServices;
  16. using ExcelApplication = Microsoft.Office.Interop.Excel.Application;
  17. using Label = System.Web.UI.WebControls.Label;
  18. public partial class web_pos_c_show_work : System.Web.UI.Page
  19. {
  20.     int id = 0;
  21.     ArrayList array1 = new ArrayList();
  22.     ArrayList array2 = new ArrayList();
  23.     ArrayList array3 = new ArrayList();
  24.     protected void Page_Load(object sender, EventArgs e)
  25.     {
  26.         SqlConnection conn = dbConnection.getConnection();
  27.         conn.Open();
  28.         SqlCommand comm1 = new SqlCommand("select id from OA_DEPARTMENT where name='中山隆成啟航商貿有限公司'", conn);
  29.         id = Convert.ToInt32(comm1.ExecuteScalar());
  30.         SqlCommand sqlcom2 = new SqlCommand("select id from OA_DEPARTMENT where last_id='" + id + "'", conn);
  31.         SqlDataReader comm2 = sqlcom2.ExecuteReader();
  32.         while (comm2.Read())
  33.         {
  34.             array1.Add(Convert.ToInt32(comm2["id"]));
  35.         }
  36.         comm2.Close();
  37.         foreach (int i in array1)
  38.         {
  39.             ArrayList array5 = new ArrayList();
  40.             array5.Add(i);
  41.             SqlCommand sqlcom3 = new SqlCommand("select id from OA_DEPARTMENT where last_id='" + i + "'", conn);
  42.             SqlDataReader comm3 = sqlcom3.ExecuteReader();
  43.             if (comm3.HasRows)
  44.             {
  45.                 while (comm3.Read())
  46.                 {
  47.                     array5.Add(Convert.ToInt32(comm3["id"]));
  48.                     SqlConnection conn1 = dbConnection.getConnection();
  49.                     conn1.Open();
  50.                     SqlCommand sqlcom4 = new SqlCommand("select id from OA_DEPARTMENT where last_id='" + Convert.ToInt32(comm3["id"]) + "'", conn1);
  51.                     SqlDataReader comm4 = sqlcom4.ExecuteReader();
  52.                     if (comm4.HasRows)
  53.                     {
  54.                         while (comm4.Read())
  55.                         {
  56.                             array5.Add(Convert.ToInt32(comm4["id"]));
  57.                         }
  58.                     }
  59.                     comm4.Close();
  60.                     conn1.Close();
  61.                 }
  62.             }
  63.             comm3.Close();
  64.             array2.Add(array5);
  65.         }
  66.         conn.Close();
  67.     }
  68.     protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  69.     {
  70.         if (Calendar1.Visible == true)
  71.         {
  72.             Calendar1.Visible = false;
  73.             Calendar1.Focus();
  74.         }
  75.         else
  76.         {
  77.             Calendar1.Visible = true;
  78.             Calendar1.Focus();
  79.         }
  80.     }
  81.     protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
  82.     {
  83.         if (Calendar2.Visible == true)
  84.         {
  85.             Calendar2.Visible = false;
  86.             Calendar2.Focus();
  87.         }
  88.         else
  89.         {
  90.             Calendar2.Visible = true;
  91.             Calendar2.Focus();
  92.         }
  93.     }
  94.     protected void Calendar1_SelectionChanged(object sender, EventArgs e)
  95.     {
  96.         Calendar1.Visible = false;
  97.         string year = Calendar1.SelectedDate.Year.ToString();
  98.         string month = Calendar1.SelectedDate.Month.ToString();
  99.         if (month.Length == 1)
  100.         {
  101.             month = "0" + month;
  102.         }
  103.         string day = Calendar1.SelectedDate.Day.ToString();
  104.         if (day.Length == 1)
  105.         {
  106.             day = "0" + day;
  107.         }
  108.         TextBox1.Text = year + "-" + month + "-" + day;
  109.         TextBox1.Focus();
  110.     }
  111.     protected void Calendar2_SelectionChanged(object sender, EventArgs e)
  112.     {
  113.         Calendar2.Visible = false;
  114.         string year = Calendar2.SelectedDate.Year.ToString();
  115.         string month = Calendar2.SelectedDate.Month.ToString();
  116.         if (month.Length == 1)
  117.         {
  118.             month = "0" + month;
  119.         }
  120.         string day = Calendar2.SelectedDate.Day.ToString();
  121.         if (day.Length == 1)
  122.         {
  123.             day = "0" + day;
  124.         }
  125.         TextBox2.Text = year + "-" + month + "-" + day;
  126.         TextBox2.Focus();
  127.     }
  128.     public void show_work()
  129.     {
  130.         int k = 0;
  131.         string nul = " ";
  132.         string department = null;
  133.         float sum = 0;
  134.         string time1 = null;
  135.         string time2 = null;
  136.         SqlConnection conn = dbConnection.getConnection();
  137.         conn.Open();
  138.         SqlCommand sqlcom = new SqlCommand();
  139.         foreach (ArrayList i in array2)
  140.         {
  141.             ArrayList array6 = new ArrayList();
  142.             foreach (int j in i)
  143.             {
  144.                 SqlCommand sqlcom1 = new SqlCommand("select emp_no from OA_EMPLOYEE where department_id='" + j + "'", conn);
  145.                 SqlDataReader comm1 = sqlcom1.ExecuteReader();
  146.                 if (comm1.HasRows)
  147.                 {
  148.                     while (comm1.Read())
  149.                     {
  150.                         array6.Add(Convert.ToString(comm1["emp_no"]));
  151.                     }
  152.                 }
  153.                 comm1.Close();
  154.             }
  155.             array3.Add(array6);
  156.         }
  157.         TableRow tr = new TableRow();
  158.         TableCell td = new TableCell();
  159.         td.BorderWidth = Unit.Pixel(1);
  160.         td.Style["Width"] = "90px";
  161.         td.Text = "中山隆成启航商贸有限公司";
  162.         tr.Cells.Add(td);
  163.         Table1.Rows.Add(tr);
  164.         foreach (ArrayList i in array3)
  165.         {
  166.             if (k < array1.Count)
  167.             {
  168.                 SqlConnection conn4 = dbConnection.getConnection();
  169.                 conn4.Open();
  170.                 SqlCommand sqlcom2 = new SqlCommand("select name from OA_DEPARTMENT where id='" + array1[k] + "'", conn4);
  171.                
  172.                 TableRow tr1 = new TableRow();
  173.                 TableCell td1 = new TableCell();
  174.                 td1.BorderWidth = Unit.Pixel(1);
  175.                 td1.Style["Width"] = "90px";
  176.                 d1.Text = Convert.ToString(sqlcom2.ExecuteScalar());
  177.                 tr1.Cells.Add(td1);
  178.                 Table1.Rows.Add(tr1);
  179.                 conn4.Close();
  180.                 foreach (string j in i)
  181.                 {
  182.                     TableRow tr2 = new TableRow();
  183.                     TableCell tdd1 = new TableCell();
  184.                     tdd1.BorderWidth = Unit.Pixel(1);
  185.                     tdd1.Style["Width"] = "90px";
  186.                     tdd1.Text = "员工编号";
  187.                     tr2.Cells.Add(tdd1);
  188.                     TableCell tdd2 = new TableCell();
  189.                     tdd2.BorderWidth = Unit.Pixel(1);
  190.                     tdd2.Style["Width"] = "90px";
  191.                     tdd2.Text = j;
  192.                     tr2.Cells.Add(tdd2);
  193.                     TableCell tdd3 = new TableCell();
  194.                     tdd3.BorderWidth = Unit.Pixel(1);
  195.                     tdd3.Style["Width"] = "90px";
  196.                     tdd3.Text = "员工名称";
  197.                     tr2.Cells.Add(tdd3);
  198.                     SqlCommand sqlcom3 = new SqlCommand("select emp_name from OA_EMPLOYEE where emp_no='" + j + "'", conn);
  199.                     TableCell tdd4 = new TableCell();
  200.                     tdd4.BorderWidth = Unit.Pixel(1);
  201.                     tdd4.Style["Width"] = "90px";
  202.                     tdd4.Text = Convert.ToString(sqlcom3.ExecuteScalar());
  203.                     tr2.Cells.Add(tdd4);
  204.                     TableCell tdd5 = new TableCell();
  205.                     tdd5.BorderWidth = Unit.Pixel(1);
  206.                     tdd5.Style["Width"] = "90px";
  207.                     tdd5.Text = "所属部门";
  208.                     tr2.Cells.Add(tdd5);
  209.                     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);
  210.                     department = Convert.ToString(sqlcom7.ExecuteScalar());
  211.                     TableCell tdd6 = new TableCell();
  212.                     tdd6.BorderWidth = Unit.Pixel(1);
  213.                     tdd6.Style["Width"] = "90px";
  214.                     tdd6.Text = department;
  215.                     tr2.Cells.Add(tdd6);
  216.                     Table1.Rows.Add(tr2);
  217.                     TableRow tr3 = new TableRow();
  218.                     TableCell t1 = new TableCell();
  219.                     t1.BorderWidth = Unit.Pixel(1);
  220.                     t1.Style["Width"] = "90px";
  221.                     t1.Text = "日期";
  222.                     tr3.Cells.Add(t1);
  223.                     TableCell t2 = new TableCell();
  224.                     t2.BorderWidth = Unit.Pixel(1);
  225.                     t2.Style["Width"] = "90px";
  226.                     t2.Text = "星期";
  227.                     tr3.Cells.Add(t2);
  228.                     TableCell t3 = new TableCell();
  229.                     t3.BorderWidth = Unit.Pixel(1);
  230.                     t3.Style["Width"] = "90px";
  231.                     t3.Text = "班别";
  232.                     tr3.Cells.Add(t3);
  233.                     TableCell t4 = new TableCell();
  234.                     t4.BorderWidth = Unit.Pixel(1);
  235.                     t4.Style["Width"] = "90px";
  236.                     t4.Text = "排班时间";
  237.                     tr3.Cells.Add(t4);
  238.                     TableCell t5 = new TableCell();
  239.                     t5.BorderWidth = Unit.Pixel(1);
  240.                     t5.Style["Width"] = "90px";
  241.                     t5.Text = nul;
  242.                     tr3.Cells.Add(t5);
  243.                     TableCell t6 = new TableCell();
  244.                     t6.BorderWidth = Unit.Pixel(1);
  245.                     t6.Style["Width"] = "90px";
  246.                     t6.Text = "排班门店";
  247.                     tr3.Cells.Add(t6);
  248.                     TableCell t7 = new TableCell();
  249.                     t7.BorderWidth = Unit.Pixel(1);
  250.                     t7.Style["Width"] = "90px";
  251.                     t7.Text = "签到退时间";
  252.                     tr3.Cells.Add(t7);
  253.                     TableCell t8 = new TableCell();
  254.                     t8.BorderWidth = Unit.Pixel(1);
  255.                     t8.Style["Width"] = "90px";
  256.                     t8.Text = nul;
  257.                     tr3.Cells.Add(t8);
  258.                     TableCell t9 = new TableCell();
  259.                     t9.BorderWidth = Unit.Pixel(1);
  260.                     t9.Style["Width"] = "90px";
  261.                     t9.Text = nul;
  262.                     tr3.Cells.Add(t9);
  263.                     TableCell t10 = new TableCell();
  264.                     t10.BorderWidth = Unit.Pixel(1);
  265.                     t10.Style["Width"] = "90px";
  266.                     t10.Text = nul;
  267.                     tr3.Cells.Add(t10);
  268.                     TableCell t11 = new TableCell();
  269.                     t11.BorderWidth = Unit.Pixel(1);
  270.                     t11.Style["Width"] = "90px";
  271.                     t11.Text = "签到时数";
  272.                     tr3.Cells.Add(t11);
  273.                     Table1.Rows.Add(tr3);
  274.                     SqlCommand sqlcom4 = new SqlCommand("select distinct data  from OA_KAOQIN_JL  where  data between '" + TextBox1.Text + "'and '" + TextBox2.Text + "' order by data", conn);
  275.                     SqlDataReader comm4 = sqlcom4.ExecuteReader();
  276.                     while (comm4.Read())
  277.                     {
  278.                         TableRow tr4 = new TableRow();
  279.                         TableCell d1 = new TableCell();
  280.                         d1.BorderWidth = Unit.Pixel(1);
  281.                         d1.Style["Width"] = "90px";
  282.                         d1.Text = Convert.ToString(comm4["data"]);
  283.                         tr4.Cells.Add(d1);
  284.                         TableCell d2 = new TableCell();
  285.                         d2.BorderWidth = Unit.Pixel(1);
  286.                         d2.Style["Width"] = "90px";
  287.                         d2.Text = getweekday(Convert.ToDateTime(comm4["data"]));
  288.                         tr4.Cells.Add(d2);
  289.                         SqlConnection conn1 = dbConnection.getConnection();
  290.                         conn1.Open();
  291.                         SqlCommand sqlcom5 = new SqlCommand("select banbie from OA_KAOQIN_PBB where data='" + Convert.ToString(comm4["data"]) + "' and emp_no='" + j + "'", conn1);
  292.                         SqlDataReader comm5 = sqlcom5.ExecuteReader();
  293.                         if (comm5.HasRows)
  294.                         {
  295.                             while (comm5.Read())
  296.                             {
  297.                                 TableCell d3 = new TableCell();
  298.                                 d3.BorderWidth = Unit.Pixel(1);
  299.                                 d3.Style["Width"] = "90px";
  300.                                 d3.Text = Convert.ToString(comm5["banbie"]);
  301.                                 tr4.Cells.Add(d3);
  302.                                 SqlConnection conn2 = dbConnection.getConnection();
  303.                                 conn2.Open();
  304.                                 SqlCommand sqlcom6 = new SqlCommand("select bengin_time,end_time from oa_pos_type where department='" + department + "' and type='" + Convert.ToString(comm5["banbie"]) + "'", conn2);
  305.                                 SqlDataReader comm6 = sqlcom6.ExecuteReader();
  306.                                 if (comm6.HasRows)
  307.                                 {
  308.                                     while (comm6.Read())
  309.                                     {
  310.                                         TableCell d4 = new TableCell();
  311.                                         d4.BorderWidth = Unit.Pixel(1);
  312.                                         d4.Style["Width"] = "90px";
  313.                                         d4.Text = Convert.ToString(comm6["bengin_time"]);
  314.                                         tr4.Cells.Add(d3);
  315.                                         TableCell d5 = new TableCell();
  316.                                         d5.BorderWidth = Unit.Pixel(1);
  317.                                         d5.Style["Width"] = "90px";
  318.                                         d5.Text = Convert.ToString(comm6["end_time"]);
  319.                                         tr4.Cells.Add(d5);
  320.                                     }
  321.                                 }
  322.                                 else
  323.                                 {
  324.                                     TableCell d4 = new TableCell();
  325.                                     d4.BorderWidth = Unit.Pixel(1);
  326.                                     d4.Style["Width"] = "90px";
  327.                                     d4.Text = nul;
  328.                                     tr4.Cells.Add(d3);
  329.                                     TableCell d5 = new TableCell();
  330.                                     d5.BorderWidth = Unit.Pixel(1);
  331.                                     d5.Style["Width"] = "90px";
  332.                                     d5.Text = nul;
  333.                                     tr4.Cells.Add(d5);
  334.                                 }
  335.                                 comm6.Close();
  336.                                 conn2.Close();
  337.                                 TableCell d6 = new TableCell();
  338.                                 d6.BorderWidth = Unit.Pixel(1);
  339.                                 d6.Style["Width"] = "90px";
  340.                                 d6.Text = department;
  341.                                 tr4.Cells.Add(d6);
  342.                             }
  343.                         }
  344.                         else
  345.                         {
  346.                             TableCell d3 = new TableCell();
  347.                             d3.BorderWidth = Unit.Pixel(1);
  348.                             d3.Style["Width"] = "90px";
  349.                             d3.Visible = true;
  350.                             d3.Text = nul;
  351.                             tr4.Cells.Add(d3);
  352.                             TableCell d4 = new TableCell();
  353.                             d4.BorderWidth = Unit.Pixel(1);
  354.                             d4.Style["Width"] = "90px";
  355.                             d4.Text = nul;
  356.                             tr4.Cells.Add(d3);
  357.                             TableCell d5 = new TableCell();
  358.                             d5.BorderWidth = Unit.Pixel(1);
  359.                             d5.Style["Width"] = "90px";
  360.                             d5.Text = nul;
  361.                             tr4.Cells.Add(d5);
  362.                             TableCell d6 = new TableCell();
  363.                             d6.BorderWidth = Unit.Pixel(1);
  364.                             d6.Style["Width"] = "90px";
  365.                             d6.Text = nul;
  366.                             tr4.Cells.Add(d6);
  367.                             //}
  368.                         }
  369.                         comm5.Close();
  370.                         conn1.Close();
  371.                         SqlConnection conn3 = dbConnection.getConnection();
  372.                         conn3.Open();
  373.                         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);
  374.                         SqlDataReader comm8 = sqlcom8.ExecuteReader();
  375.                         if (comm8.HasRows)
  376.                         {
  377.                             while (comm8.Read())
  378.                             {
  379.                                 time1 = Convert.ToString(comm8["zao"]);
  380.                                 time2 = Convert.ToString(comm8["wan"]);
  381.                                 TableCell d7 = new TableCell();
  382.                                 d7.BorderWidth = Unit.Pixel(1);
  383.                                 d7.Style["Width"] = "90px";
  384.                                 d7.Text = Convert.ToString(comm8["zao"]);
  385.                                 if (d7.Text.Equals(""))
  386.                                 {
  387.                                     d7.Text = nul;
  388.                                 }
  389.                                 tr4.Cells.Add(d7);
  390.                                 TableCell d8 = new TableCell();
  391.                                 d8.BorderWidth = Unit.Pixel(1);
  392.                                 d8.Style["Width"] = "90px";
  393.                                 d8.Text = Convert.ToString(comm8["wuxia"]);
  394.                                 if (d8.Text.Equals(""))
  395.                                 {
  396.                                     d8.Text = nul;
  397.                                 }
  398.                                 tr4.Cells.Add(d8);
  399.                                 TableCell d9 = new TableCell();
  400.                                 d9.BorderWidth = Unit.Pixel(1);
  401.                                 d9.Style["Width"] = "90px";
  402.                                 d9.Text = Convert.ToString(comm8["wushang"]);
  403.                                 if (d9.Text.Equals(""))
  404.                                 {
  405.                                     d9.Text = nul;
  406.                                 }
  407.                                 tr4.Cells.Add(d9);
  408.                                 TableCell d10 = new TableCell();
  409.                                 d10.BorderWidth = Unit.Pixel(1);
  410.                                 d10.Style["Width"] = "90px";
  411.                                 d10.Text = Convert.ToString(comm8["wan"]);
  412.                                 if (d10.Text.Equals(""))
  413.                                 {
  414.                                     d10.Text = nul;
  415.                                 }
  416.                                 tr4.Controls.Add(d10);
  417.                                 if (time1.Length == 5)
  418.                                 {
  419.                                     time1 = "0" + time1;
  420.                                 }
  421.                                 if (time2.Length == 5)
  422.                                 {
  423.                                     time2 = "0" + time2;
  424.                                 }
  425.                                 TableCell d11 = new TableCell();
  426.                                 d11.BorderWidth = Unit.Pixel(1);
  427.                                 d11.Style["Width"] = "90px";
  428.                                 if (!(time1.Equals("")) && (!time2.Equals("")))
  429.                                 {
  430.                                     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);
  431.                                     d11.Text = Convert.ToString(sum);
  432.                                 }
  433.                                 else
  434.                                 {
  435.                                     d11.Text = nul;
  436.                                 }
  437.                                 tr4.Cells.Add(d11);
  438.                                 Table1.Rows.Add(tr4);
  439.                             }
  440.                         }
  441.                         else
  442.                         {
  443.                             TableCell d6 = new TableCell();
  444.                             d6.BorderWidth = Unit.Pixel(1);
  445.                             d6.Style["Width"] = "90px";
  446.                             d6.Text = nul;
  447.                             tr4.Cells.Add(d6);
  448.                             TableCell d7 = new TableCell();
  449.                             d7.BorderWidth = Unit.Pixel(1);
  450.                             d7.Style["Width"] = "90px";
  451.                             d7.Text = nul;
  452.                             tr4.Cells.Add(d7);
  453.                             TableCell d8 = new TableCell();
  454.                             d8.BorderWidth = Unit.Pixel(1);
  455.                             d8.Style["Width"] = "90px";
  456.                             d8.Text = nul;
  457.                             tr4.Cells.Add(d8);
  458.                             TableCell d9 = new TableCell();
  459.                             d9.BorderWidth = Unit.Pixel(1);
  460.                             d9.Style["Width"] = "90px";
  461.                             d9.Text = nul;
  462.                             tr4.Cells.Add(d9);
  463.                             TableCell d10 = new TableCell();
  464.                             d10.BorderWidth = Unit.Pixel(1);
  465.                             d10.Style["Width"] = "90px";
  466.                             d10.Text = nul;
  467.                             tr4.Cells.Add(d10);
  468.                             TableCell d11 = new TableCell();
  469.                             d11.BorderWidth = Unit.Pixel(1);
  470.                             d11.Style["Width"] = "90px";
  471.                             d11.Text = nul;
  472.                             tr4.Cells.Add(d11);
  473.                             Table1.Rows.Add(tr4);
  474.                         }
  475.                         comm8.Close();
  476.                         conn3.Close();
  477.                     }
  478.                     comm4.Close();
  479.                 }
  480.             }
  481.             k++;
  482.         }
  483.         conn.Close();
  484.     }
  485.     public string getweekday(DateTime data)
  486.     {
  487.         string str = null;
  488.         switch (data.DayOfWeek.ToString())
  489.         {
  490.             case "Monday":
  491.                 str = "星期一";
  492.                 break;
  493.             case "Tuesday":
  494.                 str = "星期二";
  495.                 break;
  496.             case "Wednesday":
  497.                 str = "星期三";
  498.                 break;
  499.             case "Thursday":
  500.                 str = "星期四";
  501.                 break;
  502.             case "Friday":
  503.                 str = "星期五";
  504.                 break;
  505.             case "Saturday":
  506.                 str = "星期六";
  507.                 break;
  508.             case "Sunday":
  509.                 str = "星期日";
  510.                 break;
  511.         }
  512.         return str;
  513.     }
  514.     protected void Button1_Click(object sender, EventArgs e)
  515.     {
  516.         show_work();
  517.     }
  518.     protected void TextBox1_TextChanged(object sender, EventArgs e)
  519.     {
  520.     }
  521.     protected void TextBox2_TextChanged(object sender, EventArgs e)
  522.     {
  523.     }
  524.     protected void Button2_Click(object sender, EventArgs e)
  525.     {
  526.     }
  527. }