WorkFlowTaskEdit.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:15k
- 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 com.etong.DAL.FC;
- using com.etong.BusinessRule.Zwf;
- public partial class Workflow_WorkFlowTaskEdit : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- int iWFID;
- WFValue.Value = Request.QueryString["StrN"];
- try
- {
- iWFID = Convert.ToInt32(WFValue.Value);
- }
- catch
- {
- iWFID = -1;
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
- }
- EtongFlyChouWFPrj EFlyPrj = new EtongFlyChouWFPrj();
- DataView dv = new DataView();
- dv = EFlyPrj.GetAllOpRole();
- DTaskRoleName.DataTextField = "OpName";
- DTaskRoleName.DataValueField = "OpID";
- DTaskRoleName.DataSource = dv;
- DTaskRoleName.DataBind();
- EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
- dv = EFlyWF.GetWFStaticPage();
- DTaskPage.DataTextField = "PageName";
- DTaskPage.DataValueField = "StaticPageID";
- DTaskPage.DataSource = dv;
- DTaskPage.DataBind();
- EtongFlyChouCode EFlyCode = new EtongFlyChouCode();
- dv = EFlyCode.BlockCodeAll("tb_BlockSort");
- DTaskBlock.DataTextField = "BlockName";
- DTaskBlock.DataValueField = "BlockID";
- DTaskBlock.DataSource = dv;
- DTaskBlock.DataBind();
- dv = EFlyCode.BlockCodeAll("tb_TaskSort");
- DTaskSort.DataTextField = "TaskSName";
- DTaskSort.DataValueField = "TaskSID";
- DTaskSort.DataSource = dv;
- DTaskSort.DataBind();
- if (EFlyWF.BlStartTask(iWFID, 0, "StartEnd") == true)
- {
- DTaskSort.SelectedIndex = 1;
- }
- dv = EFlyCode.BlockCodeAll("tb_Shunt");
- DTaskShunt.DataTextField = "ShuntName";
- DTaskShunt.DataValueField = "ShuntID";
- DTaskShunt.DataSource = dv;
- DTaskShunt.DataBind();
- dv = EFlyCode.BlockCodeAll("tb_ModeSort");
- DTaskMode.DataTextField = "ModeName";
- DTaskMode.DataValueField = "ModeID";
- DTaskMode.DataSource = dv;
- DTaskMode.DataBind();
- if (EFlyWF.BlTask(iWFID, "WorkFlowID", "tb_WF_Activity") == false)
- {
- DTaskMode.Items.FindByValue(DTaskMode.SelectedValue).Selected = false;
- DTaskMode.Items.FindByText("抢先式").Selected = true;
- DTaskMode.Enabled = false;
- DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
- DTaskShunt.Items.FindByText("不分流").Selected = true;
- DTaskShunt.Enabled = false;
- DTaskSort.Items.FindByValue(DTaskSort.SelectedValue).Selected = false;
- DTaskSort.Items.FindByText("起始任务").Selected = true;
- DTaskSort.Enabled = false;
- }
- HAct.Value = "-1";
- if (Request.QueryString["StrM"] == "M")
- {
- int iActID;
- try
- {
- iActID = Convert.ToInt32(Request.QueryString["StrA"]);
- }
- catch
- {
- iActID = -1;
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
- return;
- }
- GetM(iWFID,iActID);
- GetEnable(iWFID, iActID);
- GetDocName(iActID);
- HAct.Value = iActID.ToString();
- }
- }
- }
- protected void GetDocName(int iActID)
- {
- //EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
- //DataView dv = EFlyWF.GetActFName(iActID);
- //string sDoc;
- //int starti = 0;
- //for (int i = 0; i < dv.Table.Rows.Count; i++)
- //{
- // ListItem Lst = new ListItem();
- // sDoc = dv.Table.Rows[i][0].ToString();
- // starti = sDoc.Length - (sDoc.Split('\').GetValue(sDoc.Split('\').Length - 1)).ToString().Length;
- // Lst.Value = sDoc;
- // Lst.Text = sDoc.Substring(starti, sDoc.Length - starti);
- // LstDoc.Items.Add(Lst);
- //}
- //新
- EtongWord EWord = new EtongWord();
- EWord.ActID = iActID;
- DataView dv = new DataView();
- dv = EWord.GetFNameByActID();
- for (int k = 0; k < dv.Table.Rows.Count; k++)
- {
- ListItem lstk = new ListItem();
- lstk.Text = dv.Table.Rows[k][1].ToString();
- lstk.Value = dv.Table.Rows[k][0].ToString();
- LstDoc.Items.Add(lstk);
- }
- }
- protected void GetM(int iWFID, int iActID)
- {
- EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
- DataView dv = new DataView();
- dv = EFlyWF.GetActivityEdit(iWFID, iActID);
- if (dv.Table.Rows.Count < 1)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
- return;
- }
- TxtTaskName.Text = dv.Table.Rows[0][4].ToString();
- TTaskUnit.Text = dv.Table.Rows[0][1].ToString();
- DTaskBlock.Items.FindByValue(DTaskBlock.SelectedValue).Selected = false;
- DTaskBlock.Items.FindByValue(dv.Table.Rows[0][10].ToString()).Selected = true;
- DTaskMode.Items.FindByValue(DTaskMode.SelectedValue).Selected = false;
- DTaskMode.Items.FindByValue(dv.Table.Rows[0][12].ToString()).Selected = true;
- DTaskPage.Items.FindByValue(DTaskPage.SelectedValue).Selected = false;
- DTaskPage.Items.FindByValue(dv.Table.Rows[0][6].ToString()).Selected = true;
- DTaskRoleName.Items.FindByValue(DTaskRoleName.SelectedValue).Selected = false;
- try
- {
- DTaskRoleName.Items.FindByValue(dv.Table.Rows[0][15].ToString()).Selected = true;
- }
- catch
- {
- }
- //else
- //{
- // DTaskRoleName.SelectedItem.Text = "---请选择---";
- // DTaskRoleName.SelectedValue = "---请选择---";
- //}
- DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
- DTaskShunt.Items.FindByValue(dv.Table.Rows[0][11].ToString()).Selected = true;
- DTaskSort.Items.FindByValue(DTaskSort.SelectedValue).Selected = false;
- DTaskSort.Items.FindByValue(dv.Table.Rows[0][9].ToString()).Selected = true;
-
- for (int i = 0; i < dv.Table.Rows.Count; i++)
- {
- ListItem Lst = new ListItem();
- Lst.Value = dv.Table.Rows[i][14].ToString();
- Lst.Text = EFlyWF.GetActName(Convert.ToInt32(dv.Table.Rows[i][14].ToString()));
- lbParentTask.Items.Add(Lst);
- }
- //DTaskBlock.SelectedIndex=Convert.ToInt32(dv.Table.Rows[0][10].ToString());
- //DTaskMode.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][12].ToString());
- //DTaskPage.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][6].ToString());
- //DTaskRoleName.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][15].ToString());
- //DTaskShunt.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][11].ToString());
- //DTaskSort.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][9].ToString());
- }
- protected void GetEnable(int iWFID,int iActID)
- {
- EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
- if (EFlyWF.BlTask(iActID, "ParentActID", "tb_Colony_User") == true)
- {
- DTaskMode.Enabled = false;
- DTaskShunt.Enabled = false;
- ImgSelect.Enabled = false;
- }
- else
- {
- ImgSelect.Enabled = false;
- DTaskMode.Enabled = false;
- DTaskShunt.Enabled = false;
- }
- }
- protected void DTaskSort_SelectedIndexChanged(object sender, EventArgs e)
- {
-
- if (this.DTaskSort.SelectedValue == "0")
- {
- int iWFID;
- try
- {
- iWFID = Convert.ToInt32(WFValue.Value);
- }
- catch
- {
- iWFID =-1;
- }
- EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
- if (EFlyWF.BlStartTask(iWFID, 0, "StartEnd") == true)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流已存在起始任务,请选择其他任务!');", true);
- //DTaskSort.SelectedIndex = 1;
- DTaskSort.Items.FindByValue(DTaskSort.SelectedValue).Selected = false;
- DTaskSort.Items.FindByValue("1").Selected = true;
- }
- }
- }
- protected void DTaskShunt_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (DTaskMode.SelectedValue == "0")
- {
- if (DTaskShunt.SelectedValue != "0")
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『抢先式』,分流方式只能为『不分流』!');", true);
- //DTaskShunt.SelectedIndex = 0;
- DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
- DTaskShunt.Items.FindByValue("0").Selected = true;
- }
- }
- else
- {
- if (DTaskShunt.SelectedValue == "0")
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『并行式』,分流方式不能为『不分流』!');", true);
- //DTaskShunt.SelectedIndex = 1;
- DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
- DTaskShunt.Items.FindByValue("1").Selected = true;
- }
- }
- }
- protected void DTaskMode_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (DTaskMode.SelectedValue == "0")
- {
- if (DTaskShunt.SelectedValue != "0")
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『抢先式』,分流方式只能为『不分流』!');", true);
- //DTaskShunt.SelectedIndex = 0;
- DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
- DTaskShunt.Items.FindByValue("0").Selected = true;
- }
- }
- else
- {
- if (DTaskShunt.SelectedValue == "0")
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『并行式』,分流方式不能为『不分流』!');", true);
- //DTaskShunt.SelectedIndex = 1;
- DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
- DTaskShunt.Items.FindByValue("1").Selected = true;
- }
- }
- }
- protected void ImgOK_Click(object sender, ImageClickEventArgs e)
- {
- string sUnit, sActName;
- int iWFID, iPage, iStart, iBlock, iShunt, iMode, iRole;
- //if (DTaskRoleName.SelectedValue == "---请选择---")
- //{
- // this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:请选择使用角色!');", true);
- // return;
- //}
- try
- {
- iWFID = Convert.ToInt32(WFValue.Value);
- }
- catch
- {
- iWFID = -1;
- }
- sUnit = TTaskUnit.Text;
- sActName = TxtTaskName.Text;
- try
- {
- iPage = Convert.ToInt32(DTaskPage.SelectedValue);
- }
- catch
- {
- iPage = -1;
- }
- try
- {
- iStart = Convert.ToInt32(DTaskSort.SelectedValue);
- }
- catch
- {
- iStart = -1;
- }
- try
- {
- iBlock = Convert.ToInt32(DTaskBlock.SelectedValue);
- }
- catch
- {
- iBlock = -1;
- }
- try
- {
- iShunt = Convert.ToInt32(DTaskShunt.SelectedValue);
- }
- catch
- {
- iShunt = -1;
- }
- try
- {
- iMode = Convert.ToInt32(DTaskMode.SelectedValue);
- }
- catch
- {
- iMode = -1;
- }
- try
- {
- iRole = Convert.ToInt32(DTaskRoleName.SelectedValue);
- }
- catch
- {
- iRole = -1;
- }
- string sParent;
- sParent = ListValue.Value;
- int i = sParent.Split('|').Length;
- int[] iParent = new int[i];
- for (int j = 0; j < i; j++)
- {
- iParent[j] = Convert.ToInt32(sParent.Split('|').GetValue(j).ToString());
- }
- sParent="";
- sParent = ListDoc.Value;
- int k = sParent.Split('|').Length;
- string[] sDoc = new string[k];
- for (int m = 0; m < k; m++)
- {
- sDoc[m] = Convert.ToString(sParent.Split('|').GetValue(m).ToString());
- }
- EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
- if (Request.QueryString["StrM"] == "M")
- {
- int iActID;
- try
- {
- iActID = Convert.ToInt32(Request.QueryString["StrA"]);
- }
- catch
- {
- iActID = -1;
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
- return;
- }
- if (EFlyWF.UpWFAct1(iActID, sUnit, sActName, iWFID, iPage, iStart, iBlock, iShunt, iMode, iRole, iParent, 1,sDoc) == true)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程修改成功!');window.location.href('WorkFlowConfigure.aspx');", true);
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程修改失败!');", true);
- }
- }
- else
- {
- if (EFlyWF.InsertWFAct1(-1, sUnit, sActName, iWFID, iPage, iStart, iBlock, iShunt, iMode, iRole, iParent,sDoc) == true)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程新增成功!');window.location.href('WorkFlowConfigure.aspx');", true);
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程新增失败!');", true);
- }
- }
- }
- }