deal_d.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:12k
源码类别:
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_tw_deal_d : System.Web.UI.Page
- {
- string name = "";
- string d_start = "";
- string d_end = "";
- string hour = "";
- string type = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- // flg.Value = "0";
- LoginDAO.CheckLogin(Session, Response, "../../", 2);
- }
- if (Request.QueryString["f_id"] != null)
- {
- FlowList.DataKeyNames = new string[] { "id" };
- PnlApprovel.Visible = true;
- PnlDeal.Visible = true;
- PnlFlow.Visible = true;
- this.SetData(Request.QueryString["f_id"]);
- }
- }
- protected void SetData(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int form_id = 0;
- SqlCommand cmd = new SqlCommand("select form_id from OA_TW_APPROVEL_FORM_FLOW where id=" + id, conn);
- form_id = Convert.ToInt32(cmd.ExecuteScalar().ToString());
- cmd = new SqlCommand("select a.form_id, e.emp_name, e.emp_no, p.name position, " +
- "d.name department, e1.emp_name delegate, t.name off_type,t.id type, a.parenthesis, a.days, a.vacation_begin, " +
- "a.vacation_end,a.days, vp.name vacation_place, fp1.name flight_go_depart, fp2.name flight_go_arrive, " +
- "a.flight_go_time, a.flight_back_time, fp3.name flight_back_depart, fp4.name flight_back_arrive, " +
- "a.business_begin, a.business_end, a.reason, a.apply_date, b.name business_place " +
- "from OA_TW_APPROVEL_FORM a " +
- "inner join OA_EMPLOYEE e on a.emp_id=e.id " +
- "inner join OA_EMPLOYEE e1 on a.delegate_id=e1.id " +
- "inner join OA_DEPARTMENT d on e.department_id=d.id " +
- "inner join OA_EMPLOYEE_POSITION p on e.position=p.id " +
- "inner join OA_TW_OFF_TYPE t on a.off_type=t.id " +
- "inner join OA_VACATION_PLACE vp on a.vacation_place=vp.id " +
- "inner join OA_FLIGHT_PLACE fp1 on a.flight_go_depart=fp1.id " +
- "inner join OA_FLIGHT_PLACE fp2 on a.flight_go_arrive=fp2.id " +
- "inner join OA_FLIGHT_PLACE fp3 on a.flight_back_depart=fp3.id " +
- "inner join OA_FLIGHT_PLACE fp4 on a.flight_back_arrive=fp4.id " +
- "inner join OA_BUSINESS_PLACE b on a.business_place=b.id where a.id=" + form_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtFormNo.Text = dr["form_id"].ToString();
- TxtEmpName.Text = dr["emp_name"].ToString();
- TxtEmpNo.Text = dr["emp_no"].ToString();
- TxtPosition.Text = dr["position"].ToString();
- TxtDepartment.Text = dr["department"].ToString();
- TxtDelegate.Text = dr["delegate"].ToString();
- TxtOffType.Text = dr["off_type"].ToString();
- TxtParenthesis.Text = dr["parenthesis"].ToString();
- TxtDays.Text = dr["days"].ToString();
- TxtVacationBegin.Text = dr["vacation_begin"].ToString();
- TxtVacationEnd.Text = dr["vacation_end"].ToString();
- TxtVacationPlace.Text = dr["vacation_place"].ToString();
- TxtFlightGoDepart.Text = dr["flight_go_depart"].ToString();
- TxtFlightGoArrive.Text = dr["flight_go_arrive"].ToString();
- TxtFlightGoTime.Text = dr["flight_go_time"].ToString();
- TxtFlightBackTime.Text = dr["flight_back_time"].ToString();
- TxtFlightBackDepart.Text = dr["flight_back_depart"].ToString();
- TxtFlightBackArrive.Text = dr["flight_back_arrive"].ToString();
- TxtBusinessBegin.Text = dr["business_begin"].ToString();
- TxtBusinessEnd.Text = dr["business_end"].ToString();
- TxtReason.Text = dr["reason"].ToString();
- TxtApplyDate.Text = dr["apply_date"].ToString();
- TxtBusinessPlace.Text = dr["business_place"].ToString();
- name = dr["emp_name"].ToString();
- if (dr["type"].ToString().Equals("1"))
- {
- d_start = dr["business_begin"].ToString();
- d_end = dr["business_end"].ToString();
- hour = dr["days"].ToString();
- type = dr["off_type"].ToString();
- }
- else
- {
- d_start = dr["vacation_begin"].ToString();
- d_end = dr["vacation_end"].ToString();
- hour = dr["days"].ToString();
- type = dr["off_type"].ToString();
- }
- }
- dr.Close();
- conn.Close();
- }
- 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("select * from oa_employee");
- /*if (flg.Value.Equals("1"))
- {
- cmd = new SqlCommand("update OA_TW_APPROVEL_FORM_FLOW set is_check='Y', is_agree='" +
- RbAgree.SelectedValue + "', comment='" + TxtComment.Text.Replace("n", "<br>") +
- "', check_date='" + mgr.getDateTime() + "',operator_id='" + Session["user_id"] +
- "',apply_type='" + 3 + "' where id=" + Request.QueryString["f_id"], conn);
- }
- else
- {*/
- cmd = new SqlCommand("update OA_TW_APPROVEL_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_TW_APPROVEL_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_TW_APPROVEL_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_TW_APPROVEL_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 = "同意";
- //mail.mail_tw(name, d_start, d_end, hour, type);
- // Response.Write(d_start);
- }
- time = mgr.getDateTime();
- }
- else
- {
- if (RbAgree.SelectedValue.Equals("N"))
- {
- total_result = "不同意";
- time = mgr.getDateTime();
- }
- }
- cmd = new SqlCommand("update OA_TW_APPROVEL_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_TW_APPROVEL_FORM_flow as b on b.operator_id=a.id left join OA_TW_APPROVEL_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();
- // Response.Write("<script>window.href='deal_list.aspx'</script>");
- // Response.Write("<script>window.close();</script>");
- }
- catch (Exception ex)
- {
- Response.Write(ex.ToString());
- // tx.Rollback();
- }
- conn.Close();
- // try
- // {
- // Response.Write("<script>mainFrame5.location.href='deal_list.aspx'</script>");
- Response.Write("<script>window.close();</script>");
- // }
- // catch
- // {
- // Response.Write("wrong");
- // }
- }
- protected void FlowList_RowCreated(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select apply_type, is_check, is_agree, comment from " +
- "OA_TW_APPROVEL_FORM_FLOW where id=" + FlowList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- Label label = (Label)e.Row.FindControl("LblApplyType");
- if (dr["apply_type"].ToString().Equals("1"))
- {
- label.Text = "會簽";
- }
- else if (dr["apply_type"].ToString().Equals("2"))
- {
- label.Text = "審批";
- }
- else if (dr["apply_type"].ToString().Equals("3"))
- {
- label.Text = "審批(代理)";
- }
- label = (Label)e.Row.FindControl("LblIsCheck");
- if (dr["is_check"].ToString().Equals("N"))
- {
- label.Text = "未處理";
- }
- else
- {
- label.Text = "已處理";
- label = (Label)e.Row.FindControl("LblIsAgree");
- if (dr["is_agree"].ToString().Equals("Y"))
- {
- label.Text = "已同意";
- }
- else
- {
- label.Text = "不同意";
- }
- }
- label = (Label)e.Row.FindControl("LblComment");
- label.Text = dr["comment"].ToString();
- }
- 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 = "不同意";
- }
- }
- }
- }