deal_list.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:16k
源码类别:
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_approvel_tw_deal_list : System.Web.UI.Page
- {
- ArrayList b_d_people = new ArrayList();
- 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);
- this.SetTable();
- }
- 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 SetTable()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- ArrayList d_people = new ArrayList();
- string user_id="0";
- if (Session["user_id"] != null)
- {
- user_id = Session["user_id"].ToString();
- }
- /* //判断是否为代理人
- SqlCommand cmd = new SqlCommand("select d_people,b_d_people from oa_delegate where s_date<=convert(varchar, getdate(), 120)"+
- " and e_date>=convert(varchar, getdate(), 120) and d_people="+Session["user_id"],conn);
- SqlDataReader dr1 = cmd.ExecuteReader();
- while (dr1.Read()) {
- d_people.Add(dr1["d_people"].ToString());
- b_d_people.Add(dr1["b_d_people"].ToString());
- }
- //如果有代理,显示被代理人的表单给代理人看
- if (dr1.HasRows) {
- for (int i = 0; i < b_d_people.Count; i++)
- {
- flg.Value = "1";
- cmd = new SqlCommand("SELECT f.id, f.step f_step, a.step a_step, t.name off_type, e.emp_name, a.apply_date " +
- "FROM dbo.OA_TW_APPROVEL_FORM_FLOW AS f INNER JOIN dbo.OA_TW_APPROVEL_FORM AS a ON f.form_id = a.id " +
- "INNER JOIN dbo.OA_EMPLOYEE AS e ON a.emp_id = e.id inner join OA_TW_OFF_TYPE t on a.off_type=t.id " +
- "WHERE (f.operator_id = " + user_id + ") AND (f.is_check = 'N') or (f.operator_id = " + b_d_people[i] + ") AND (f.is_check = 'N')" +
- " order by a.apply_date desc", conn);
- }
- }
- //否则只显示自己的表单
- else
- {*/
- SqlCommand cmd = new SqlCommand("SELECT f.id, f.step f_step,f.form_id, a.step a_step, t.name off_type, e.emp_name, a.apply_date " +
- "FROM dbo.OA_TW_APPROVEL_FORM_FLOW AS f INNER JOIN dbo.OA_TW_APPROVEL_FORM AS a ON f.form_id = a.id " +
- "INNER JOIN dbo.OA_EMPLOYEE AS e ON a.emp_id = e.id inner join OA_TW_OFF_TYPE t on a.off_type=t.id " +
- "WHERE (f.operator_id = " + user_id + ") AND (f.is_check = 'N') and state=1 order by a.apply_date desc", conn);
- // }
- // dr1.Close();
- 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);
- 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.Target = "blank";
- // hl.Attributes.Add("onclick", Response.Write(+"<script>window.open('deal_d.aspx?f_id=" + dr["id"].ToString() + "&f_id1=" + dr["form_id"].ToString() + "')</script>"+););
- hl.NavigateUrl = "javascript:void(window.open('deal_d.aspx?f_id=" + dr["id"].ToString() + "&f_id1=" + dr["form_id"].ToString()+"'))";
- td.Controls.Add(hl);
- tr.Cells.Add(td);
- TblFlow.Rows.Add(tr);
- }
- }
- dr.Close();
- conn.Close();
- }
- 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();
- // 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_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();
- }
- catch (Exception ex)
- {
- Response.Write(ex.ToString());
- // tx.Rollback();
- }
- conn.Close();
- // Response.Write("<script>window.close();</script>");
- }
- 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 = "不同意";
- }
- }
- }
- }