mail_statistic.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_mail_mail_statistic : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         LoginDAO.CheckLogin(Session, Response, "../", 2);
  17.         if (!IsPostBack)
  18.         {
  19.             if (Request.QueryString["mail_id"] != null)
  20.             {
  21.                 this.AddIsRead(Request.QueryString["mail_id"]);
  22.                 this.AddUnRead(Request.QueryString["mail_id"]);
  23.             }
  24.         }
  25.     }
  26.     public void AddIsRead(string mail_id)
  27.     {
  28.         ArrayList emp_names = new ArrayList();
  29.         ArrayList department_id = new ArrayList();
  30.         ArrayList read_date = new ArrayList();//創建已讀人員信息列表
  31.         SqlConnection conn = dbConnection.getConnection();
  32.         conn.Open();
  33.         SqlCommand cmd = new SqlCommand("select r.id, e.emp_name, e.department_id, r.read_date from " +
  34.             "OA_MAIL_RECEIVER r inner join OA_EMPLOYEE e on r.receiver=e.id where is_read=1 and mail_id=" + mail_id, conn);
  35.         SqlDataReader dr = cmd.ExecuteReader();
  36.         emp_names.Clear();
  37.         department_id.Clear();
  38.         read_date.Clear();
  39.         while (dr.Read())
  40.         {
  41.             emp_names.Add(dr["emp_name"].ToString());
  42.             department_id.Add(dr["department_id"].ToString());
  43.             read_date.Add(dr["read_date"].ToString());
  44.         }
  45.         dr.Close();
  46.         if (emp_names.Count > 0)
  47.         {
  48.             //添加表頭
  49.             TableHeaderRow hr = new TableHeaderRow();
  50.             TableHeaderCell hc = new TableHeaderCell();
  51.             hc.BorderWidth = Unit.Pixel(1);
  52.             hc.ColumnSpan = 3;
  53.             hc.HorizontalAlign = HorizontalAlign.Left;
  54.             Label head = new Label();
  55.             head.Text = "已讀人員列表";
  56.             hc.Controls.Add(head);
  57.             hr.Cells.Add(hc);
  58.             TblIsRead.Rows.Add(hr);
  59.             TableRow tr = new TableRow();
  60.             TableCell cell1 = new TableCell();
  61.             cell1.BorderWidth = Unit.Pixel(1);
  62.             cell1.Text = "員工姓名";
  63.             TableCell cell2 = new TableCell();
  64.             cell2.BorderWidth = Unit.Pixel(1);
  65.             cell2.Text = "所屬部門";
  66.             TableCell cell3 = new TableCell();
  67.             cell3.BorderWidth = Unit.Pixel(1);
  68.             cell3.Text = "最後閱讀時間";
  69.             tr.Cells.Add(cell1);
  70.             tr.Cells.Add(cell2);
  71.             tr.Cells.Add(cell3);
  72.             TblIsRead.Rows.Add(tr);
  73.         }
  74.         for (int i = 0; i < department_id.Count; i++)
  75.         {
  76.             DepartmentDAO departmentDAO = new DepartmentDAO();
  77.             Department department = departmentDAO.queryById(Convert.ToInt32(department_id[i]));
  78.             TableRow tr = new TableRow();
  79.             TableCell cell1 = new TableCell();
  80.             cell1.BorderWidth = Unit.Pixel(1);
  81.             cell1.Text = emp_names[i].ToString();
  82.             TableCell cell2 = new TableCell();
  83.             cell2.BorderWidth = Unit.Pixel(1);
  84.             cell2.Text = department.Full_name;
  85.             TableCell cell3 = new TableCell();
  86.             cell3.BorderWidth = Unit.Pixel(1);
  87.             cell3.Text = read_date[i].ToString();
  88.             tr.Cells.Add(cell1);
  89.             tr.Cells.Add(cell2);
  90.             tr.Cells.Add(cell3);
  91.             TblIsRead.Rows.Add(tr);
  92.         }
  93.         conn.Close();
  94.     }
  95.     public void AddUnRead(string mail_id)
  96.     {
  97.         ArrayList emp_names = new ArrayList();
  98.         ArrayList department_id = new ArrayList();
  99.         ArrayList read_date = new ArrayList();//創建已讀人員信息列表
  100.         SqlConnection conn = dbConnection.getConnection();
  101.         conn.Open();
  102.         SqlCommand cmd = new SqlCommand("select r.id, e.emp_name, e.department_id, r.read_date from " +
  103.             "OA_MAIL_RECEIVER r inner join OA_EMPLOYEE e on r.receiver=e.id where is_read=0 and mail_id=" + mail_id, conn);
  104.         SqlDataReader dr = cmd.ExecuteReader();
  105.         emp_names.Clear();
  106.         department_id.Clear();
  107.         read_date.Clear();
  108.         while (dr.Read())
  109.         {
  110.             emp_names.Add(dr["emp_name"].ToString());
  111.             department_id.Add(dr["department_id"].ToString());
  112.             read_date.Add(dr["read_date"].ToString());
  113.         }
  114.         dr.Close();
  115.         if (emp_names.Count > 0)
  116.         {
  117.             //添加表頭
  118.             TableHeaderRow hr = new TableHeaderRow();
  119.             TableHeaderCell hc = new TableHeaderCell();
  120.             hc.BorderWidth = Unit.Pixel(1);
  121.             hc.ColumnSpan = 2;
  122.             hc.HorizontalAlign = HorizontalAlign.Left;
  123.             Label head = new Label();
  124.             head.Text = "未讀人員列表";
  125.             hc.Controls.Add(head);
  126.             hr.Cells.Add(hc);
  127.             TblUnRead.Rows.Add(hr);
  128.             TableRow tr = new TableRow();
  129.             TableCell cell1 = new TableCell();
  130.             cell1.BorderWidth = Unit.Pixel(1);
  131.             cell1.Text = "員工姓名";
  132.             TableCell cell2 = new TableCell();
  133.             cell2.BorderWidth = Unit.Pixel(1);
  134.             cell2.Text = "所屬部門";
  135.             tr.Cells.Add(cell1);
  136.             tr.Cells.Add(cell2);
  137.             TblUnRead.Rows.Add(tr);
  138.         }
  139.         for (int i = 0; i < department_id.Count; i++)
  140.         {
  141.             DepartmentDAO departmentDAO = new DepartmentDAO();
  142.             Department department = departmentDAO.queryById(Convert.ToInt32(department_id[i]));
  143.             TableRow tr = new TableRow();
  144.             TableCell cell1 = new TableCell();
  145.             cell1.BorderWidth = Unit.Pixel(1);
  146.             cell1.Text = emp_names[i].ToString();
  147.             TableCell cell2 = new TableCell();
  148.             cell2.BorderWidth = Unit.Pixel(1);
  149.             cell2.Text = department.Full_name;
  150.             tr.Cells.Add(cell1);
  151.             tr.Cells.Add(cell2);
  152.             TblUnRead.Rows.Add(tr);
  153.         }
  154.         conn.Close();    
  155.     }
  156. }