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

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. public partial class web_fair_approvel_select : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             this.SetTable();
  19.         }
  20.     }
  21.     protected void SetTable()
  22.     {
  23.         int user_id = 0;
  24.         if (Session["user_id"] != null)
  25.         {
  26.             user_id = Convert.ToInt32(Session["user_id"]);
  27.         }
  28.         if (user_id != 0)
  29.         {
  30.             SqlConnection conn = dbConnection.getConnection();
  31.             conn.Open();
  32.             int flag = 0;
  33.             SqlCommand cmd = new SqlCommand("select f.id, f.form_id, f.vacation_begin, f.vacation_end, " +
  34.                 "f.business_begin, f.business_end, t.name type, f.vacation_place from OA_TW_APPROVEL_FORM f " +
  35.                 "inner join OA_TW_OFF_TYPE t on f.off_type=t.id where emp_id=" + user_id + " order by form_id desc", conn);
  36.             SqlDataReader dr = cmd.ExecuteReader();
  37.             while (dr.Read())
  38.             {
  39.                 flag = 1;
  40.                 TableRow tr = new TableRow();
  41.                 TableCell td = new TableCell();
  42.                 td.BorderWidth = Unit.Pixel(1);
  43.                 CheckBox chk = new CheckBox();
  44.                 chk.ID = dr["id"].ToString() + "-" + dr["form_id"].ToString() + "-" + "OA_TW_APPROVEL_FORM";
  45.                 td.Controls.Add(chk);
  46.                 tr.Cells.Add(td);
  47.                 td = new TableCell();
  48.                 td.BorderWidth = Unit.Pixel(1);
  49.                 td.Text = dr["form_id"].ToString();
  50.                 tr.Cells.Add(td);
  51.                 td = new TableCell();
  52.                 td.BorderWidth = Unit.Pixel(1);
  53.                 td.Text = dr["type"].ToString();
  54.                 tr.Cells.Add(td);
  55.                 if (dr["type"].ToString().Equals("出差"))
  56.                 {
  57.                     td = new TableCell();
  58.                     td.BorderWidth = Unit.Pixel(1);
  59.                     td.Text = dr["business_begin"].ToString();
  60.                     tr.Cells.Add(td);
  61.                     td = new TableCell();
  62.                     td.BorderWidth = Unit.Pixel(1);
  63.                     td.Text = dr["business_end"].ToString();
  64.                     tr.Cells.Add(td);
  65.                 }
  66.                 else
  67.                 {
  68.                     td = new TableCell();
  69.                     td.BorderWidth = Unit.Pixel(1);
  70.                     td.Text = dr["vacation_begin"].ToString();
  71.                     tr.Cells.Add(td);
  72.                     td = new TableCell();
  73.                     td.BorderWidth = Unit.Pixel(1);
  74.                     td.Text = dr["vacation_end"].ToString();
  75.                     tr.Cells.Add(td);
  76.                 }
  77.                 TblForm.Rows.Add(tr);
  78.             }
  79.             dr.Close();
  80.             if (flag == 0)
  81.             {
  82.                 cmd = new SqlCommand("select id, form_id, begin_time, end_time from OA_CH_BUSINESS_FORM " +
  83.                     "where emp_id=" + user_id + " order by form_id desc", conn);
  84.                 dr = cmd.ExecuteReader();
  85.                 while (dr.Read())
  86.                 {
  87.                     flag = 1;
  88.                     TableRow tr = new TableRow();
  89.                     TableCell td = new TableCell(); 
  90.                     td.BorderWidth = Unit.Pixel(1);
  91.                     CheckBox chk = new CheckBox();
  92.                     chk.ID = dr["id"].ToString() + "-" + dr["form_id"].ToString() + "-" + "OA_CH_BUSINESS_FORM";
  93.                     td.Controls.Add(chk);
  94.                     tr.Cells.Add(td);
  95.                     td = new TableCell();
  96.                     td.BorderWidth = Unit.Pixel(1);
  97.                     td.Text = dr["form_id"].ToString();
  98.                     tr.Cells.Add(td);
  99.                     td = new TableCell();
  100.                     td.BorderWidth = Unit.Pixel(1);
  101.                     td.Text = "出差";
  102.                     tr.Cells.Add(td);
  103.                     td = new TableCell();
  104.                     td.BorderWidth = Unit.Pixel(1);
  105.                     td.Text = dr["begin_time"].ToString();
  106.                     tr.Cells.Add(td);
  107.                     td = new TableCell();
  108.                     td.BorderWidth = Unit.Pixel(1);
  109.                     td.Text = dr["end_time"].ToString();
  110.                     tr.Cells.Add(td);
  111.                     TblForm.Rows.Add(tr);
  112.                 }
  113.                 dr.Close();
  114.                 cmd = new SqlCommand("select f.id, f.form_id, t.name type, f.begin_time, f.end_time from " +
  115.                     "OA_CH_OFF_FORM f inner join OA_CH_OFF_TYPE t on f.off_type=t.id where emp_id=" + user_id +
  116.                     " order by f.form_id", conn);
  117.                 dr = cmd.ExecuteReader();
  118.                 while (dr.Read())
  119.                 {
  120.                     flag = 1;
  121.                     TableRow tr = new TableRow();
  122.                     TableCell td = new TableCell();
  123.                     td.BorderWidth = Unit.Pixel(1);
  124.                     CheckBox chk = new CheckBox();
  125.                     chk.ID = dr["id"].ToString() + "-" + dr["form_id"].ToString() + "-" + "OA_CH_OFF_FORM";
  126.                     td.Controls.Add(chk);
  127.                     tr.Cells.Add(td);
  128.                     td = new TableCell();
  129.                     td.BorderWidth = Unit.Pixel(1);
  130.                     td.Text = dr["form_id"].ToString();
  131.                     tr.Cells.Add(td);
  132.                     td = new TableCell();
  133.                     td.BorderWidth = Unit.Pixel(1);
  134.                     td.Text = dr["type"].ToString();
  135.                     tr.Cells.Add(td);
  136.                     td = new TableCell();
  137.                     td.BorderWidth = Unit.Pixel(1);
  138.                     td.Text = dr["begin_time"].ToString();
  139.                     tr.Cells.Add(td);
  140.                     td = new TableCell();
  141.                     td.BorderWidth = Unit.Pixel(1);
  142.                     td.Text = dr["end_time"].ToString();
  143.                     tr.Cells.Add(td);
  144.                     TblForm.Rows.Add(tr);
  145.                 }
  146.                 dr.Close();
  147.             }
  148.             if (flag == 0)
  149.             {
  150.                 TblForm.Visible = false;
  151.             }
  152.             conn.Close();
  153.         }
  154.     }
  155. }