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

.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. public partial class Workflow_WorkFlowConfigure : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             EtongFlyChouWF WFFly = new EtongFlyChouWF();
  19.             DataView dv = new DataView();
  20.             dv = WFFly.GetWFNewData();
  21.             try
  22.             {
  23.                 this.GridView1.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MorePageNum"]);
  24.             }
  25.             catch
  26.             {
  27.                 this.GridView1.PageSize = 10;
  28.             }
  29.             this.GridView1.DataSource = dv;
  30.             this.GridView1.DataBind();
  31.             //btnDeleteProcess.Attributes.Add("onclick", "javascript:return confirm('确定要删除吗?');");
  32.         }
  33.     }
  34.     protected string FormatStr(object Objval)
  35.     {
  36.         string retval, strval;
  37.         strval = Convert.ToString(Objval);
  38.         if (strval == "1") retval = "已启用";
  39.         else if (strval == "0") retval = "已停用";
  40.         else retval = "未知状态";
  41.         return retval;
  42.     }
  43.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  44.     {
  45.         int currentpageindex;
  46.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  47.         if (currentpageindex == -2)
  48.         {
  49.             TextBox txtNewPageIndex;
  50.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  51.             if (txtNewPageIndex != null)
  52.             {
  53.                 try
  54.                 {
  55.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  56.                 }
  57.                 catch
  58.                 {
  59.                     currentpageindex = 0;
  60.                 }
  61.             }
  62.         }
  63.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  64.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  65.         GridView1.PageIndex = currentpageindex;
  66.         EtongFlyChouWF WFFly = new EtongFlyChouWF();
  67.         DataView dv = new DataView();
  68.         dv = WFFly.GetWFNewData();
  69.         GridView1.DataSource = dv;
  70.         GridView1.DataBind();
  71.     }
  72.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  73.     {
  74.         if (e.Row.RowType == DataControlRowType.DataRow)
  75.         {
  76.             int iRow;
  77.             iRow = e.Row.DataItemIndex;
  78.             iRow = iRow % 2;
  79.             if (iRow > 0)
  80.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  81.             else
  82.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  83.             e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
  84.         }
  85.     }
  86.     protected void btnAddProcess_Click(object sender, EventArgs e)
  87.     {
  88.         Response.Redirect("WorkFlowConfigureENew.aspx?StrM=N");
  89.     }
  90.     protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
  91.     {
  92.         string sSelectedIndex;
  93.         int iSelectedIndex=0;
  94.         sSelectedIndex = TB_SelectedIndex.Value;
  95.         if (sSelectedIndex.Trim() == "" || sSelectedIndex == null)
  96.         {
  97.         }
  98.         else
  99.         {
  100.             try
  101.             {
  102.                 iSelectedIndex = Convert.ToInt32(sSelectedIndex);
  103.             }
  104.             catch
  105.             {
  106.                 iSelectedIndex = -1;
  107.             }
  108.             if (iSelectedIndex != -1)
  109.             {
  110.                 ImageButton imgbtselected;
  111.                 imgbtselected = this.GridView1.Rows[iSelectedIndex].FindControl("IB_Del") as ImageButton;
  112.                 imgbtselected.Visible = false;
  113.             }
  114.         }
  115.         int i= GridView1.SelectedIndex;
  116.         TB_SelectName.Value = GridView1.SelectedRow.Cells[1].Text;
  117.         TB_SelectedIndex.Value = Convert.ToString(i);
  118.         ImageButton imgbt;
  119.         imgbt = this.GridView1.SelectedRow.FindControl("IB_Del") as ImageButton;
  120.         imgbt.Visible = true;
  121.         this.GridView1.SelectedRow.HorizontalAlign = HorizontalAlign.Center;
  122.         TB_SelectedKey.Value=this.GridView1.DataKeys[i].Value.ToString();
  123.         //TB_SelectName.Value = this.GridView1.SelectedRow.Cells[1].Text;
  124.         //imgbt = this.GridView1.TemplateControl.FindControl("IB_Del") as ImageButton;
  125.     }
  126.     protected void btnModifyProcess_Click(object sender, EventArgs e)
  127.     {
  128.         int i;
  129.         try 
  130.         {
  131.             i= Convert.ToInt32(TB_SelectedKey.Value);
  132.         }
  133.         catch 
  134.         {
  135.             i =-1;
  136.         }
  137.         if (i==-1)
  138.         {
  139.             this.ClientScript.RegisterStartupScript(this.GetType(),"","alert('系统提示:请选择工作流!');",true);
  140.             return;
  141.         }
  142.         Response.Redirect("WorkFlowConfigureENew.aspx?StrM=M&StrN="+i);
  143.     }
  144.     protected void btnDeleteProcess_Click(object sender, EventArgs e)
  145.     {
  146.     }
  147.     protected void btnTaskManage_Click(object sender, EventArgs e)
  148.     {
  149.         int i;
  150.         try
  151.         {
  152.             i = Convert.ToInt32(TB_SelectedKey.Value);
  153.         }
  154.         catch
  155.         {
  156.             i = -1;
  157.         }
  158.         if (i == -1)
  159.         {
  160.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:请选择工作流!');", true);
  161.             return;
  162.         }
  163.         string strName = TB_SelectName.Value;
  164.         Response.Redirect("WorkFlowTaskSession.aspx?StrM=M&StrN="+i+"&StrNM="+strName);
  165.     }
  166.     protected void btnRouteManage_Click(object sender, EventArgs e)
  167.     {
  168.         int i;
  169.         try
  170.         {
  171.             i = Convert.ToInt32(TB_SelectedKey.Value);
  172.         }
  173.         catch
  174.         {
  175.             i = -1;
  176.         }
  177.         if (i == -1)
  178.         {
  179.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:请选择工作流!');", true);
  180.             return;
  181.         }
  182.         Response.Redirect("WorkFlowImage.aspx?PID=" +i);
  183.     }
  184.     protected void btnDeleteProcess_Click1(object sender, EventArgs e)
  185.     {
  186.         int iWFID;
  187.         try
  188.         {
  189.             iWFID = Convert.ToInt32(TB_SelectedKey.Value);
  190.         }
  191.         catch
  192.         {
  193.             iWFID = -1;
  194.         }
  195.         if (iWFID == -1)
  196.         {
  197.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:请选择工作流!');", true);
  198.             return;
  199.         }
  200.         try
  201.         {
  202.             EtongFlyChouWFNTask tsk = new EtongFlyChouWFNTask();
  203.             //tsk.CreateNewTask();
  204.             tsk.TaskWFID = iWFID;
  205.             if (tsk.IsCanWFDelete() == false)
  206.             {
  207.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:该工作流正被任务活动使用,无法删除!欲删除该工作流,请先删除与该工作流关联的活动。')", true);
  208.                 return;
  209.             }
  210.             tsk.WFDelete();
  211.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:工作流删除成功!');window.location.replace(window.location.href);", true);
  212.         }
  213.         catch (Exception ex)
  214.         {
  215.             this.ClientScript.RegisterStartupScript(this.GetType(),"", "<script>alert('" + ex.Message.Replace("'", "").Replace("n", "") + "');</script>");
  216.         }
  217.     }
  218. }