deal_list.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:9k
源码类别:
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;
- using System.Net.Mail;
- using System.Net;
- using System.Net.Sockets;
- public partial class web_fair_deal_list : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../", 2);
- this.SetTable();
- }
- if (Request.QueryString["f_id"] != null)
- {
- this.SetForm(Request.QueryString["f_id"]);
- PnlFair.Visible = true;
- PnlDeal.Visible = true;
- }
- }
- //mail给待签核人
- protected void SetForm(string id)
- {
- string fair_id = "0";
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select form_id from OA_FAIR_FORM_FLOW where id=" + id, conn);
- fair_id = cmd.ExecuteScalar().ToString();
- cmd = new SqlCommand("select e.emp_name, e.emp_no, f.apply_date, f.amount, f.remark, f.form_no, " +
- "f.subject, f.form_id, f.form_table from OA_FAIR f inner join OA_EMPLOYEE e on f.emp_id=e.id " +
- "where f.id=" + fair_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- string form_id = "0";
- string form_table = "";
- if (dr.Read())
- {
- TxtEmpName.Text = dr["emp_name"].ToString();
- TxtEmpNo.Text = dr["emp_no"].ToString();
- TxtApplyDate.Text = dr["apply_date"].ToString();
- TxtAmount.Text = dr["amount"].ToString();
- TxtRemark.Text = dr["remark"].ToString();
- TxtFormNo.Text = dr["form_no"].ToString();
- TxtSubject.Text = dr["subject"].ToString();
- if (!dr["form_id"].Equals("0"))
- {
- TblFair.Rows[7].Visible = true;
- form_id = dr["form_id"].ToString();
- form_table = dr["form_table"].ToString();
- }
- }
- dr.Close();
- if (!form_id.Equals("0"))
- {
- cmd = new SqlCommand("select form_id from " + form_table + " where id=" + form_id, conn);
- HlFormNo.Text = cmd.ExecuteScalar().ToString();
- HlFormNo.NavigateUrl = "form_show.aspx?id=" + form_id + "&table=" + form_table;
- HlFormNo.Target = "_blank";
- }
- cmd = new SqlCommand("select attachment, attachment_save_name, content_length from OA_FAIR_ATTACHMENT where fair_id=" + fair_id, conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- TblFair.Rows[9].Visible = true;
- HyperLink img = new HyperLink();
- img.ToolTip = dr["attachment"].ToString();
- img.ImageUrl = "../fair_picture/" + dr["attachment_save_name"].ToString();
- img.Target = "_blank";
- img.Width = Unit.Pixel(450);
- img.NavigateUrl = img.ImageUrl;
- PnlPicture.Controls.Add(img);
- }
- dr.Close();
- conn.Close();
- }
- protected void SetTable()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- string user_id = "0";
- if (Session["user_id"] != null)
- {
- user_id = Session["user_id"].ToString();
- }
- SqlCommand cmd = new SqlCommand("SELECT f.id, f.step f_step, a.step a_step, e.department_id, "+
- "e.emp_name, a.apply_date FROM dbo.OA_FAIR_FORM_FLOW AS f INNER JOIN dbo.OA_FAIR AS a ON "+
- "f.form_id = a.id INNER JOIN dbo.OA_EMPLOYEE AS e ON a.emp_id = e.id WHERE (f.operator_id = " +
- user_id + ") AND (f.is_check = 'N') order by a.apply_date desc", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- int a_step = Convert.ToInt32(dr["a_step"].ToString()) + 1;
- int f_step = Convert.ToInt32(dr["f_step"].ToString());
- if (a_step == f_step)
- {
- TblFlow.Visible = true;
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["emp_name"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- DepartmentDAO departmentDAO = new DepartmentDAO();
- string department = departmentDAO.queryById(Convert.ToInt32(dr["department_id"].ToString())).Full_name;
- td.Text = department;
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["apply_date"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- HyperLink hl = new HyperLink();
- hl.Text = "查看";
- hl.NavigateUrl = "deal_list.aspx?f_id=" + dr["id"].ToString();
- td.Controls.Add(hl);
- tr.Cells.Add(td);
- TblFlow.Rows.Add(tr);
- }
- }
- dr.Close();
- conn.Close();
- }
- protected void RbAgree_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (TxtComment.Text.Equals("已同意") || TxtComment.Text.Equals("不同意"))
- {
- if (RbAgree.SelectedValue.Equals("Y"))
- {
- TxtComment.Text = "已同意";
- }
- else
- {
- TxtComment.Text = "不同意";
- }
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlTransaction tx = conn.BeginTransaction();
- try
- {
- DateMgr mgr = new DateMgr();
- SqlCommand cmd = new SqlCommand("update OA_FAIR_FORM_FLOW set is_check='Y', is_agree='" +
- RbAgree.SelectedValue + "', comment='" + TxtComment.Text.Replace("n", "<br>") + "', check_date='" + mgr.getDateTime() +
- "' where id=" + Request.QueryString["f_id"], conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- cmd = new SqlCommand("select form_id from OA_FAIR_FORM_FLOW where id=" + Request.QueryString["f_id"], conn);
- cmd.Transaction = tx;
- int form_id = Convert.ToInt32(cmd.ExecuteScalar());
- cmd = new SqlCommand("select max(step) from OA_FAIR_FORM_FLOW where form_id=" + form_id, conn);
- cmd.Transaction = tx;
- int max_step = Convert.ToInt32(cmd.ExecuteScalar());
- cmd = new SqlCommand("select step from OA_FAIR where id=" + form_id, conn);
- cmd.Transaction = tx;
- int step = Convert.ToInt32(cmd.ExecuteScalar());
- string total_result = "跑流程中";
- string time = "";
- if (max_step == step + 1)
- {
- if (RbAgree.SelectedValue.Equals("N"))
- {
- total_result = "不同意";
- }
- else
- {
- total_result = "同意";
- }
- time = mgr.getDateTime();
- }
- else
- {
- if (RbAgree.SelectedValue.Equals("N"))
- {
- total_result = "不同意";
- time = mgr.getDateTime();
- }
- }
- cmd = new SqlCommand("update OA_FAIR set step=step+1, total_result='" +
- total_result + "', finish_date='" + time + "' where id=" + form_id, conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- tx.Commit();
- ArrayList name1 = new ArrayList();
- ArrayList mail1 = new ArrayList();
- cmd = new SqlCommand("select top 1 a.email_work,a.emp_name from oa_employee as a inner join "+
- "OA_FAIR_FORM_FLOW as b on b.operator_id=a.id left join OA_FAIR as c "+
- "on b.form_id=c.id where b.step=c.step+1 and c.id=" + form_id + " order by position desc", conn);
- cmd.Transaction = tx;
- SqlDataReader dr3 = cmd.ExecuteReader();
- while (dr3.Read())
- {
- name1.Add(dr3["emp_name"].ToString());
- mail1.Add(dr3["email_work"].ToString());
- //mail_q(mail1[0],name1[0]);
- mail.mail_q(mail1[0],name1[0],TxtEmpName.Text);
- } dr3.Close();
- //
- }
- catch (Exception ex)
- {
- Response.Write(ex.ToString());
- //tx.Rollback();
- }
- conn.Close();
- Response.Redirect("finish_list.aspx");
- }
- }