WorkFlowTaskEdit.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:15k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using com.etong.DAL.FC;
  12. using com.etong.BusinessRule.Zwf;
  13. public partial class Workflow_WorkFlowTaskEdit : System.Web.UI.Page
  14. {
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.         if (!IsPostBack)
  18.         {
  19.             int iWFID;
  20.             WFValue.Value = Request.QueryString["StrN"];
  21.             try
  22.             {
  23.                 iWFID = Convert.ToInt32(WFValue.Value);
  24.             }
  25.             catch
  26.             {
  27.                 iWFID = -1;
  28.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
  29.             }
  30.             EtongFlyChouWFPrj EFlyPrj = new EtongFlyChouWFPrj();
  31.             DataView dv = new DataView();
  32.             dv = EFlyPrj.GetAllOpRole();
  33.             DTaskRoleName.DataTextField = "OpName";
  34.             DTaskRoleName.DataValueField = "OpID";
  35.             DTaskRoleName.DataSource = dv;
  36.             DTaskRoleName.DataBind();
  37.             EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
  38.             dv = EFlyWF.GetWFStaticPage();
  39.             DTaskPage.DataTextField = "PageName";
  40.             DTaskPage.DataValueField = "StaticPageID";
  41.             DTaskPage.DataSource = dv;
  42.             DTaskPage.DataBind();
  43.             EtongFlyChouCode EFlyCode = new EtongFlyChouCode();
  44.             dv = EFlyCode.BlockCodeAll("tb_BlockSort");
  45.             DTaskBlock.DataTextField = "BlockName";
  46.             DTaskBlock.DataValueField = "BlockID";
  47.             DTaskBlock.DataSource = dv;
  48.             DTaskBlock.DataBind();
  49.             dv = EFlyCode.BlockCodeAll("tb_TaskSort");
  50.             DTaskSort.DataTextField = "TaskSName";
  51.             DTaskSort.DataValueField = "TaskSID";
  52.             DTaskSort.DataSource = dv;
  53.             DTaskSort.DataBind();
  54.             if (EFlyWF.BlStartTask(iWFID, 0, "StartEnd") == true)
  55.             {
  56.                 DTaskSort.SelectedIndex = 1;
  57.             }
  58.             dv = EFlyCode.BlockCodeAll("tb_Shunt");
  59.             DTaskShunt.DataTextField = "ShuntName";
  60.             DTaskShunt.DataValueField = "ShuntID";
  61.             DTaskShunt.DataSource = dv;
  62.             DTaskShunt.DataBind();
  63.             dv = EFlyCode.BlockCodeAll("tb_ModeSort");
  64.             DTaskMode.DataTextField = "ModeName";
  65.             DTaskMode.DataValueField = "ModeID";
  66.             DTaskMode.DataSource = dv;
  67.             DTaskMode.DataBind();
  68.             if (EFlyWF.BlTask(iWFID, "WorkFlowID", "tb_WF_Activity") == false)
  69.             {
  70.                 DTaskMode.Items.FindByValue(DTaskMode.SelectedValue).Selected = false;
  71.                 DTaskMode.Items.FindByText("抢先式").Selected = true;
  72.                 DTaskMode.Enabled = false;
  73.                 DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
  74.                 DTaskShunt.Items.FindByText("不分流").Selected = true;
  75.                 DTaskShunt.Enabled = false;
  76.                 DTaskSort.Items.FindByValue(DTaskSort.SelectedValue).Selected = false;
  77.                 DTaskSort.Items.FindByText("起始任务").Selected = true;
  78.                 DTaskSort.Enabled = false;
  79.             }
  80.             HAct.Value = "-1";
  81.             if (Request.QueryString["StrM"] == "M")
  82.             {
  83.                 int iActID;
  84.                 try
  85.                 {
  86.                     iActID = Convert.ToInt32(Request.QueryString["StrA"]);
  87.                 }
  88.                 catch
  89.                 {
  90.                     iActID = -1;
  91.                     this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
  92.                     return;
  93.                 }
  94.                 GetM(iWFID,iActID);
  95.                 GetEnable(iWFID, iActID);
  96.                 GetDocName(iActID);
  97.                 HAct.Value = iActID.ToString();
  98.             }
  99.         }
  100.     }
  101.     protected void GetDocName(int iActID)
  102.     {
  103.         //EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
  104.         //DataView dv = EFlyWF.GetActFName(iActID);
  105.         //string sDoc;
  106.         //int starti = 0;
  107.         //for (int i = 0; i < dv.Table.Rows.Count; i++)
  108.         //{
  109.         //    ListItem Lst = new ListItem();
  110.         //    sDoc = dv.Table.Rows[i][0].ToString();
  111.         //    starti = sDoc.Length - (sDoc.Split('\').GetValue(sDoc.Split('\').Length - 1)).ToString().Length;
  112.         //    Lst.Value = sDoc;
  113.         //    Lst.Text = sDoc.Substring(starti, sDoc.Length - starti);
  114.         //    LstDoc.Items.Add(Lst);
  115.         //}
  116.         //新
  117.         EtongWord EWord = new EtongWord();
  118.         EWord.ActID = iActID;
  119.         DataView dv = new DataView();
  120.         dv = EWord.GetFNameByActID();
  121.         for (int k = 0; k < dv.Table.Rows.Count; k++)
  122.         {
  123.             ListItem lstk = new ListItem();
  124.             lstk.Text = dv.Table.Rows[k][1].ToString();
  125.             lstk.Value = dv.Table.Rows[k][0].ToString();
  126.             LstDoc.Items.Add(lstk);
  127.         }
  128.     }
  129.     protected void GetM(int iWFID, int iActID)
  130.     {
  131.         EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
  132.         DataView dv = new DataView();
  133.         dv = EFlyWF.GetActivityEdit(iWFID, iActID);
  134.         if (dv.Table.Rows.Count < 1)
  135.         {
  136.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
  137.             return;
  138.         }
  139.         TxtTaskName.Text = dv.Table.Rows[0][4].ToString();
  140.         TTaskUnit.Text = dv.Table.Rows[0][1].ToString();
  141.         DTaskBlock.Items.FindByValue(DTaskBlock.SelectedValue).Selected = false;
  142.         DTaskBlock.Items.FindByValue(dv.Table.Rows[0][10].ToString()).Selected = true;
  143.         DTaskMode.Items.FindByValue(DTaskMode.SelectedValue).Selected = false;
  144.         DTaskMode.Items.FindByValue(dv.Table.Rows[0][12].ToString()).Selected = true;
  145.         DTaskPage.Items.FindByValue(DTaskPage.SelectedValue).Selected = false;
  146.         DTaskPage.Items.FindByValue(dv.Table.Rows[0][6].ToString()).Selected = true;
  147.         DTaskRoleName.Items.FindByValue(DTaskRoleName.SelectedValue).Selected = false;
  148.         try
  149.         {
  150.             DTaskRoleName.Items.FindByValue(dv.Table.Rows[0][15].ToString()).Selected = true;
  151.         }
  152.         catch
  153.         {
  154.         }
  155.         //else
  156.         //{
  157.         //    DTaskRoleName.SelectedItem.Text = "---请选择---";
  158.         //    DTaskRoleName.SelectedValue = "---请选择---";
  159.         //}
  160.         DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
  161.         DTaskShunt.Items.FindByValue(dv.Table.Rows[0][11].ToString()).Selected = true;
  162.         DTaskSort.Items.FindByValue(DTaskSort.SelectedValue).Selected = false;
  163.         DTaskSort.Items.FindByValue(dv.Table.Rows[0][9].ToString()).Selected = true;
  164.         
  165.         for (int i = 0; i < dv.Table.Rows.Count; i++)
  166.         {
  167.             ListItem Lst = new ListItem();
  168.             Lst.Value = dv.Table.Rows[i][14].ToString();
  169.             Lst.Text = EFlyWF.GetActName(Convert.ToInt32(dv.Table.Rows[i][14].ToString()));
  170.             lbParentTask.Items.Add(Lst);
  171.         }
  172.         //DTaskBlock.SelectedIndex=Convert.ToInt32(dv.Table.Rows[0][10].ToString());
  173.         //DTaskMode.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][12].ToString());
  174.         //DTaskPage.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][6].ToString());
  175.         //DTaskRoleName.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][15].ToString());
  176.         //DTaskShunt.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][11].ToString());
  177.         //DTaskSort.SelectedIndex = Convert.ToInt32(dv.Table.Rows[0][9].ToString());
  178.     }
  179.     protected void GetEnable(int iWFID,int iActID)
  180.     {
  181.         EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
  182.         if (EFlyWF.BlTask(iActID, "ParentActID", "tb_Colony_User") == true)
  183.         {
  184.             DTaskMode.Enabled = false;
  185.             DTaskShunt.Enabled = false;
  186.             ImgSelect.Enabled = false;
  187.         }
  188.         else
  189.         {
  190.             ImgSelect.Enabled = false;
  191.             DTaskMode.Enabled = false;
  192.             DTaskShunt.Enabled = false;
  193.         }
  194.     }
  195.     protected void DTaskSort_SelectedIndexChanged(object sender, EventArgs e)
  196.     {
  197.         
  198.         if (this.DTaskSort.SelectedValue == "0")
  199.         {
  200.             int iWFID;
  201.             try 
  202.             {
  203.                 iWFID = Convert.ToInt32(WFValue.Value);
  204.             }
  205.             catch 
  206.             {
  207.                 iWFID =-1;
  208.             }
  209.             EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
  210.             if (EFlyWF.BlStartTask(iWFID, 0, "StartEnd") == true)
  211.             {
  212.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流已存在起始任务,请选择其他任务!');", true);
  213.                 //DTaskSort.SelectedIndex = 1;
  214.                 DTaskSort.Items.FindByValue(DTaskSort.SelectedValue).Selected = false;
  215.                 DTaskSort.Items.FindByValue("1").Selected = true;
  216.             }
  217.         }
  218.     }
  219.     protected void DTaskShunt_SelectedIndexChanged(object sender, EventArgs e)
  220.     {
  221.         if (DTaskMode.SelectedValue == "0")
  222.         {
  223.             if (DTaskShunt.SelectedValue != "0")
  224.             {
  225.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『抢先式』,分流方式只能为『不分流』!');", true);
  226.                 //DTaskShunt.SelectedIndex = 0;
  227.                 DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
  228.                 DTaskShunt.Items.FindByValue("0").Selected = true;
  229.             }
  230.         }
  231.         else
  232.         {
  233.             if (DTaskShunt.SelectedValue == "0")
  234.             {
  235.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『并行式』,分流方式不能为『不分流』!');", true);
  236.                 //DTaskShunt.SelectedIndex = 1;
  237.                 DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
  238.                 DTaskShunt.Items.FindByValue("1").Selected = true;
  239.             }
  240.         }
  241.     }
  242.     protected void DTaskMode_SelectedIndexChanged(object sender, EventArgs e)
  243.     {
  244.         if (DTaskMode.SelectedValue == "0")
  245.         {
  246.             if (DTaskShunt.SelectedValue != "0")
  247.             {
  248.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『抢先式』,分流方式只能为『不分流』!');", true);
  249.                 //DTaskShunt.SelectedIndex = 0;
  250.                 DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
  251.                 DTaskShunt.Items.FindByValue("0").Selected = true;
  252.             }
  253.         }
  254.         else
  255.         {
  256.             if (DTaskShunt.SelectedValue == "0")
  257.             {
  258.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:本工作流协调方式为『并行式』,分流方式不能为『不分流』!');", true);
  259.                 //DTaskShunt.SelectedIndex = 1;
  260.                 DTaskShunt.Items.FindByValue(DTaskShunt.SelectedValue).Selected = false;
  261.                 DTaskShunt.Items.FindByValue("1").Selected = true;
  262.             }
  263.         }
  264.     }
  265.     protected void ImgOK_Click(object sender, ImageClickEventArgs e)
  266.     {
  267.         string sUnit, sActName;
  268.         int iWFID, iPage, iStart, iBlock, iShunt, iMode, iRole;
  269.         //if (DTaskRoleName.SelectedValue == "---请选择---")
  270.         //{
  271.         //    this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:请选择使用角色!');", true);
  272.         //    return;
  273.         //}
  274.         try
  275.         {
  276.             iWFID = Convert.ToInt32(WFValue.Value);
  277.         }
  278.         catch
  279.         {
  280.             iWFID = -1;
  281.         }
  282.         sUnit = TTaskUnit.Text;
  283.         sActName = TxtTaskName.Text;
  284.         try
  285.         {
  286.             iPage = Convert.ToInt32(DTaskPage.SelectedValue);
  287.         }
  288.         catch
  289.         {
  290.             iPage = -1;
  291.         }
  292.         try
  293.         {
  294.             iStart = Convert.ToInt32(DTaskSort.SelectedValue);
  295.         }
  296.         catch
  297.         {
  298.             iStart = -1;
  299.         }
  300.         try
  301.         {
  302.             iBlock = Convert.ToInt32(DTaskBlock.SelectedValue);
  303.         }
  304.         catch
  305.         {
  306.             iBlock = -1;
  307.         }
  308.         try
  309.         {
  310.             iShunt = Convert.ToInt32(DTaskShunt.SelectedValue);
  311.         }
  312.         catch
  313.         {
  314.             iShunt = -1;
  315.         }
  316.         try
  317.         {
  318.             iMode = Convert.ToInt32(DTaskMode.SelectedValue);
  319.         }
  320.         catch
  321.         {
  322.             iMode = -1;
  323.         }
  324.         try
  325.         {
  326.             iRole = Convert.ToInt32(DTaskRoleName.SelectedValue);
  327.         }
  328.         catch
  329.         {
  330.             iRole = -1;
  331.         }
  332.         string sParent;
  333.         sParent = ListValue.Value;
  334.         int i = sParent.Split('|').Length;
  335.         int[] iParent = new int[i];
  336.         for (int j = 0; j < i; j++)
  337.         {
  338.             iParent[j] = Convert.ToInt32(sParent.Split('|').GetValue(j).ToString());
  339.         }
  340.         sParent="";
  341.         sParent = ListDoc.Value;
  342.         int k = sParent.Split('|').Length;
  343.         string[] sDoc = new string[k];
  344.         for (int m = 0; m < k; m++)
  345.         {
  346.             sDoc[m] = Convert.ToString(sParent.Split('|').GetValue(m).ToString());
  347.         }
  348.         EtongFlyChouWF EFlyWF = new EtongFlyChouWF();
  349.         if (Request.QueryString["StrM"] == "M")
  350.         {
  351.             int iActID;
  352.             try
  353.             {
  354.                 iActID = Convert.ToInt32(Request.QueryString["StrA"]);
  355.             }
  356.             catch
  357.             {
  358.                 iActID = -1;
  359.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:参数错误!');window.location.href('WorkFlowConfigure.aspx')", true);
  360.                 return;
  361.             }
  362.             if (EFlyWF.UpWFAct1(iActID, sUnit, sActName, iWFID, iPage, iStart, iBlock, iShunt, iMode, iRole, iParent, 1,sDoc) == true)
  363.             {
  364.                 ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程修改成功!');window.location.href('WorkFlowConfigure.aspx');", true);
  365.             }
  366.             else
  367.             {
  368.                 ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程修改失败!');", true);
  369.             }
  370.         }
  371.         else
  372.         {
  373.             if (EFlyWF.InsertWFAct1(-1, sUnit, sActName, iWFID, iPage, iStart, iBlock, iShunt, iMode, iRole, iParent,sDoc) == true)
  374.             {
  375.                 ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程新增成功!');window.location.href('WorkFlowConfigure.aspx');", true);
  376.             }
  377.             else
  378.             {
  379.                 ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:任务活动流程新增失败!');", true);
  380.             }
  381.         }
  382.     }
  383. }