deal.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:8k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Drawing;
- using System.Data;
- using System.Data.SqlClient;
- 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;
- public partial class web_equipment_deal : System.Web.UI.Page
- {
- string form_id = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- this.MultiView1.Visible = true;
- form_id = Request.QueryString["form_id"];
- TextBox1.Text = form_id;
- TextBox2.Text = Request.QueryString["emp_name"];
- this.SetTable();
- }
- }
- public void SetTable()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select operator_id,is_check,is_agree,comment,check_date,step from oa_equipment_flow where form_id='" + form_id + "'", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["step"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom = new SqlCommand("select emp_name from oa_employee where id='"+dr["operator_id"]+"'",conn1);
- td.Text = sqlcom.ExecuteScalar().ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.Text = "審批";
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (dr["is_check"].ToString().Equals("N"))
- {
- td.Text = "未處理";
- }
- else
- {
- td.Text = "已處理";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (dr["is_check"].ToString().Equals("Y"))
- {
- if (dr["is_agree"].ToString().Equals("Y"))
- {
- td.Text = "已同意";
- }
- else
- {
- td.Text = "不同意";
- }
- }
- else
- {
- td.Text = "<br>";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (!dr["comment"].ToString().Equals(""))
- {
- td.Text = dr["comment"].ToString();
- }
- else
- {
- td.Text = "<br>";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- if (!dr["check_date"].ToString().Equals(""))
- {
- td.Text = dr["check_date"].ToString();
- }
- else
- {
- td.Text = "<br>";
- }
- tr.Cells.Add(td);
- FlowTable.Rows.Add(tr);
- }
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- string total_result = "跑流程中";
- string time = "";
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DateMgr mgr = new DateMgr();
- SqlCommand cmd = new SqlCommand("update oa_equipment_flow set is_check='Y',is_agree='" + RbAgree.SelectedValue.ToString() + "',comment='" + TxtComment.Text.Replace("n", "<br>") + "',check_date='" + mgr.getDateTime() + "'where form_id='" + Request.QueryString["form_id"] + "'and operator_id='" + Session["user_id"] + "'", conn);
- cmd.ExecuteNonQuery();
- cmd = new SqlCommand("select max(step) from oa_equipment_flow where form_id='" + Request.QueryString["form_id"] + "'", conn);
- int max_step = 1;
- max_step = Convert.ToInt32(cmd.ExecuteScalar());
- cmd = new SqlCommand("select step from oa_equipment_form where form_id='" + Request.QueryString["form_id"] + "'", conn);
- int step = Convert.ToInt32(cmd.ExecuteScalar());
- if (step == max_step)
- {
- if (RbAgree.SelectedValue.Equals("N"))
- {
- total_result = "不同意";
- }
- else
- {
- total_result = "同意";
- }
- time = mgr.getDateTime();
- }
- else
- {
- if (RbAgree.SelectedValue.Equals("N"))
- {
- total_result = "不同意";
- }
- time = mgr.getDateTime();
- }
- if (step == max_step)
- {
- cmd = new SqlCommand("update oa_equipment_form set step=step+1,total_result='" + total_result + "',finish_date='" + time + "'where form_id='" + Request.QueryString["form_id"] + "'", conn);
- cmd.ExecuteNonQuery();
- }
- else
- {
- cmd = new SqlCommand("update oa_equipment_form set step=step+1,total_result='" + total_result + "',finish_date=''where form_id='" + Request.QueryString["form_id"] + "'", conn);
- cmd.ExecuteNonQuery();
- }
- if ((step + 1) <= max_step)
- {
- if (RbAgree.SelectedValue.Equals("Y"))
- {
- ArrayList name1 = new ArrayList();
- ArrayList mail1 = new ArrayList();
- cmd = new SqlCommand("select f.email_work,f.emp_name from oa_employee as f,oa_equipment_flow as g where f.id=g.operator_id and form_id='" + Request.QueryString["form_id"] + "'and step='" + (step + 1) + "'", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- name1.Add(dr["emp_name"].ToString());
- mail1.Add(dr["email_work"].ToString());
- }
- }
- mail.mail_q(mail1[0], name1[0], TextBox2.Text, "設備申請單");
- dr.Close();
- }
- }
- conn.Close();
- Response.Redirect("deal_list.aspx");
- }
- 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 ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- protected void TextBox2_TextChanged(object sender, EventArgs e)
- {
- }
- protected void MultiView1_ActiveViewChanged(object sender, EventArgs e)
- {
- }
- }