mail_statistic.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:6k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- 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 System.Data.SqlClient;
- public partial class web_mail_mail_statistic : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- if (!IsPostBack)
- {
- if (Request.QueryString["mail_id"] != null)
- {
- this.AddIsRead(Request.QueryString["mail_id"]);
- this.AddUnRead(Request.QueryString["mail_id"]);
- }
- }
- }
- public void AddIsRead(string mail_id)
- {
- ArrayList emp_names = new ArrayList();
- ArrayList department_id = new ArrayList();
- ArrayList read_date = new ArrayList();//創建已讀人員信息列表
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select r.id, e.emp_name, e.department_id, r.read_date from " +
- "OA_MAIL_RECEIVER r inner join OA_EMPLOYEE e on r.receiver=e.id where is_read=1 and mail_id=" + mail_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- emp_names.Clear();
- department_id.Clear();
- read_date.Clear();
- while (dr.Read())
- {
- emp_names.Add(dr["emp_name"].ToString());
- department_id.Add(dr["department_id"].ToString());
- read_date.Add(dr["read_date"].ToString());
- }
- dr.Close();
- if (emp_names.Count > 0)
- {
- //添加表頭
- TableHeaderRow hr = new TableHeaderRow();
- TableHeaderCell hc = new TableHeaderCell();
- hc.BorderWidth = Unit.Pixel(1);
- hc.ColumnSpan = 3;
- hc.HorizontalAlign = HorizontalAlign.Left;
- Label head = new Label();
- head.Text = "已讀人員列表";
- hc.Controls.Add(head);
- hr.Cells.Add(hc);
- TblIsRead.Rows.Add(hr);
- TableRow tr = new TableRow();
- TableCell cell1 = new TableCell();
- cell1.BorderWidth = Unit.Pixel(1);
- cell1.Text = "員工姓名";
- TableCell cell2 = new TableCell();
- cell2.BorderWidth = Unit.Pixel(1);
- cell2.Text = "所屬部門";
- TableCell cell3 = new TableCell();
- cell3.BorderWidth = Unit.Pixel(1);
- cell3.Text = "最後閱讀時間";
- tr.Cells.Add(cell1);
- tr.Cells.Add(cell2);
- tr.Cells.Add(cell3);
- TblIsRead.Rows.Add(tr);
- }
- for (int i = 0; i < department_id.Count; i++)
- {
- DepartmentDAO departmentDAO = new DepartmentDAO();
- Department department = departmentDAO.queryById(Convert.ToInt32(department_id[i]));
- TableRow tr = new TableRow();
- TableCell cell1 = new TableCell();
- cell1.BorderWidth = Unit.Pixel(1);
- cell1.Text = emp_names[i].ToString();
- TableCell cell2 = new TableCell();
- cell2.BorderWidth = Unit.Pixel(1);
- cell2.Text = department.Full_name;
- TableCell cell3 = new TableCell();
- cell3.BorderWidth = Unit.Pixel(1);
- cell3.Text = read_date[i].ToString();
- tr.Cells.Add(cell1);
- tr.Cells.Add(cell2);
- tr.Cells.Add(cell3);
- TblIsRead.Rows.Add(tr);
- }
- conn.Close();
- }
- public void AddUnRead(string mail_id)
- {
- ArrayList emp_names = new ArrayList();
- ArrayList department_id = new ArrayList();
- ArrayList read_date = new ArrayList();//創建已讀人員信息列表
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select r.id, e.emp_name, e.department_id, r.read_date from " +
- "OA_MAIL_RECEIVER r inner join OA_EMPLOYEE e on r.receiver=e.id where is_read=0 and mail_id=" + mail_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- emp_names.Clear();
- department_id.Clear();
- read_date.Clear();
- while (dr.Read())
- {
- emp_names.Add(dr["emp_name"].ToString());
- department_id.Add(dr["department_id"].ToString());
- read_date.Add(dr["read_date"].ToString());
- }
- dr.Close();
- if (emp_names.Count > 0)
- {
- //添加表頭
- TableHeaderRow hr = new TableHeaderRow();
- TableHeaderCell hc = new TableHeaderCell();
- hc.BorderWidth = Unit.Pixel(1);
- hc.ColumnSpan = 2;
- hc.HorizontalAlign = HorizontalAlign.Left;
- Label head = new Label();
- head.Text = "未讀人員列表";
- hc.Controls.Add(head);
- hr.Cells.Add(hc);
- TblUnRead.Rows.Add(hr);
- TableRow tr = new TableRow();
- TableCell cell1 = new TableCell();
- cell1.BorderWidth = Unit.Pixel(1);
- cell1.Text = "員工姓名";
- TableCell cell2 = new TableCell();
- cell2.BorderWidth = Unit.Pixel(1);
- cell2.Text = "所屬部門";
- tr.Cells.Add(cell1);
- tr.Cells.Add(cell2);
- TblUnRead.Rows.Add(tr);
- }
- for (int i = 0; i < department_id.Count; i++)
- {
- DepartmentDAO departmentDAO = new DepartmentDAO();
- Department department = departmentDAO.queryById(Convert.ToInt32(department_id[i]));
- TableRow tr = new TableRow();
- TableCell cell1 = new TableCell();
- cell1.BorderWidth = Unit.Pixel(1);
- cell1.Text = emp_names[i].ToString();
- TableCell cell2 = new TableCell();
- cell2.BorderWidth = Unit.Pixel(1);
- cell2.Text = department.Full_name;
- tr.Cells.Add(cell1);
- tr.Cells.Add(cell2);
- TblUnRead.Rows.Add(tr);
- }
- conn.Close();
- }
- }