flow_show.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;
- public partial class web_approvel_flow_flow_show : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- if (Request.QueryString["f_id"] != null)
- {
- this.SetValue(Request.QueryString["f_id"]);
- }
- if (Request.QueryString["d_id"] != null)
- {
- this.SetDetail(Request.QueryString["d_id"]);
- this.PnlDetail.Visible = true;
- }
- FlowList.DataKeyNames = new string[] { "id" };
- }
- }
- protected void SetValue(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select name, description, type from OA_FLOW_MAIN where id="+id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtName.Text = dr["name"].ToString();
- TxtDescription.Text = dr["description"].ToString();
- RbType.SelectedValue = dr["type"].ToString();
- }
- dr.Close();
- cmd = new SqlCommand("select f.department_id, d.name from OA_FLOW_DEPARTMENT f "+
- "inner join OA_DEPARTMENT d on f.department_id=d.id where f.main_id="+id, conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- DepartmentIds.Value = DepartmentIds.Value + dr["department_id"].ToString() + ";";
- LblDepartments.Text = LblDepartments.Text + dr["name"].ToString() + ";";
- }
- dr.Close();
- DepartmentIds.Value = DepartmentIds.Value.Substring(0, DepartmentIds.Value.Length - 1);
- conn.Close();
- }
- protected void SetDetail(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select f.name, f.apply_type, f.operator_id, e.emp_name, " +
- "f.number, f.next_number, f.larger_than, f.larger_next from OA_FLOW_DETAIL f " +
- "inner join OA_EMPLOYEE e on f.operator_id=e.id where f.id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- TxtDetailName.Text = dr["name"].ToString();
- DdlType.SelectedValue = dr["apply_type"].ToString();
- OperatorId.Value = dr["operator_id"].ToString();
- TxtOperator.Text = dr["emp_name"].ToString();
- TxtNumber.Text = dr["number"].ToString();
- TxtNextNumber.Text = dr["next_number"].ToString();
- if (dr["larger_than"].ToString().Equals("0"))
- {
- TxtLargerThan.Text = "";
- }
- else
- {
- TxtLargerThan.Text = dr["larger_than"].ToString();
- }
- TxtLargerNext.Text = dr["larger_next"].ToString();
- }
- dr.Close();
- conn.Close();
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- if (Request.QueryString["f_id"] != null)
- {
- string id = Request.QueryString["f_id"];
- string upd_user = "";
- if (Session["user"] != null)
- {
- upd_user = ((User)Session["user"]).Emp_name;
- }
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlTransaction tx = conn.BeginTransaction();
- try
- {
- SqlCommand cmd = new SqlCommand("update OA_FLOW_MAIN set name='"+TxtName.Text+"', "+
- "description='"+TxtDescription.Text+"', type='"+RbType.SelectedValue+"' where id="+id, conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- cmd = new SqlCommand("delete from OA_FLOW_DEPARTMENT where main_id="+id, conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- string[] ids = DepartmentIds.Value.Split(new char[] { ',' });
- int department_id = 1;
- cmd = new SqlCommand("select max(id) from OA_FLOW_DEPARTMENT", conn);
- cmd.Transaction = tx;
- try
- {
- department_id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
- }
- catch { }
- for (int i = 0; i < ids.Length; i++)
- {
- cmd = new SqlCommand("insert into OA_FLOW_DEPARTMENT(id, main_id, department_id)" +
- "values(" + department_id + ",'" + id + "','" + ids[i] + "')", conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- department_id++;
- }
- tx.Commit();
- LblDepartments.Text = "";
- DepartmentIds.Value = "";
- cmd = new SqlCommand("select f.department_id, d.name from OA_FLOW_DEPARTMENT f " +
- "inner join OA_DEPARTMENT d on f.department_id=d.id where f.main_id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- DepartmentIds.Value = DepartmentIds.Value + dr["department_id"].ToString() + ";";
- LblDepartments.Text = LblDepartments.Text + dr["name"].ToString() + ";";
- }
- dr.Close();
- DepartmentIds.Value = DepartmentIds.Value.Substring(0, DepartmentIds.Value.Length - 1);
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- tx.Rollback();
- }
- conn.Close();
- }
- BtnOk.Visible = false;
- BtnEdit.Visible = true;
- BtnSelect.Visible = false;
- TxtDescription.Enabled = false;
- TxtName.Enabled = false;
- RbType.Enabled = false;
- }
- protected void BtnEdit_Click(object sender, EventArgs e)
- {
- BtnOk.Visible = true;
- BtnEdit.Visible = false;
- BtnSelect.Visible = true;
- TxtDescription.Enabled = true;
- TxtName.Enabled = true;
- RbType.Enabled = true;
- }
- protected void FlowList_RowCreated(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- LinkButton btnEdit = (LinkButton)e.Row.FindControl("BtnEdit");
- btnEdit.CommandArgument = FlowList.DataKeys[e.Row.RowIndex].Value.ToString();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select apply_type, larger_than from OA_FLOW_DETAIL where id=" + FlowList.DataKeys[e.Row.RowIndex].Value.ToString(), conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- Label label = (Label)e.Row.FindControl("LblApplyType");
- if (dr["apply_type"].ToString().Equals("1"))
- {
- label.Text = "會簽";
- }
- else
- {
- label.Text = "審批";
- }
- }
- dr.Close();
- conn.Close();
- }
- }
- protected void FlowList_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- }
- protected void FlowList_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- if (e.CommandName.Equals("EditData"))
- {
- string id = e.CommandArgument.ToString();
- try
- {
- if (Request.QueryString["f_id"] != null)
- {
- Response.Redirect("flow_show.aspx?f_id="+Request.QueryString["f_id"]+"&d_id="+id);
- }
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- }
- }
- protected void BtnDetailOk_Click(object sender, EventArgs e)
- {
- if (Request.QueryString["d_id"] != null)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("update OA_FLOW_DETAIL set apply_type='"+DdlType.SelectedValue+
- "', operator_id='"+OperatorId.Value+"', number='"+TxtNumber.Text+"', next_number='"+
- TxtNextNumber.Text+"', larger_than='"+TxtLargerThan.Text+"', larger_next='"+TxtLargerNext.Text+
- "', name='"+TxtDetailName.Text+"' where id="+Request.QueryString["d_id"], conn);
- cmd.ExecuteNonQuery();
- conn.Close();
- FlowList.DataBind();
- this.SetEmpty();
- PnlDetail.Visible = false;
- }
- }
- protected void BtnCancel_Click(object sender, EventArgs e)
- {
- this.SetEmpty();
- PnlDetail.Visible = false;
- }
- protected void SetEmpty()
- {
- TxtDetailName.Text = "";
- DdlType.SelectedIndex = 2;
- TxtNumber.Text = "";
- TxtOperator.Text = "";
- OperatorId.Value = "";
- TxtLargerNext.Text = "";
- TxtLargerThan.Text = "";
- TxtNumber.Text = "";
- }
- }