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

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. using Microsoft.Office.Interop.Excel;
  13. using Microsoft.Office.Interop;
  14. using System.Reflection;
  15. using System.IO;
  16. using System.Runtime.InteropServices;
  17. using ExcelApplication = Microsoft.Office.Interop.Excel.Application;
  18. using Label = System.Web.UI.WebControls.Label;
  19. public partial class web_123_report_approvel : System.Web.UI.Page
  20. {
  21.     ArrayList array_1 = new ArrayList();
  22.     ArrayList array_2 = new ArrayList();
  23.     //string str_path = "..\..\oa_upload\temp\";
  24.     string str_path = "~/upload/";
  25.     string str_name = "hello.xls"; 
  26.     protected void Page_Load(object sender, EventArgs e)
  27.     {
  28.         if (!IsPostBack)
  29.         {
  30.             LoginDAO.CheckLogin(Session, Response, "../../", 2);
  31.             if (Table1.Visible = false)
  32.             {
  33.                 Button2.Enabled = false;
  34.             }
  35.             else if(Table1.Visible=true)
  36.             { 
  37.                 Button2.Enabled = true;
  38.             }
  39.         }
  40.     }
  41.     public void getnum()
  42.     {
  43.         if (!TxtBeginTime.Text.ToString().Equals("") && !TxtEndTime.Text.ToString().Equals(""))
  44.         {
  45.             
  46.             array_1 = new ArrayList();
  47.             SqlConnection con = dbConnection.getConnection();
  48.             con.Open();
  49.             SqlCommand cmd = new SqlCommand();
  50.             if (DropDf_type.SelectedValue.ToString().Equals("1"))
  51.             {
  52.                 if (DrpDownType.SelectedValue.ToString().Equals("1"))
  53.                 {
  54.                     cmd.CommandText = "select f.id as f_id,f.form_id ,e.emp_name,d.name,f.vacation_begin,f.vacation_end,f.days,f.off_type from oa_tw_approvel_form" +
  55.                         " as f inner join oa_employee as e on f.emp_id=e.id inner join oa_department as d on e.department_id=d.id " +
  56.                         " where vacation_begin>='" + TxtBeginTime.Text + "' and  vacation_begin<='" + TxtEndTime.Text + "' and off_type<>1 and total_result='同意' order by name,emp_name";
  57.                     cmd.Connection = con;
  58.                     SqlDataReader dr = cmd.ExecuteReader();
  59.                     while (dr.Read())
  60.                     {
  61.                         array_2 = new ArrayList();
  62.                         Table1.Visible = true;
  63.                         TableRow tr = new TableRow();
  64.                         TableCell td = new TableCell();
  65.                         td.BorderWidth = Unit.Pixel(1);
  66.                         td.Text = dr["form_id"].ToString();
  67.                         array_2.Add("'"+Convert.ToString(dr["form_id"]));
  68.                         tr.Cells.Add(td);
  69.                         td = new TableCell();
  70.                         td.BorderWidth = Unit.Pixel(1);
  71.                         td.Text = dr["name"].ToString();
  72.                         array_2.Add(Convert.ToString(dr["name"]));
  73.                         tr.Cells.Add(td);
  74.                         td = new TableCell();
  75.                         td.BorderWidth = Unit.Pixel(1);
  76.                         td.Text = dr["emp_name"].ToString();
  77.                         array_2.Add(Convert.ToString(dr["emp_name"]));
  78.                         tr.Cells.Add(td);
  79.                         td = new TableCell();
  80.                         td.BorderWidth = Unit.Pixel(1);
  81.                         td.Text = dr["vacation_begin"].ToString();
  82.                         array_2.Add("'"+Convert.ToString(dr["vacation_begin"]));
  83.                         tr.Cells.Add(td);
  84.                         td = new TableCell();
  85.                         td.BorderWidth = Unit.Pixel(1);
  86.                         td.Text = dr["vacation_end"].ToString();
  87.                         array_2.Add("'"+Convert.ToString(dr["vacation_end"]));
  88.                         tr.Cells.Add(td);
  89.                         td = new TableCell();
  90.                         td.BorderWidth = Unit.Pixel(1);
  91.                         td.Text = dr["days"].ToString() + "天";
  92.                         array_2.Add(Convert.ToString(td.Text));
  93.                         tr.Cells.Add(td);
  94.                         td = new TableCell();
  95.                         td.BorderWidth = Unit.Pixel(1);
  96.                         HyperLink hl = new HyperLink();
  97.                         hl.Text = "查看";
  98.                         hl.Target = "blank";
  99.                         hl.NavigateUrl = "../../approvel/tw/my_list.aspx?a_id=" + dr["f_id"].ToString()+"&k=1";
  100.                         td.Controls.Add(hl);
  101.                         tr.Cells.Add(td);
  102.                         Table1.Rows.Add(tr);
  103.                         array_1.Add(array_2);
  104.                     }
  105.                     dr.Close();
  106.                 }
  107.                 else if (DrpDownType.SelectedValue.ToString().Equals("4"))
  108.                 {
  109.                     array_1 = new ArrayList();
  110.                     cmd.CommandText = "select f.id,f.form_id,e.emp_name,d.name,f.business_begin,f.business_end,f.days,f.off_type from oa_tw_approvel_form" +
  111.                             " as f inner join oa_employee as e on f.emp_id=e.id inner join oa_department as d on e.department_id=d.id where" +
  112.                             " vacation_begin>='" + TxtBeginTime.Text + "' and  vacation_begin<='" + TxtEndTime.Text + "' and off_type=1 and total_result='同意' order by name,emp_name";
  113.                     cmd.Connection = con;
  114.                     SqlDataReader dr = cmd.ExecuteReader();
  115.                     while (dr.Read())
  116.                     {
  117.                         array_2 = new ArrayList();
  118.                         Table1.Visible = true;
  119.                         TableRow tr = new TableRow();
  120.                         TableCell td = new TableCell();
  121.                         td.BorderWidth = Unit.Pixel(1);
  122.                         td.Text = dr["form_id"].ToString();
  123.                         array_2.Add("'"+Convert.ToString(dr["form_id"]));
  124.                         tr.Cells.Add(td);
  125.                         td = new TableCell();
  126.                         td.BorderWidth = Unit.Pixel(1);
  127.                         td.Text = dr["name"].ToString();
  128.                         array_2.Add(Convert.ToString(dr["name"]));
  129.                         tr.Cells.Add(td);
  130.                         td = new TableCell();
  131.                         td.BorderWidth = Unit.Pixel(1);
  132.                         td.Text = dr["emp_name"].ToString();
  133.                         array_2.Add(Convert.ToString(dr["emp_name"]));
  134.                         tr.Cells.Add(td);
  135.                         td = new TableCell();
  136.                         td.BorderWidth = Unit.Pixel(1);
  137.                         td.Text = dr["'" + "business_begin"].ToString();
  138.                         array_2.Add(Convert.ToString(dr["business_begin"]));
  139.                         tr.Cells.Add(td);
  140.                         td = new TableCell();
  141.                         td.BorderWidth = Unit.Pixel(1);
  142.                         td.Text = dr["'" + "business_end"].ToString();
  143.                         array_2.Add(Convert.ToString(dr["business_end"]));
  144.                         tr.Cells.Add(td);
  145.                         td = new TableCell();
  146.                         td.BorderWidth = Unit.Pixel(1);
  147.                         td.Text = dr["days"].ToString() + "天";
  148.                         array_2.Add(Convert.ToString(td.Text));
  149.                         tr.Cells.Add(td);
  150.                         td = new TableCell();
  151.                         td.BorderWidth = Unit.Pixel(1);
  152.                         HyperLink hl = new HyperLink();
  153.                         hl.Text = "查看";
  154.                         hl.Target = "blank";
  155.                         hl.NavigateUrl = "../../approvel/tw/my_list.aspx?a_id=" + dr["f_id"].ToString()+"&k=1";
  156.                         td.Controls.Add(hl);
  157.                         tr.Cells.Add(td);
  158.                         Table1.Rows.Add(tr);
  159.                         array_1.Add(array_2);
  160.                     }
  161.                     dr.Close();
  162.                 }
  163.                 else
  164.                 {
  165.                     array_1 = new ArrayList();
  166.                     if (DrpDownType.SelectedValue.ToString().Equals("2"))
  167.                     {
  168.                         cmd.CommandText = "select f.id,f.form_id,e.emp_name,d.name,f.begin_time,f.end_time,f.days from oa_ch_business_form " +
  169.                             " as f inner join oa_employee as e on f.emp_id=e.id inner join oa_department as d on e.department_id=d.id where" +
  170.                             " begin_time>='" + TxtBeginTime.Text + "' and  begin_time<='" + TxtEndTime.Text + "' and total_result='同意' order by name,emp_name";
  171.                     }
  172.                     else if (DrpDownType.SelectedValue.ToString().Equals("3"))
  173.                     {
  174.                         cmd.CommandText = "select f.id,f.form_id,e.emp_name,d.name,f.begin_time,f.end_time,f.hours from oa_ch_off_form " +
  175.                             " as f inner join oa_employee as e on f.emp_id=e.id inner join oa_department as d on e.department_id=d.id where" +
  176.                             " begin_time>='" + TxtBeginTime.Text + "' and  begin_time<='" + TxtEndTime.Text + "' and total_result='同意' order by name,emp_name";
  177.                     }
  178.                     cmd.Connection = con;
  179.                     SqlDataReader dr = cmd.ExecuteReader();
  180.                     while (dr.Read())
  181.                     {
  182.                         array_2 = new ArrayList();
  183.                         Table1.Visible = true;
  184.                         TableRow tr = new TableRow();
  185.                         TableCell td = new TableCell();
  186.                         td.BorderWidth = Unit.Pixel(1);
  187.                         td.Text = dr["form_id"].ToString();
  188.                         array_2.Add("'" + Convert.ToString(dr["form_id"]));
  189.                         tr.Cells.Add(td);
  190.                         td = new TableCell();
  191.                         td.BorderWidth = Unit.Pixel(1);
  192.                         td.Text = dr["name"].ToString();
  193.                         array_2.Add(Convert.ToString(dr["name"]));
  194.                         tr.Cells.Add(td);
  195.                         td = new TableCell();
  196.                         td.BorderWidth = Unit.Pixel(1);
  197.                         td.Text = dr["emp_name"].ToString();
  198.                         array_2.Add(Convert.ToString(dr["emp_name"]));
  199.                         tr.Cells.Add(td);
  200.                         td = new TableCell();
  201.                         td.BorderWidth = Unit.Pixel(1);
  202.                         td.Text = dr["begin_time"].ToString();
  203.                         array_2.Add("'" + Convert.ToString(dr["begin_time"]));
  204.                         tr.Cells.Add(td);
  205.                         td = new TableCell();
  206.                         td.BorderWidth = Unit.Pixel(1);
  207.                         td.Text = dr["end_time"].ToString();
  208.                         array_2.Add("'" + Convert.ToString(dr["end_time"]));
  209.                         tr.Cells.Add(td);
  210.                         if (DrpDownType.SelectedValue.ToString().Equals("2"))
  211.                         {
  212.                             td = new TableCell();
  213.                             td.BorderWidth = Unit.Pixel(1);
  214.                             td.Text = dr["days"].ToString() + "天";
  215.                             array_2.Add(Convert.ToString(td.Text));
  216.                         }
  217.                         else if (DrpDownType.SelectedValue.ToString().Equals("3"))
  218.                         {
  219.                             td = new TableCell();
  220.                             td.BorderWidth = Unit.Pixel(1);
  221.                             td.Text = dr["hours"].ToString() + "小時";
  222.                             array_2.Add(Convert.ToString(td.Text));
  223.                         }
  224.                         tr.Cells.Add(td);
  225.                         td = new TableCell();
  226.                         td.BorderWidth = Unit.Pixel(1);
  227.                         HyperLink hl = new HyperLink();
  228.                         hl.Text = "查看";
  229.                         hl.Target = "blank";
  230.                         hl.NavigateUrl = "../../approvel/ch/my_list_d.aspx?a_id=" + dr["id"].ToString();
  231.                         td.Controls.Add(hl);
  232.                         tr.Cells.Add(td);
  233.                         Table1.Rows.Add(tr);
  234.                         array_1.Add(array_2);
  235.                     }
  236.                     dr.Close();
  237.                 }
  238.                 con.Close();
  239.             }
  240.             else
  241.             {
  242.                 int flag = 0;
  243.                 cmd.CommandText = "select f.id as f_id,f.form_id ,e.emp_name,d.name,f.vacation_begin,f.vacation_end,f.days,f.off_type from oa_tw_approvel_form" +
  244.                     " as f inner join oa_employee as e on f.emp_id=e.id inner join oa_department as d on e.department_id=d.id " +
  245.                     " where vacation_begin>='" + TxtBeginTime.Text + "' and  vacation_begin<='" + TxtEndTime.Text + "' and off_type<>1 and emp_no='"+TxtEmp_no.Text+
  246.                     "' and total_result='同意' order by name,emp_name";
  247.                 cmd.Connection = con;
  248.                 SqlDataReader dr = cmd.ExecuteReader();
  249.                 while (dr.Read())
  250.                 {
  251.                     array_2 = new ArrayList();
  252.                     Table1.Visible = true;
  253.                     TableRow tr = new TableRow();
  254.                     TableCell td = new TableCell();
  255.                     td.BorderWidth = Unit.Pixel(1);
  256.                     td.Text = dr["form_id"].ToString();
  257.                     array_2.Add("'" + Convert.ToString(dr["form_id"]));
  258.                     tr.Cells.Add(td);
  259.                     td = new TableCell();
  260.                     td.BorderWidth = Unit.Pixel(1);
  261.                     td.Text = dr["name"].ToString();
  262.                     array_2.Add(Convert.ToString(dr["name"]));
  263.                     tr.Cells.Add(td);
  264.                     td = new TableCell();
  265.                     td.BorderWidth = Unit.Pixel(1);
  266.                     td.Text = dr["emp_name"].ToString();
  267.                     array_2.Add(Convert.ToString(dr["emp_name"]));
  268.                     tr.Cells.Add(td);
  269.                     td = new TableCell();
  270.                     td.BorderWidth = Unit.Pixel(1);
  271.                     td.Text = dr["vacation_begin"].ToString();
  272.                     array_2.Add("'" + Convert.ToString(dr["vacation_begin"]));
  273.                     tr.Cells.Add(td);
  274.                     td = new TableCell();
  275.                     td.BorderWidth = Unit.Pixel(1);
  276.                     td.Text = dr["vacation_end"].ToString();
  277.                     array_2.Add("'" + Convert.ToString(dr["vacation_end"]));
  278.                     tr.Cells.Add(td);
  279.                     td = new TableCell();
  280.                     td.BorderWidth = Unit.Pixel(1);
  281.                     td.Text = dr["days"].ToString() + "天";
  282.                     array_2.Add(Convert.ToString(td.Text));
  283.                     tr.Cells.Add(td);
  284.                     td = new TableCell();
  285.                     td.BorderWidth = Unit.Pixel(1);
  286.                     HyperLink hl = new HyperLink();
  287.                     hl.Text = "查看";
  288.                     hl.Target = "blank";
  289.                     hl.NavigateUrl = "../../approvel/tw/my_list.aspx?a_id=" + dr["f_id"].ToString()+"&k=1";
  290.                     td.Controls.Add(hl);
  291.                     tr.Cells.Add(td);
  292.                     Table1.Rows.Add(tr);
  293.                     array_1.Add(array_2);
  294.                     flag = 1;
  295.                 }
  296.                 dr.Close();
  297.                 if (flag == 0)
  298.                 {
  299.                     array_1 = new ArrayList();
  300.                     cmd.CommandText = "select f.id,f.form_id,e.emp_name,d.name,f.business_begin,f.business_end,f.days,f.off_type from oa_tw_approvel_form" +
  301.                             " as f inner join oa_employee as e on f.emp_id=e.id inner join oa_department as d on e.department_id=d.id where" +
  302.                             " vacation_begin>='" + TxtBeginTime.Text + "' and  vacation_begin<='" + TxtEndTime.Text + "' and off_type=1 and total_result='同意'and emp_no='"+TxtEmp_no.Text+
  303.                             "' order by name,emp_name";
  304.                     cmd.Connection = con;
  305.                     SqlDataReader dr1 = cmd.ExecuteReader();
  306.                     while (dr1.Read())
  307.                     {
  308.                         array_2 = new ArrayList();
  309.                         Table1.Visible = true;
  310.                         TableRow tr = new TableRow();
  311.                         TableCell td = new TableCell();
  312.                         td.BorderWidth = Unit.Pixel(1);
  313.                         td.Text = dr1["form_id"].ToString();
  314.                         array_2.Add("'" + Convert.ToString(dr1["form_id"]));
  315.                         tr.Cells.Add(td);
  316.                         td = new TableCell();
  317.                         td.BorderWidth = Unit.Pixel(1);
  318.                         td.Text = dr1["name"].ToString();
  319.                         array_2.Add(Convert.ToString(dr1["name"]));
  320.                         tr.Cells.Add(td);
  321.                         td = new TableCell();
  322.                         td.BorderWidth = Unit.Pixel(1);
  323.                         td.Text = dr1["emp_name"].ToString();
  324.                         array_2.Add(Convert.ToString(dr1["emp_name"]));
  325.                         tr.Cells.Add(td);
  326.                         td = new TableCell();
  327.                         td.BorderWidth = Unit.Pixel(1);
  328.                         td.Text = dr1["business_begin"].ToString();
  329.                         array_2.Add("'" + Convert.ToString(dr1["business_begin"]));
  330.                         tr.Cells.Add(td);
  331.                         td = new TableCell();
  332.                         td.BorderWidth = Unit.Pixel(1);
  333.                         td.Text = dr1["business_end"].ToString();
  334.                         array_2.Add("'" + Convert.ToString(dr1["business_end"]));
  335.                         tr.Cells.Add(td);
  336.                         td = new TableCell();
  337.                         td.BorderWidth = Unit.Pixel(1);
  338.                         td.Text = dr["days"].ToString() + "天";
  339.                         array_2.Add(Convert.ToString(td.Text));
  340.                         tr.Cells.Add(td);
  341.                         td = new TableCell();
  342.                         td.BorderWidth = Unit.Pixel(1);
  343.                         HyperLink hl = new HyperLink();
  344.                         hl.Text = "查看";
  345.                         hl.Target = "blank";
  346.                         hl.NavigateUrl = "../../approvel/tw/my_list.aspx?a_id=" + dr1["f_id"].ToString()+"&k=1";
  347.                         td.Controls.Add(hl);
  348.                         tr.Cells.Add(td);
  349.                         Table1.Rows.Add(tr);
  350.                         array_1.Add(array_2);
  351.                     }
  352.                     dr1.Close();
  353.                 
  354.                 cmd.CommandText = "select f.id,f.form_id,e.emp_name,d.name,f.begin_time,f.end_time,f.days from oa_ch_business_form " +
  355.                     " as f inner join oa_employee as e on f.emp_id=e.id inner join oa_department as d on e.department_id=d.id where" +
  356.                     " begin_time>='" + TxtBeginTime.Text + "' and  begin_time<='" + TxtEndTime.Text + "'and emp_no='" + TxtEmp_no.Text + "'and total_result='同意' order by name,emp_name";
  357.                 cmd.Connection = con;
  358.                 SqlDataReader dr2 = cmd.ExecuteReader();
  359.                 while (dr2.Read())
  360.                 {
  361.                     array_2 = new ArrayList();
  362.                     Table1.Visible = true;
  363.                     TableRow tr = new TableRow();
  364.                     TableCell td = new TableCell();
  365.                     td.BorderWidth = Unit.Pixel(1);
  366.                     td.Text = dr2["form_id"].ToString();
  367.                     array_2.Add("'" + Convert.ToString(dr2["form_id"]));
  368.                     tr.Cells.Add(td);
  369.                     td = new TableCell();
  370.                     td.BorderWidth = Unit.Pixel(1);
  371.                     td.Text = dr2["name"].ToString();
  372.                     array_2.Add(Convert.ToString(dr2["name"]));
  373.                     tr.Cells.Add(td);
  374.                     td = new TableCell();
  375.                     td.BorderWidth = Unit.Pixel(1);
  376.                     td.Text = dr2["emp_name"].ToString();
  377.                     array_2.Add(Convert.ToString(dr2["emp_name"]));
  378.                     tr.Cells.Add(td);
  379.                     td = new TableCell();
  380.                     td.BorderWidth = Unit.Pixel(1);
  381.                     td.Text = dr2["begin_time"].ToString();
  382.                     array_2.Add("'" + Convert.ToString(dr2["begin_time"]));
  383.                     tr.Cells.Add(td);
  384.                     td = new TableCell();
  385.                     td.BorderWidth = Unit.Pixel(1);
  386.                     td.Text = dr2["end_time"].ToString();
  387.                     array_2.Add("'" + Convert.ToString(dr2["end_time"]));
  388.                     tr.Cells.Add(td);
  389.                     if (DrpDownType.SelectedValue.ToString().Equals("2"))
  390.                     {
  391.                         td = new TableCell();
  392.                         td.BorderWidth = Unit.Pixel(1);
  393.                         td.Text = dr2["days"].ToString() + "天";
  394.                         array_2.Add(Convert.ToString(td.Text));
  395.                     }
  396.                     else if (DrpDownType.SelectedValue.ToString().Equals("3"))
  397.                     {
  398.                         td = new TableCell();
  399.                         td.BorderWidth = Unit.Pixel(1);
  400.                         td.Text = dr2["hours"].ToString() + "小時";
  401.                         array_2.Add(Convert.ToString(td.Text));
  402.                     }
  403.                     tr.Cells.Add(td);
  404.                     td = new TableCell();
  405.                     td.BorderWidth = Unit.Pixel(1);
  406.                     HyperLink hl = new HyperLink();
  407.                     hl.Text = "查看";
  408.                     hl.Target = "blank";
  409.                     hl.NavigateUrl = "../../approvel/ch/my_list_d.aspx?a_id=" + dr2["id"].ToString()+"&k=1";
  410.                     td.Controls.Add(hl);
  411.                     tr.Cells.Add(td);
  412.                     Table1.Rows.Add(tr);
  413.                     array_1.Add(array_2);
  414.                 } dr2.Close();
  415.             }
  416.             }
  417.                    
  418.                     con.Close();
  419.                 }
  420.                 
  421.       else
  422.         {
  423.             Response.Write("<script>alert('日期不能為空!')</script>");
  424.         }
  425.     }
  426.         
  427.       
  428.    
  429.     public void getexcel()
  430.     {
  431.         ExcelApplication exc = new ExcelApplication();
  432.          exc.Visible = false;
  433.         exc.UserControl = false;
  434.         Workbooks workbooks = exc.Workbooks;
  435.         _Workbook workbook = workbooks.Add(true);
  436.         Sheets shs = workbook.Sheets;
  437.         _Worksheet sh = (_Worksheet)shs.get_Item(1);
  438.         Range rang = sh.get_Range(sh.Cells[1, 1], sh.Cells[1, 6]);
  439.         rang.Merge(true);
  440.         rang.Value2 = "差假統計表";
  441.         sh.Cells[2, 1] = "單號";
  442.         sh.Cells[2, 2] = "部門";
  443.         sh.Cells[2, 3] = "姓名";
  444.         sh.Cells[2, 4] = "日期起";
  445.         sh.Cells[2, 5] = "日期迄";
  446.         sh.Cells[2, 6] = "總計";
  447.         rang.HorizontalAlignment = XlHAlign.xlHAlignCenter;
  448.         int n=3;
  449.         int m=1;
  450.         foreach(ArrayList i in array_1)
  451.         {
  452.             m = 1;
  453.             foreach (string j in i)
  454.             {
  455.                 Range rang1 = sh.get_Range(sh.Cells[n,m],sh.Cells[n,m]);
  456.                // rang1.Merge(true);
  457.                 rang1.Value2 = j;
  458.                 m++;
  459.             }
  460.             n++;
  461.         }
  462.         exc.Visible = true;
  463.         exc.UserControl = true;
  464.         exc.Columns.AutoFit();
  465.         exc.Columns.HorizontalAlignment = XlHAlign.xlHAlignCenter;
  466.         string strFilePhysicalPath = Server.MapPath(str_path) + str_name;
  467.         if (File.Exists(strFilePhysicalPath))
  468.         {
  469.             File.Delete(strFilePhysicalPath);
  470.         }
  471.         sh.Name = "hello";
  472.         exc.DisplayAlerts = false;
  473.         exc.AlertBeforeOverwriting = false;
  474.         //exc.Save(strFilePhysicalPath);
  475.         sh.SaveAs(strFilePhysicalPath, Type.Missing, Type.Missing, Type.Missing,
  476.         Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
  477.         workbook.Save();
  478.         ReleaseCom(sh);
  479.         ReleaseCom(shs);
  480.         ReleaseCom(workbook);
  481.         ReleaseCom(workbooks);
  482.         exc.Quit();
  483.         ReleaseCom(exc);
  484.        
  485.     }
  486.   
  487.     protected void Button1_Click(object sender, EventArgs e)
  488.     {
  489.         getnum();
  490.     }
  491.     private void ReleaseCom(object pComObj)
  492.     {
  493.         try
  494.         {
  495.             if (pComObj != null)
  496.             {
  497.                 System.Runtime.InteropServices.Marshal.ReleaseComObject(pComObj);
  498.             }
  499.         }
  500.         catch
  501.         {
  502.         }
  503.         finally
  504.         {
  505.             pComObj = null;
  506.         }
  507.     }
  508.     protected void Button2_Click(object sender, EventArgs e)
  509.     {
  510.         int flag = 0;
  511.         getnum();
  512.         getexcel();
  513.         flag = download(str_name ,str_path);
  514.     }
  515.  
  516.     protected void DropDf_type_SelectedIndexChanged(object sender, EventArgs e)
  517.     {
  518.         if (DropDf_type.SelectedValue.ToString().Equals("1"))
  519.         {
  520.             Label6.Enabled = false;
  521.             TxtEmp_no.Enabled = false;
  522.             DrpDownType.Enabled = true;
  523.             Label2.Enabled = true;
  524.         }
  525.         else
  526.         {
  527.             Label6.Enabled = true;
  528.             TxtEmp_no.Enabled = true;
  529.             DrpDownType.Enabled = false;
  530.             Label2.Enabled = false;
  531.         }
  532.     }
  533.     public int download(string str_name,string str_path)
  534.     {
  535.         try
  536.         {
  537.             string FullFileName = Server.MapPath(str_path) + str_name; 
  538.             FileInfo DownloadFile = new FileInfo(FullFileName);
  539.             Response.Clear();
  540.             Response.ClearHeaders();
  541.             Response.Buffer = false;
  542.             Response.ContentType = "application/octet-stream";
  543.             Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
  544.             Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
  545.             Response.WriteFile(DownloadFile.FullName);
  546.             Response.Flush();
  547.             Response.End();
  548.             return 1;
  549.         }
  550.         catch (Exception ex)
  551.         {
  552.             Response.Write(ex.Message);
  553.             return 0;
  554.         }
  555.     }
  556.     protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  557.     {
  558.         if (Calendar1.Visible == true)
  559.         {
  560.             Calendar1.Visible = false;
  561.         }
  562.         else
  563.         {
  564.             Calendar1.Visible = true;
  565.         }
  566.     }
  567.     protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
  568.     {
  569.         if (Calendar2.Visible == true)
  570.         {
  571.             Calendar2.Visible = false;
  572.         }
  573.         else
  574.         {
  575.             Calendar2.Visible = true;
  576.         }
  577.     }
  578.     protected void Calendar1_SelectionChanged(object sender, EventArgs e)
  579.     {
  580.         string year = Calendar1.SelectedDate.Year.ToString();
  581.         string month = Calendar1.SelectedDate.Month.ToString();
  582.         if (month.Length == 1)
  583.         {
  584.             month = "0" + month;
  585.         }
  586.         string day = Calendar1.SelectedDate.Day.ToString();
  587.         if (day.Length == 1)
  588.         {
  589.             day = "0" + day;
  590.         }
  591.         TxtBeginTime.Text = year + "-" + month + "-" + day;
  592.         Calendar1.Visible = false;
  593.     }
  594.     protected void Calendar2_SelectionChanged(object sender, EventArgs e)
  595.     {
  596.         string year = Calendar2.SelectedDate.Year.ToString();
  597.         string month = Calendar2.SelectedDate.Month.ToString();
  598.         if (month.Length == 1)
  599.         {
  600.             month = "0" + month;
  601.         }
  602.         string day = Calendar2.SelectedDate.Day.ToString();
  603.         if (day.Length == 1)
  604.         {
  605.             day = "0" + day;
  606.         }
  607.         TxtEndTime.Text = year + "-" + month + "-" + day;
  608.         Calendar2.Visible = false;
  609.     }
  610.     public void is_ok() 
  611.     {
  612.         if (Table1.Visible = false)
  613.         {
  614.             Button2.Enabled = false;
  615.         }
  616.         else { Button2.Enabled = true; }
  617.     }
  618. }