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

.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.BusinessRule.Zwf;
  12. using com.etong.Inform;
  13. using com.etong.DBUtility;
  14. using com.etong.DAL;
  15. using com.etong.Model;
  16. public partial class Workflow_OldMaterialCollect : System.Web.UI.Page
  17. {
  18.     protected int userid = -1;//用户ID
  19.     protected int wfid = -1;//当前工作流ID
  20.     protected int MustChooseItem = -1;//必选项
  21.     protected int ActivityID = -1;//活动ID
  22.     protected int WFInstanceID = -1;//工作流实例ID
  23.     protected int actinstanceid = -1;//活动实例ID
  24.     protected int ActID = -1;//活动实例ID
  25.     protected bool IsUntread = true;//是否回退
  26.     protected int shuntFlag = 0;//分流标志(0、不分流;1、小件;2、大件;)
  27.     protected int MatHZID = -1;//当前物资汇总ID
  28.     protected string rolestr()
  29.     {
  30.         string rolestr = "";
  31.         if (userid != -1)
  32.         {
  33.             EtongZwf etongzwf = new EtongZwf();
  34.             DataView dvrole = etongzwf.RoleGetByID(userid);
  35.             for (int i = 0; i < dvrole.Count; i++)
  36.             {
  37.                 rolestr = rolestr + dvrole[i][0].ToString().Trim() + ",";
  38.             }
  39.         }
  40.         return rolestr;
  41.     }
  42.     protected void Page_Load(object sender, EventArgs e)
  43.     {
  44.         //------------------------------------------变量定义-----------------------------------------------
  45.         DataView dv = null;
  46.         CheckUserInfo cui = null;
  47.         //-----------------------------------------获取参数值----------------------------------------------
  48.         if (Request.QueryString["MustChooseItem"] != null)
  49.         {
  50.             string MustChooseItemtxt = "";
  51.             MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
  52.             MustChooseItem = Convert.ToInt16(MustChooseItemtxt);
  53.         }
  54.         string ActivityIDtxt = "";
  55.         if (Request.QueryString["ActivityID"] != null)
  56.         {
  57.             ActivityIDtxt = Request.QueryString["ActivityID"].ToString().Trim();
  58.             ActivityID = Convert.ToInt32(ActivityIDtxt);
  59.         }
  60.         string WFInstanceIDtxt = "";
  61.         if (Request.QueryString["WFInstanceID"] != null)
  62.         {
  63.             WFInstanceIDtxt = Request.QueryString["WFInstanceID"].ToString().Trim();
  64.         }
  65.         string WFIDtxt = "";
  66.         if (Request.QueryString["WFID"] != null)
  67.         {
  68.             WFIDtxt = Request.QueryString["WFID"].ToString().Trim();
  69.             wfid = Convert.ToInt16(WFIDtxt);
  70.         }
  71.         if (Request.QueryString["ActID"] != null)
  72.         {
  73.             actinstanceid = Convert.ToInt32(Request.QueryString["ActID"].ToString());
  74.         }
  75.         //----------------------------------------对象定义--------------------------------------------------
  76.         if (Session["checkuserinfo"] != null)
  77.         {
  78.             cui = (CheckUserInfo)Session["checkuserinfo"];
  79.             userid = cui.UserID;
  80.         }
  81.         if (ActivityIDtxt != "" && WFInstanceIDtxt != "")
  82.         {
  83.             if (Convert.ToInt32(ActivityIDtxt) != -1 && Convert.ToInt32(WFInstanceIDtxt) != -1)
  84.             {
  85.                 WFInstanceID = Convert.ToInt32(WFInstanceIDtxt);
  86.                 string sql = "select * from [tb_WF_Instance] where [WFInstanceID]=" + WFInstanceID;
  87.                 dv = SqlServer.GetDataView(sql);
  88.                 if (dv.Count > 0)
  89.                 {
  90.                     wfid = Convert.ToInt32(dv[0][8].ToString().Trim());
  91.                     this.MatHZID = Convert.ToInt32(dv[0][9].ToString().Trim());
  92.                 }
  93.             }
  94.         }
  95.         if (!this.Page.IsPostBack)
  96.         {
  97.             CreateYearToBindDropDownList_Year();
  98.             string path = Server.MapPath("doc").Replace("\", "\\");//获取项目所在路径
  99.             int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
  100.             switch (MustChooseItem)
  101.             {
  102.                 /*==============================================================================================
  103.                  * 
  104.                  *                                物资公司获取并确认废旧物资汇总表
  105.                  * 
  106.                  *=============================================================================================*/
  107.                 case 80:
  108.                     SetAllPanelsVisibility(true, false, false, false, true);
  109.                     this.IsUntread = false;//起始活动不可回退
  110.                     BindPrjOldMatHZInfoToPageControls();
  111.                     break;
  112.                 /*==============================================================================================
  113.                  * 
  114.                  *                                工程管理办公室审核
  115.                  * 
  116.                  *=============================================================================================*/
  117.                 case 81:
  118.                     SetAllPanelsVisibility(true, true, false, false, true);
  119.                     BindPrjOldMatHZInfoToPageControls();
  120.                     break;
  121.                 /*==============================================================================================
  122.                  * 
  123.                  *                                分管领导审核
  124.                  * 
  125.                  *=============================================================================================*/
  126.                 case 82:
  127.                     SetAllPanelsVisibility(true, true, true, false, true);
  128.                     BindPrjOldMatHZInfoToPageControls();
  129.                     break;
  130.                 /*==============================================================================================
  131.                  * 
  132.                  *                                基层单位获取所有反馈的汇总物资
  133.                  * 
  134.                  *=============================================================================================*/
  135.                 case 83:
  136.                     SetAllPanelsVisibility(true, true, true, true, true);
  137.                     BindPrjOldMatHZInfoToPageControls();
  138.                     break;
  139.             }
  140.         }
  141.     }
  142.     //-------------------------------------------------根据MatHZID得到表记录信息--------------------------------------------------
  143.     private DataView GetPrjOldMatHZInfo(int mathzid)
  144.     {
  145.         string sql = "select * from [tb_PrjOldMatHZ] where [MatHZID]=" + mathzid;
  146.         DataView dv = SqlServer.GetDataView(sql);
  147.         return dv;
  148.     }
  149.     //-------------------------------------------绑定由MatHZID得到的表记录信息到页面控件-------------------------------------------
  150.     private void BindPrjOldMatHZInfoToPageControls()
  151.     {
  152.         DataView dv = GetPrjOldMatHZInfo(this.MatHZID);
  153.         CheckUserInfo cui = null;
  154.         if (Session["checkuserinfo"] != null)
  155.         {
  156.             cui = (CheckUserInfo)Session["checkuserinfo"];
  157.         }
  158.         if (dv.Count > 0 && cui != null)
  159.         {
  160.             if (this.Panel_OldMaterialCollect.Visible == true)
  161.             {
  162.                 this.DDL_Year.SelectedValue = dv[0]["nf"].ToString();
  163.                 this.DDL_Year.Enabled = false;
  164.                 this.DDL_Quarter.SelectedValue = dv[0]["jd"].ToString();
  165.                 this.DDL_Quarter.Enabled = false;
  166.                 this.TB_MatHzName.Text = dv[0]["MatHzName"].ToString();
  167.                 this.RadioButtonList2.SelectedValue = dv[0]["HZ"].ToString();
  168.                 this.txt_OldMaterialCollect.Value = dv[0]["HzFName"].ToString();
  169.                 this.BT_OpenDocument_OldMaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_OldMaterialCollect').value,'" + cui.EmpName + "');");
  170.             }
  171.             if (this.Panel_ProjectManagementOffice.Visible == true)
  172.             {
  173.                 this.ShowOperatorAndTime_OldMaterialCollect.InnerHtml = "<div align='center'>汇总人/汇总时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["WzTransactor"].ToString() + "</font></div>";
  174.                 this.RadioButtonList2.Enabled = false;
  175.             }
  176.             if (this.Panel_Separate_Management_Leader.Visible == true)
  177.             {
  178.                 this.ShowOperatorAndTime_ProjectManagementOfficee.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["GcglTransactor"].ToString() + "</font></div>";
  179.                 this.TB_GcglIdea.Text = dv[0]["GcglIdea"].ToString();
  180.                 this.TB_GcglIdea.Enabled = false;
  181.             }
  182.             if (this.Panel_GetFeedbackOldMaterial.Visible == true)
  183.             {
  184.                 this.ShowOperatorAndTime_Separate_Management_Leader.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["FgTransactor"].ToString() + "</font></div>";
  185.                 this.TB_FgIdea.Text = dv[0]["FgIdea"].ToString();
  186.                 this.TB_FgIdea.Enabled = false;
  187.             }
  188.         }
  189.     }
  190.     //-----------------------------------------------------生成DropDownList的下拉项------------------------------------------------------
  191.     private void CreateYearToBindDropDownList_Year()
  192.     {
  193.         int year = DateTime.Now.Year;
  194.         for (int i = year; i >= year - 10; i--)
  195.         {
  196.             this.DDL_Year.Items.Add(new ListItem(i.ToString(), i.ToString()));
  197.         }
  198.     }
  199.     //-------------------------------------------------------设定各项面板的可见性--------------------------------------------------------
  200.     private void SetAllPanelsVisibility(bool flag_OldMaterialCollect, bool flag_ProjectManagementOffice, bool flag_Separate_Management_Leader,
  201.         bool flag_GetFeedbackOldMaterial,bool flag_Button)
  202.     {
  203.         this.Panel_OldMaterialCollect.Visible = flag_OldMaterialCollect;
  204.         this.Panel_ProjectManagementOffice.Visible = flag_ProjectManagementOffice;
  205.         this.Panel_Separate_Management_Leader.Visible = flag_Separate_Management_Leader;
  206.         this.Panel_GetFeedbackOldMaterial.Visible = flag_GetFeedbackOldMaterial;
  207.         this.Panel_Button.Visible = flag_Button;
  208.     }
  209.     protected void BT_Pass_Click(object sender, ImageClickEventArgs e)
  210.     {
  211.           if (Request.QueryString["MustChooseItem"] != null)
  212.         {
  213.             string MustChooseItemtxt = "";
  214.             MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
  215.             MustChooseItem = Convert.ToInt16(MustChooseItemtxt);
  216.         }
  217.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  218.         CheckUserInfo cui = null;
  219.         if (Session["checkuserinfo"] != null)
  220.             cui = (CheckUserInfo)Session["checkuserinfo"];
  221.         string sql = "";
  222.         switch (MustChooseItem)
  223.         {
  224.             /*==============================================================================================
  225.              * 
  226.              *                                废旧物资汇总(审核通过code)
  227.              * 
  228.              *=============================================================================================*/
  229.             case 80:
  230.                 int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
  231.                 if (tempStatus == 2)
  232.                 {
  233.                     WFInstADD("您已审核通过!");
  234.                 }
  235.                 else
  236.                 {
  237.                     string hz = this.RadioButtonList2.SelectedValue;
  238.                     string wzTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  239.                     sql = "update [tb_PrjOldMatHZ] set [HZ]='" + hz + "',[WzTransactor]='" + wzTransactor + "' where [MatHzID]=" + this.MatHZID;
  240.                     if (SqlServer.RunSql(sql))
  241.                     {
  242.                         WFInstADD("您已审核通过!");
  243.                     }
  244.                     else
  245.                     {
  246.                         Common.RunScript(this.Page, "操作失败,请检查数据!");
  247.                     }
  248.                 }
  249.                 break;
  250.             /*==============================================================================================
  251.              * 
  252.              *                                工程管理办公室审核(审核通过code)
  253.              * 
  254.              *=============================================================================================*/
  255.             case 81:
  256.                 string gcglIdea = this.TB_GcglIdea.Text.Trim();
  257.                 string gcglTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  258.                 sql = "update [tb_PrjOldMatHZ] set [GcglTransactor]='" + gcglTransactor + "',[GcglIdea]='" + gcglIdea + "' where [MatHzID]=" + this.MatHZID;
  259.                 if (SqlServer.RunSql(sql))
  260.                 {
  261.                     WFInstADD("您已审核通过!");
  262.                 }
  263.                 else
  264.                 {
  265.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  266.                 }
  267.                 break;
  268.             /*==============================================================================================
  269.              * 
  270.              *                                分管领导审核(审核通过code)
  271.              * 
  272.              *=============================================================================================*/
  273.             case 82:
  274.                 string fgIdea = this.TB_FgIdea.Text.Trim();
  275.                 string fgTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  276.                 sql = "update [tb_PrjOldMatHZ] set [FgTransactor]='" + fgTransactor + "',[FgIdea]='" + fgIdea + "' where [MatHzID]=" + this.MatHZID;
  277.                 if (SqlServer.RunSql(sql))
  278.                 {
  279.                     WFInstADD("您已审核通过!");
  280.                 }
  281.                 else
  282.                 {
  283.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  284.                 }
  285.                 break;
  286.             /*==============================================================================================
  287.              * 
  288.              *                                获取反馈汇总废旧物资(审核通过code)
  289.              * 
  290.              *=============================================================================================*/
  291.             case 83:
  292.                 string jcoIdea = this.TB_JcoIdea.Text.Trim();
  293.                 string jcoTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  294.                 sql = "update [tb_PrjOldMatHZ] set [JcoTransactor]='" + jcoTransactor + "',[JcoIdea]='" + jcoIdea + "',[status]=2 where [MatHzID]=" + this.MatHZID;
  295.                 if (SqlServer.RunSql(sql))
  296.                 {
  297.                     string script = "<script>alert('系统提示:您已审核通过,废旧物资汇总工作完成!');top.location.href='../Main.aspx';</script>";
  298.                     Common.RunScriptString(this.Page, script);
  299.                 }
  300.                 else
  301.                 {
  302.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  303.                 }
  304.                 break;
  305.         }
  306.     }
  307.     protected void BT_Untread_Click(object sender, ImageClickEventArgs e)
  308.     {
  309.         if (IsUntread == false)
  310.         {
  311.             Common.RunScript(this.Page, "起始活动不可回退!");
  312.             return;
  313.         }
  314.         else
  315.         {
  316.             EtongZwf etongzwf = new EtongZwf();
  317.             bool ReActInsValue = false;
  318.             string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  319.             ActID = Convert.ToInt32(ActIDtxt);
  320.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ActID.ToString() + "');</script>");
  321.             //return;
  322.             ReActInsValue = etongzwf.WFActInsUpdata(ActID, userid, 3);
  323.             if (ReActInsValue == true)
  324.             {
  325.                 //产生回退活动事例
  326.                 // 注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  327.                 int ReActInsValue2 = 0;
  328.                 DataView dvAct = etongzwf.ActivityGetByActInsId(ActID);
  329.                 // DataView dvAct = etongzwf.ColonyUserGetByAct(ActivityID);    
  330.                 int PreviousActID = -1;
  331.                 int PreviousUserID = -1;
  332.                 int PreviousRoleID = -1;
  333.                 if (dvAct != null)
  334.                 {
  335.                     PreviousActID = Convert.ToInt16(dvAct[0]["PreviousActID"].ToString().Trim());
  336.                     PreviousUserID = Convert.ToInt16(dvAct[0]["PreviousUserID"].ToString().Trim());
  337.                     PreviousRoleID = Convert.ToInt16(dvAct[0]["PreviousRoleID"].ToString().Trim());
  338.                 }
  339.                 WFActInsInfo wfactinsinfo2 = new WFActInsInfo(-1, PreviousActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  340.                                                                     2, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, "", PreviousUserID, PreviousRoleID);
  341.                 ReActInsValue2 = etongzwf.WFActInsADD(wfactinsinfo2);
  342.                 if (ReActInsValue2 != 0)
  343.                     ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退成功!');top.location.href='../Main.aspx';</script>");
  344.                 else
  345.                     ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退失败!');top.location.href='../Main.aspx';</script>");
  346.             }
  347.         }
  348.     }
  349.     protected void BT_Revoke_Click(object sender, ImageClickEventArgs e)
  350.     {
  351.         string sql = "update tb_WF_ACtIns set Status=4  where [WfInstanceID]=" + this.WFInstanceID + " and [ActivityID]=" + this.ActivityID;
  352.         //string sql1 = "update [tb_PrjOldMat] set [Status]=3 where [MatID]=" + this.MatID;
  353.         if (SqlServer.RunSql(sql)) //&& SqlServer.RunSql(sql1))
  354.         {
  355.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作成功!');top.location.href='../Main.aspx';</script>");
  356.         }
  357.         else
  358.         {
  359.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作失败!');top.location.href='../Main.aspx';</script>");
  360.         }
  361.     }
  362.     /*===========================================================================================================================
  363.    * 
  364.    *                                    工作流操作,分3步 
  365.    * 1.产生工作流实例纪录,注意constructid必须真实存在 
  366.    * 2.更新当前活动实例状态 由WFInstADD中的WFActInsUpdata执行
  367.    * 3.产生新的工作流实例纪录,即产生下一个活动实例并提交到下一个部门的用户申核,由NextColonyRole操作完成                                
  368.    * 
  369.    *==========================================================================================================================*/
  370.     protected void WorkFlowOperation(int matid, string showmessage)
  371.     {
  372.         EtongZwf etongzwf = new EtongZwf();
  373.         ProjectImplment projectImplment = new ProjectImplment();
  374.         DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  375.         if (dv.Count > 0)
  376.         {
  377.             //int ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
  378.             ////DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
  379.             //DataTable dt = projectImplment.GetDepartmentByID(ParentRoleID);
  380.             //if (dt.Rows.Count == 0)
  381.             //{
  382.             //    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!(请联系相关部门或系统管理员)');</script>");
  383.             //    return;
  384.             //}
  385.             DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
  386.             //添加工作流实例 (将添加成功的constructid添加到工作流实例表里,注意是加到该表的PrjID字段中)
  387.             WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  388.                 userid, -1, -1, DateTime.Now, 5, SuccessDate, wfid, matid);
  389.             int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
  390.             //产生当前工作流实例ID
  391.             WFInstanceID = ReInstanceValue;
  392.             //获取当前工作流启始活动    为什么要获取当前工作流启始活动?            
  393.             //DataView dvActID = etongzwf.GetActivityByWFID(wfid);
  394.             //ActivityID = Convert.ToInt32(dvActID[0][0].ToString().Trim());
  395.             if (WFInstanceID > 0)
  396.             {
  397.                 WFInstADD(showmessage);
  398.             }
  399.         }
  400.     }
  401.     /// <summary>
  402.     /// 改变工作流活动实例状态   
  403.     /// </summary>
  404.     /// 
  405.     protected void WFInstADD(string showMessage)
  406.     {
  407.         if (WFInstanceID > 0)
  408.         {
  409.             com.etong.DAL.WorkFolw workflow = new com.etong.DAL.WorkFolw();
  410.             DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
  411.             EtongZwf etongzwf = new EtongZwf();
  412.             DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  413.             // int CurrentActID = -1;
  414.             int CurrentRoleID = -1;
  415.             int ParentActID = -1;
  416.             int ParentRoleID = -1;
  417.             string nextCheckDepartment = null;
  418.             if (dv.Count > 0)
  419.             {
  420.                 if (dv.Count == 1)//不分流
  421.                 {
  422.                     CurrentRoleID = Convert.ToInt32(dv[0]["CurrentRoleID"].ToString().Trim());
  423.                     ParentActID = Convert.ToInt32(dv[0]["ParentActID"].ToString().Trim());
  424.                     ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
  425.                 }
  426.                 else//分流
  427.                 {
  428.                     for (int i = 0; i < dv.Count; i++)
  429.                     {
  430.                         if (Convert.ToInt32(dv[i]["shuntflag"]) == shuntFlag)
  431.                         {
  432.                             CurrentRoleID = Convert.ToInt32(dv[i]["CurrentRoleID"].ToString().Trim());
  433.                             ParentActID = Convert.ToInt32(dv[i]["ParentActID"].ToString().Trim());
  434.                             ParentRoleID = Convert.ToInt32(dv[i]["ParentRoleID"].ToString().Trim());
  435.                         }
  436.                     }
  437.                 }
  438.             }
  439.             //产生当前活动实例  如果是不是第一个活动,只需 修改 UserID 和 Status
  440.             int ReActInsValue = 0;
  441.             int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
  442.             if (MustChooseItem == 80)//对起始活动的操作
  443.             {
  444.                 if (tempStatus == 2)//回退活动
  445.                 {
  446.                     string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  447.                     ActID = Convert.ToInt32(ActIDtxt);
  448.                     bool returnvalue = false;
  449.                     //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
  450.                     returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
  451.                     if (returnvalue == true)
  452.                         ReActInsValue = ActID;
  453.                     if (ReActInsValue > 0)
  454.                     {
  455.                         if (ParentActID != -1)
  456.                         {
  457.                             ProjectImplment pi = new ProjectImplment();
  458.                             //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
  459.                             DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  460.                             nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
  461.                             NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment);  //(ReActInsValue);     //产生下一个活动实例并提交到下一个角色的用户申核
  462.                         }
  463.                         else//不存在上级活动,将 活动状态(Status) 改为 "完成"   注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  464.                         {
  465.                             bool ReValueAIUpdata = false;
  466.                             //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
  467.                             ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
  468.                             if (ReValueAIUpdata == true)
  469.                             {
  470.                                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工完成!');top.location.href='../Main.aspx';</script>");
  471.                             }
  472.                             else
  473.                             {
  474.                                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  475.                             }
  476.                         }
  477.                     }
  478.                 }
  479.                 else
  480.                 {
  481.                     WFActInsInfo wfactinsinfo = new WFActInsInfo(-1, ActivityID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  482.                                                                      1, SuccessDate, WFInstanceID, "", userid, CurrentRoleID);
  483.                     ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
  484.                     ProjectImplment pi = new ProjectImplment();
  485.                     //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
  486.                     DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  487.                     if (dt.Rows.Count > 0)
  488.                     {
  489.                         nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
  490.                         //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:计划下达成功,转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
  491.                     }
  492.                     NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment);//提交给下一部门用户审核
  493.                 }
  494.             }
  495.             else//对不是起始活动的操作
  496.             {
  497.                 string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  498.                 ActID = Convert.ToInt32(ActIDtxt);
  499.                 bool returnvalue = false;
  500.                 //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
  501.                 returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
  502.                 if (returnvalue == true)
  503.                     ReActInsValue = ActID;
  504.                 if (ReActInsValue > 0)
  505.                 {
  506.                     if (ParentActID != -1)
  507.                     {
  508.                         ProjectImplment pi = new ProjectImplment();
  509.                         //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
  510.                         DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  511.                         nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
  512.                         NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment);  //(ReActInsValue);     //产生下一个活动实例并提交到下一个角色的用户申核
  513.                     }
  514.                     else   // 不存在上级活动,将 活动状态(Status) 改为 "完成"   注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  515.                     {
  516.                         bool ReValueAIUpdata = false;
  517.                         //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
  518.                         ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
  519.                         if (ReValueAIUpdata == true)
  520.                         {
  521.                             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工完成!');top.location.href='../Main.aspx';</script>");
  522.                         }
  523.                         else
  524.                         {
  525.                             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  526.                         }
  527.                     }
  528.                 }
  529.             }
  530.         }
  531.     }
  532.     /// <summary>
  533.     /// 起始活动.
  534.     /// </summary>
  535.     protected int ActivityIDGetByWFID(int WfId)
  536.     {
  537.         EtongZwf etongzwf = new EtongZwf();
  538.         DataView dvActivity = etongzwf.GetActivityByWFID(WfId);
  539.         if (dvActivity.Count != 0)
  540.         {
  541.             int activity = Convert.ToInt32(dvActivity[0][0].ToString().Trim());
  542.             return activity;
  543.         }
  544.         else
  545.             return 0;
  546.     }
  547.     /// <summary>
  548.     /// 提交到上级部门用户申核
  549.     /// </summary>
  550.     protected void NextColonyRole(int ParentActID, int ParentRoleID, string showMessage, string nextCheckDepartment)
  551.     {
  552.         EtongZwf etongzwf = new EtongZwf();
  553.         WFActInsInfo wfactinsinfo = new WFActInsInfo(-1, ParentActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  554.                                                                  0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, "", -1, ParentRoleID);
  555.         int ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
  556.         if (ReActInsValue > 0)
  557.         {
  558.             //DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
  559.             //if (dvRoleName.Count != 0)
  560.             //{
  561.             //InitializePage();        //初始化当前页面
  562.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:" + showMessage + ",转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
  563.             //}
  564.             //else
  565.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!');</script>");
  566.         }
  567.         else
  568.         {
  569.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  570.         }
  571.     }
  572. }