deal_list.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:22k
源码类别:
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_approvel_ch_deal_list : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../../", 2);
- this.SetMainTable();
- if (Request.QueryString["f_id"] != null)
- {
- PnlApprovel.Visible = true;
- PnlDeal.Visible = true;
- this.SetValue(Request.QueryString["f_id"]);
- }
- if (Request.QueryString["o_id"] != null)
- {
- PnlOff.Visible = true;
- PnlDeal.Visible = true;
- this.SetOffValue(Request.QueryString["o_id"]);
- }
- }
- }
- protected void SetMainTable()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- string user_id = "0";
- if (Session["user_id"] != null)
- {
- user_id = Session["user_id"].ToString();
- }
- ArrayList ids = new ArrayList();
- ArrayList form_ids = new ArrayList();
- ArrayList is_businesses = new ArrayList();
- ArrayList f_steps = new ArrayList();
- SqlCommand cmd = new SqlCommand("SELECT f.id, f.form_id, f.is_business, f.step FROM dbo.OA_CH_APPROVEL_FORM_FLOW AS f " +
- " left join oa_ch_business_form as b on f.form_id=b.id WHERE (f.operator_id = " + user_id + ") AND (f.is_check = 'N') and state=1", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- ids.Add(dr["id"].ToString());
- form_ids.Add(dr["form_id"].ToString());
- is_businesses.Add(dr["is_business"].ToString());
- f_steps.Add(dr["step"].ToString());
- }
- dr.Close();
- for (int i = ids.Count - 1; i >= 0; i--)
- {
- int f_step = Convert.ToInt32(f_steps[i]);
- if (is_businesses[i].Equals("Y"))
- {
- cmd = new SqlCommand("select e.emp_name, b.apply_date, b.step from OA_CH_BUSINESS_FORM b inner join " +
- "OA_EMPLOYEE e on b.emp_id=e.id where b.id=" + form_ids[i], conn);
- dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- int b_step = Convert.ToInt32(dr["step"].ToString()) + 1;
- if (b_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);
- td.Text = dr["emp_name"].ToString() + "的出差單";
- 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=" + ids[i].ToString();
- td.Controls.Add(hl);
- tr.Cells.Add(td);
- TblFlow.Rows.Add(tr);
- }
- }
- dr.Close();
- }
- else
- {
- cmd = new SqlCommand("select e.emp_name, o.apply_date, t.name off_type, o.step from OA_CH_OFF_FORM o "+
- "inner join OA_EMPLOYEE e on o.emp_id=e.id inner join OA_CH_OFF_TYPE t on o.off_type=t.id "+
- "where o.id=" + form_ids[i] + " and state=1", conn);
- dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- int b_step = Convert.ToInt32(dr["step"].ToString()) + 1;
- if (f_step == b_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);
- td.Text = dr["emp_name"].ToString() + "的" + dr["off_type"].ToString() + "單";
- 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?o_id=" + ids[i].ToString();
- td.Controls.Add(hl);
- tr.Cells.Add(td);
- TblFlow.Rows.Add(tr);
- }
- }
- dr.Close();
- }
- }
- conn.Close();
- }
- protected void SetValue(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int form_id = 0;
- string is_business = "";
- SqlCommand cmd = new SqlCommand("select form_id, is_business from OA_CH_APPROVEL_FORM_FLOW where id="+id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- form_id = Convert.ToInt32(dr["form_id"].ToString());
- is_business = dr["is_business"].ToString();
- }
- dr.Close();
- FormId.Value = form_id.ToString();
- if (is_business.Equals("Y"))
- {
- PnlApprovel.Visible = true;
- cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, a.apply_date," +
- "d.name department, a.days, a.begin_time, a.end_time, f1.name depart_place, f2.name arrive_place, " +
- "a.depart_time, a.arrive_time from OA_CH_BUSINESS_FORM a inner join OA_EMPLOYEE e on a.emp_id=e.id " +
- "inner join OA_DEPARTMENT d on a.department_id=d.id inner join OA_EMPLOYEE_POSITION p on " +
- "e.position=p.id inner join OA_FLIGHT_PLACE f1 on a.depart_place=f1.id inner join " +
- "OA_FLIGHT_PLACE f2 on a.arrive_place=f2.id where a.id=" + form_id, conn);
- dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtFormId.Text = dr["form_id"].ToString();
- TxtEmpName.Text = dr["emp_name"].ToString();
- TxtEmpNo.Text = dr["emp_no"].ToString();
- TxtPosition.Text = dr["position"].ToString();
- TxtApplyDate.Text = dr["apply_date"].ToString();
- TxtDepartment.Text = dr["department"].ToString();
- TxtDays.Text = dr["days"].ToString();
- TxtBeginTime.Text = dr["begin_time"].ToString();
- TxtEndTime.Text = dr["end_time"].ToString();
- TxtDepartPlace.Text = dr["depart_place"].ToString();
- TxtArrivePlace.Text = dr["arrive_place"].ToString();
- TxtDepartTime.Text = dr["depart_time"].ToString();
- TxtArriveTime.Text = dr["arrive_time"].ToString();
- }
- dr.Close();
- }
- conn.Close();
- this.SetTable(form_id);
- }
- protected void SetOffValue(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int form_id = 0;
- SqlCommand cmd = new SqlCommand("select form_id from OA_CH_APPROVEL_FORM_FLOW where id="+id, conn);
- form_id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
- cmd = new SqlCommand("select o.form_id, e.emp_no, e.emp_name, d.name department, " +
- "e.emp_name delegate, e.position position, " +
- "t.name off_type, o.begin_time, o.end_time, o.hours, o.apply_date, o.parenthesis, " +
- "o.reason from OA_CH_OFF_FORM o inner join OA_EMPLOYEE e on o.emp_id=e.id inner join " +
- "OA_DEPARTMENT d on o.department_id=d.id inner join OA_CH_OFF_TYPE t on " +
- "o.off_type=t.id where o.id=" + form_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtOffFormId.Text = dr["form_id"].ToString();
- TxtOffEmpName.Text = dr["emp_no"].ToString() + dr["emp_name"].ToString();
- TxtOffDepartment.Text = dr["department"].ToString();
- TxtDelegate.Text = dr["delegate"].ToString();
- TxtOffPosition.Text = dr["position"].ToString();
- TxtOffType2.Text = dr["off_type"].ToString();
- TxtOffBeginTime.Text = dr["begin_time"].ToString();
- TxtOffEndTime.Text = dr["end_time"].ToString();
- TxtHours.Text = dr["hours"].ToString();
- TxtOffApplyDate.Text = dr["apply_date"].ToString();
- TxtParenthesis.Text = dr["parenthesis"].ToString();
- TxtReason.Text = dr["reason"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- protected void SetTable(int form_id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int flag = 0;
- SqlCommand cmd = new SqlCommand("select number, company, subject, linkman, tel, place, visa_begin, visa_end, " +
- "flight_go_begin, flight_back_end, is_aboard, remark from OA_CH_BUSINESS_DETAIL where form_id=" + form_id +
- " order by number", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- flag = 1;
- //動態創建表格行
- TableRow tr1 = new TableRow();
- TableCell td1 = new TableCell();
- td1.BorderWidth = Unit.Pixel(1);
- Label label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["number"].ToString();
- td1.Controls.Add(label);
- tr1.Cells.Add(td1);
- TableCell td2 = new TableCell();
- td2.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["company"].ToString();
- td2.Controls.Add(label);
- tr1.Cells.Add(td2);
- TableCell td3 = new TableCell();
- td3.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["subject"].ToString();
- td3.Controls.Add(label);
- tr1.Cells.Add(td3);
- TableCell td4 = new TableCell();
- td4.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["linkman"].ToString();
- td4.Controls.Add(label);
- tr1.Cells.Add(td4);
- TableCell td5 = new TableCell();
- td5.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["tel"].ToString();
- td5.Controls.Add(label);
- tr1.Cells.Add(td5);
- TableCell td6 = new TableCell();
- td6.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["place"].ToString();
- td6.Controls.Add(label);
- tr1.Cells.Add(td6);
- TableCell td7 = new TableCell();
- td7.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["visa_begin"].ToString();
- td7.Controls.Add(label);
- tr1.Cells.Add(td7);
- TableCell td8 = new TableCell();
- td8.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["visa_end"].ToString();
- td8.Controls.Add(label);
- tr1.Cells.Add(td8);
- TableCell td9 = new TableCell();
- td9.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["flight_go_begin"].ToString();
- td9.Controls.Add(label);
- tr1.Cells.Add(td9);
- TableCell td10 = new TableCell();
- td10.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["flight_back_end"].ToString();
- td10.Controls.Add(label);
- tr1.Cells.Add(td10);
- TableCell td11 = new TableCell();
- td11.BorderWidth = Unit.Pixel(1);
- CheckBox chk = new CheckBox();
- chk.Text = "國外";
- chk.Enabled = false;
- if (dr["is_aboard"].ToString().Equals("Y"))
- {
- chk.Checked = true;
- }
- else
- {
- chk.Checked = false;
- }
- td11.Controls.Add(chk);
- tr1.Cells.Add(td11);
- TableCell td12 = new TableCell();
- td12.BorderWidth = Unit.Pixel(1);
- label = new Label();
- label.BorderStyle = BorderStyle.None;
- label.Text = dr["remark"].ToString();
- td12.Controls.Add(label);
- tr1.Cells.Add(td12);
- TblDetail.Rows.Add(tr1);
- }
- dr.Close();
- conn.Close();
- if (flag == 0)
- {
- TblDetail.Visible = false;
- }
- }
- 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 = "不同意";
- }
- }
- this.SetTable(Convert.ToInt32(FormId.Value));
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlTransaction tx = conn.BeginTransaction();
- try
- {
- int flow_id = 0;
- if (Request.QueryString["f_id"] != null)
- {
- flow_id = Convert.ToInt32(Request.QueryString["f_id"]);
- }
- else if (Request.QueryString["o_id"] != null)
- {
- flow_id = Convert.ToInt32(Request.QueryString["o_id"]);
- }
- string is_business = "";
- DateMgr mgr = new DateMgr();
- SqlCommand cmd = new SqlCommand("update OA_CH_APPROVEL_FORM_FLOW set is_check='Y', is_agree='" +
- RbAgree.SelectedValue + "', comment='" + TxtComment.Text.Replace("n", "<br>") + "', check_date='" + mgr.getDateTime() +
- "' where id=" + flow_id, conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- cmd = new SqlCommand("select form_id, is_business from OA_CH_APPROVEL_FORM_FLOW where id=" + flow_id, conn);
- cmd.Transaction = tx;
- SqlDataReader dr = cmd.ExecuteReader();
- int form_id = 0;
- if (dr.Read())
- {
- form_id = Convert.ToInt32(dr["form_id"].ToString());
- is_business = dr["is_business"].ToString();
- }
- dr.Close();
- if (is_business.Equals("Y"))
- {
- cmd = new SqlCommand("select max(step) from OA_CH_APPROVEL_FORM_FLOW where form_id=" + form_id + " and is_business='Y'", conn);
- cmd.Transaction = tx;
- int max_step = Convert.ToInt32(cmd.ExecuteScalar());
- cmd = new SqlCommand("select step from OA_CH_BUSINESS_FORM 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_CH_BUSINESS_FORM set step=step+1, total_result='" +
- total_result + "', finish_date='" + time + "' where id=" + form_id, conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- 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_CH_APPROVEL_FORM_FLOW as b on b.operator_id=a.id left join OA_CH_BUSINESS_FORM 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.mail_q(mail1[0], name1[0], TxtEmpName.Text, "中幹出差申請單");
- } dr3.Close();
- //
- }
- else
- {
- cmd = new SqlCommand("select max(step) from OA_CH_APPROVEL_FORM_FLOW where form_id=" + form_id + " and is_business='N'", conn);
- cmd.Transaction = tx;
- int max_step = Convert.ToInt32(cmd.ExecuteScalar());
- cmd = new SqlCommand("select step from OA_CH_OFF_FORM 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_CH_OFF_FORM set step=step+1, total_result='" +
- total_result + "', finish_date='" + time + "' where id=" + form_id, conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- 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_CH_APPROVEL_FORM_FLOW as b on b.operator_id=a.id left join OA_CH_OFF_FORM 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.mail_q(mail1[0], name1[0], TxtEmpName.Text, "中幹請假單");
- } dr3.Close();
- //
- }
- tx.Commit();
- }
- catch (Exception ex)
- {
- Response.Write(ex.ToString());
- tx.Rollback();
- }
- conn.Close();
- try
- {
- Response.Redirect("finish_list.aspx");
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- }
- }