add_flow.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:10k
源码类别:
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_add_flow : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../../", 2);
- this.SetEmpty();
- if (Request.QueryString["main_id"] != null)
- {
- this.SetTable(Request.QueryString["main_id"]);
- if (Request.QueryString["flow_id"] != null)
- {
- this.SetFlow(Request.QueryString["flow_id"]);
- }
- }
- }
- }
- protected void SetEmpty()
- {
- TxtName.Text = "";
- DdlType.SelectedIndex = 2;
- TxtNumber.Text = "";
- TxtOperator.Text = "";
- OperatorId.Value = "";
- TxtLargerNext.Text = "";
- TxtLargerThan.Text = "";
- TxtNumber.Text = "";
- }
- protected void SetFlow(string flow_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=" + flow_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if(dr.Read())
- {
- TxtName.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 SetTable(string main_id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select count(*) from OA_FLOW_DETAIL where main_id="+main_id, conn);
- int count = Convert.ToInt32(cmd.ExecuteScalar().ToString());
- if (count > 0)
- {
- TableHeaderRow th = new TableHeaderRow();
- th.BackColor = System.Drawing.Color.LightGray;
- TableHeaderCell thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = "流程名稱";
- th.Cells.Add(thc);
- thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = "類別";
- th.Cells.Add(thc);
- thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = "編號";
- th.Cells.Add(thc);
- thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = "辦理人";
- th.Cells.Add(thc);
- thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = "下一步編號";
- th.Cells.Add(thc);
- thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = "最大天數";
- th.Cells.Add(thc);
- thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = "超過最大天數跳轉編號";
- th.Cells.Add(thc);
- thc = new TableHeaderCell();
- thc.BorderWidth = Unit.Pixel(1);
- thc.HorizontalAlign = HorizontalAlign.Center;
- thc.Text = " ";
- th.Cells.Add(thc);
- TblFlowList.Rows.Add(th);
- cmd = new SqlCommand("select d.id, d.main_id, d.name, d.apply_type, e.emp_name, d.number, d.next_number, "+
- "d.larger_than, d.larger_next from OA_FLOW_DETAIL d inner join OA_EMPLOYEE e on "+
- "d.operator_id=e.id where main_id="+main_id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- TableRow tr = new TableRow();
- TableCell td = new TableCell();
- td.HorizontalAlign = HorizontalAlign.Center;
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["name"].ToString();
- tr.Cells.Add(td); td = new TableCell();
- td.HorizontalAlign = HorizontalAlign.Center;
- td.BorderWidth = Unit.Pixel(1);
- if (dr["apply_type"].ToString().Equals("1"))
- {
- td.Text = "會簽";
- }
- else
- {
- td.Text = "審批";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.HorizontalAlign = HorizontalAlign.Center;
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["number"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.HorizontalAlign = HorizontalAlign.Center;
- td.BorderWidth = Unit.Pixel(1);
- td.Text = dr["emp_name"].ToString();
- tr.Cells.Add(td);
- td = new TableCell();
- td.HorizontalAlign = HorizontalAlign.Center;
- td.BorderWidth = Unit.Pixel(1);
- if (!dr["next_number"].ToString().Equals(""))
- {
- td.Text = dr["next_number"].ToString();
- }
- else
- {
- td.Text = " ";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.HorizontalAlign = HorizontalAlign.Center;
- td.BorderWidth = Unit.Pixel(1);
- if (!dr["larger_than"].ToString().Equals("0"))
- {
- td.Text = dr["larger_than"].ToString();
- }
- else
- {
- td.Text = " ";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.HorizontalAlign = HorizontalAlign.Center;
- td.BorderWidth = Unit.Pixel(1);
- if (!dr["larger_next"].ToString().Equals(""))
- {
- td.Text = dr["larger_next"].ToString();
- }
- else
- {
- td.Text = " ";
- }
- tr.Cells.Add(td);
- td = new TableCell();
- td.BorderWidth = Unit.Pixel(1);
- td.HorizontalAlign = HorizontalAlign.Center;
- HyperLink lb = new HyperLink();
- lb.Text = "編輯";
- lb.NavigateUrl = "add_flow.aspx?main_id=" + dr["main_id"].ToString() + "&flow_id=" + dr["id"].ToString();
- td.Controls.Add(lb);
- tr.Cells.Add(td);
- TblFlowList.Rows.Add(tr);
- }
- dr.Close();
- }
- conn.Close();
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- int main_id = 0;
- if (Request.QueryString["main_id"] != null)
- {
- main_id = Convert.ToInt32(Request.QueryString["main_id"]);
- }
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- if (Request.QueryString["flow_id"] == null)
- {
- //新增
- int flow_id = 1;
- SqlCommand cmd = new SqlCommand("select max(id) from OA_FLOW_DETAIL", conn);
- try
- {
- flow_id = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
- }
- catch { }
- cmd = new SqlCommand("insert into OA_FLOW_DETAIL(id, main_id, name, apply_type, operator_id, " +
- "number, next_number, larger_than, larger_next) values (" + flow_id + "," + main_id + ",'" +
- TxtName.Text + "','" + DdlType.SelectedValue + "','" + OperatorId.Value + "','" + TxtNumber.Text + "','" +
- TxtNextNumber.Text + "','" + TxtLargerThan.Text + "','" + TxtLargerNext.Text + "')", conn);
- cmd.ExecuteNonQuery();
- }
- else
- {
- //編輯
- int flow_id = Convert.ToInt32(Request.QueryString["flow_id"]);
- SqlCommand cmd = new SqlCommand("update OA_FLOW_DETAIL set name='"+TxtName.Text+"', apply_type='"+
- DdlType.SelectedValue+"', operator_id='"+OperatorId.Value+"',number='"+TxtNumber.Text+
- "', next_number='"+TxtNextNumber.Text+"', larger_than='"+TxtLargerThan.Text+
- "', larger_next='"+TxtLargerNext.Text+"' where id="+flow_id, conn);
- cmd.ExecuteNonQuery();
- }
- conn.Close();
- Response.Redirect("add_flow.aspx?main_id="+main_id);
- }
- protected void BtnCancel_Click(object sender, EventArgs e)
- {
- if (Request.QueryString["main_id"] != null)
- {
- Response.Redirect("add_flow.aspx?main_id="+Request.QueryString["main_id"]);
- }
- }
- }