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

.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.Inform;
  12. using com.etong.BusinessRule.Zwf;
  13. using com.etong.Model;
  14. using com.etong.DAL.FC;
  15. using System.IO;
  16. using com.etong.Utility;
  17. using com.etong.DBUtility;
  18. using com.etong.DAL;
  19. using DocMergerComponent;
  20. using com.etong.Excel;
  21. public partial class Workflow_WFTaskBrowse : System.Web.UI.Page
  22. {  
  23.     protected int userid = -1;
  24.     protected int  wfid=-1;
  25.     protected int MustChooseItem = -1;
  26.     protected int ActivityID = -1;
  27.     protected int WFInstanceID = -1;
  28.     protected int ActID = -1;  //活动实例ID
  29.     protected int iDepID=-1;
  30.     protected int iEmpID = -1; //当前员工ID
  31.     protected string sAccount = "";
  32.     protected string sEmpName = "";
  33.    
  34.     protected void Page_Load(object sender, EventArgs e)
  35.     {
  36.         try
  37.         {
  38.             CheckUserInfo RoInfo = (CheckUserInfo)Session["checkuserinfo"];
  39.             iDepID = RoInfo.OrgID;
  40.             userid = RoInfo.UserID;
  41.             iEmpID = RoInfo.EmpID;
  42.             sAccount = RoInfo.UserAccount;
  43.             sEmpName = RoInfo.EmpName;
  44.             ((HtmlInputHidden)this.FindControl("txt_sEmpName")).Value = sEmpName;
  45.         }
  46.         catch
  47.         {
  48.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:您尚未登录或您登录已超时,请重新登录!');top.location.href='../login.aspx';", true);
  49.         }
  50.         try 
  51.         {
  52.             string projectid = Request.QueryString["ProjectID"].ToString().Trim(); 
  53.             if (projectid != "")
  54.             {
  55.                ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value = projectid;
  56.                 BT_Confirm.Visible = false;
  57.                 PN_Button.Visible = false;
  58.                 TB_ProjectName.Enabled = false;
  59.                 BtWord_JC.Visible = false;
  60.                 BT_View_JC.Visible = true;
  61.                 BtWord_JC2.Visible = false;
  62.                 BT_View_JC2.Visible = true;
  63.                 BT_ZG.Visible = false;
  64.                 BT_View_ZG.Visible = true;
  65.                 BT_Jqb_HZ.Visible = false;
  66.                 BT_View_Jqb_HZ.Visible = true;
  67.               // BT_Gcgl_XF.Visible = false;
  68.                 BT_View_Gcgl_XF.Visible = true;
  69.                 BT_Jqb_BX.Visible = false;
  70.                 BT_View_Jqb_BX.Visible = true;
  71.                 BT_HS.Visible = false;
  72.                 BT_View_HS.Visible = true;
  73.                 BT_Jqb_FW.Visible = false;
  74.                 BT_View_Jqb_FW.Visible = true;
  75.                 Application.Visible = false;
  76.                 Pn_ZG.Visible = false;
  77.                 Pn_Jqb_HZ.Visible = false;
  78.                 PrjGetAll();
  79.             }
  80.         } 
  81.         catch
  82.         {
  83.             string MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
  84.             ((HtmlInputHidden)this.FindControl("txt_MustChooseItem")).Value = MustChooseItemtxt;
  85.             MustChooseItem = Convert.ToInt16(MustChooseItemtxt);
  86.             string ActivityIDtxt = Request.QueryString["ActivityID"].ToString().Trim();
  87.             string WFInstanceIDtxt = Request.QueryString["WFInstanceID"].ToString().Trim();
  88.             string WFIDtxt = Request.QueryString["WFID"].ToString().Trim();
  89.             wfid = Convert.ToInt16(WFIDtxt);
  90.             EtongZwf etongzwf = new EtongZwf();
  91.             ActivityID = Convert.ToInt32(ActivityIDtxt);
  92.          
  93.             if (!IsPostBack)
  94.             {
  95.                 ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value = "-1";
  96.             }
  97.             if(Convert.ToInt32(WFInstanceIDtxt) != -1)
  98.             {
  99.                 ((HtmlInputHidden)this.FindControl("txt_WFInstanceID")).Value = WFInstanceIDtxt;
  100.                 WFInstanceID = Convert.ToInt32(WFInstanceIDtxt);
  101.                 DataView dvInstance = etongzwf.WFInstanceGetAll(WFInstanceID);
  102.                 ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value = dvInstance[0][9].ToString();
  103.                 wfid = Convert.ToInt32(dvInstance[0][8].ToString().Trim());
  104.             }
  105.             //清除未提交申请
  106.             if (!IsPostBack)
  107.             {
  108.                 int actid = EtongZwf.ActivityIDGetByWFID(wfid);   //.ActivityIDGetByWFID(wfid);
  109.                 etongzwf.ProInit(actid);                        
  110.                 PrjGetAll();
  111.             }
  112.             string Status = "";
  113.             try
  114.             {
  115.                 string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  116.                 ActID = Convert.ToInt32(ActIDtxt);
  117.                 ((HtmlInputHidden)this.FindControl("txt_ActID")).Value = ActIDtxt;
  118.                  Status= EtongZwf.GetStatus(ActID);
  119.             }
  120.             catch {
  121.                // ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:工作流启动失败,请重试!');</script>");
  122.             }
  123.             string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  124.             ArrayList al =EtongZwf.GetDocumentFileName(this.ActivityID);
  125.             switch (MustChooseItem)
  126.             {
  127.                 case 0:         //启动
  128.                     Pn_ZG.Visible = false;           //主管部门项目汇总
  129.                     Application.Visible = false;
  130.                     Pn_Jqb_HZ.Visible = false;       //计企部项目汇总
  131.                     Pn_Gcgl_XF.Visible = false;      //工程管理办公室项目分析
  132.                     Pn_Jqb_BX.Visible = false;       //计企部编写工程计划清单
  133.                     Pn_Fg.Visible = false;           //分管领导批示(审核)
  134.                     Pn_Gc.Visible = false;           //工程预算委员会审批
  135.                     Pn_Gs.Visible = false;           //公司领导审批
  136.                     Pn_HS.Visible = false;         //工程管理办公室
  137.                     Jqb_FW.Visible = false;          //计企部正式发文
  138.                     PN_Button.Visible = false;
  139.                     break;
  140.                 case 11:         //基层单位申请
  141.                     Pn_ZG.Visible = false;          
  142.                     TB_ProjectName.Enabled = false;
  143.                     Pn_Jqb_HZ.Visible = false;      
  144.                     Pn_Gcgl_XF.Visible = false;     
  145.                     Pn_Jqb_BX.Visible = false;      
  146.                     Pn_Fg.Visible = false;          
  147.                     Pn_Gc.Visible = false;          
  148.                     Pn_Gs.Visible = false;         
  149.                     Pn_HS.Visible = false;           
  150.                     Jqb_FW.Visible = false;         
  151.                     BT_Pass.Visible = true;
  152.                     BT_Confirm.Visible = false;
  153.                     BT_Untread.Visible = false;
  154.                     BT_Revoke.Visible = false;
  155.                     TB_JcTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  156.                     this.BtWord_JC.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('LB_JC').value,false);");
  157.                     this.BtWord_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_JC2').value,false);");
  158.                     if (!IsPostBack)
  159.                     {
  160.                         if (Status == "2")   //判断是否是退回的活动
  161.                         {
  162.                             TB_ProjectName.Enabled = false;
  163.                             PrjGetAll();
  164.                         }
  165.                         else
  166.                         {
  167.                             string FileName_JC = "";
  168.                             string FileName_JC2 = "";
  169.                             if (al.Count > 0)
  170.                             {
  171.                                 FileName_JC = al[0].ToString();
  172.                                 FileName_JC2 = al[1].ToString();
  173.                             }
  174.                             LB_JC.Text = EtongZwf.MakeNewFileNameWithDate(FileName_JC);
  175.                             TB_JC2.Text = EtongZwf.MakeNewFileNameWithDate(FileName_JC2);
  176.                             if ((!Util.Copyfile(path + "\" + FileName_JC, path + "\DocTemplate\" + this.LB_JC.Text)) || (!Util.Copyfile(path + "\" + FileName_JC2, path + "\DocTemplate\" + this.TB_JC2.Text)))
  177.                             {
  178.                                 Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  179.                                 return;
  180.                             }
  181.                         }
  182.                     }
  183.                     break;
  184.                 case 1:         //主管审核
  185.                     BT_Untread.Visible = false;
  186.                     BT_Confirm.Visible = false;
  187.                     Application.Visible = false;
  188.                     TB_ProjectName.Enabled = false;
  189.                     Pn_Jqb_HZ.Visible=false;
  190.                     Pn_Gcgl_XF.Visible=false;
  191.                     Pn_Jqb_BX.Visible=false;
  192.                     Pn_Fg.Visible=false;
  193.                     Pn_Gc.Visible=false;
  194.                     Pn_Gs.Visible=false;
  195.                     Pn_HS.Visible=false;
  196.                     Jqb_FW.Visible = false;
  197.                     BT_ZG2.Visible = false;
  198.                     BT_View_ZG2.Visible = true;
  199.                     IB_Collect.Visible = true;
  200.                     BT_ZG.Visible = false;
  201.                     BT_View_ZG.Visible = true;
  202.                     BT_Pass.Attributes.Add("OnClientClick", "javascript:if(confirm('确定要退出吗?')) {window.close();return;} else {return;}");
  203.                     this.BT_View_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG').value,false);");
  204.                     this.BT_View_ZG2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG2').value,false);");
  205.                    
  206.                     if (!IsPostBack)
  207.                     {
  208.                         TB_ZgTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  209.                     }
  210.                     break;
  211.                 case 2:         //计企部汇总
  212.                     BT_Untread.Visible = false;
  213.                     BT_Confirm.Visible = false;
  214.                     TB_ProjectName.Enabled = false;
  215.                     Pn_Gcgl_XF.Visible = false;
  216.                     Pn_Jqb_BX.Visible = false;
  217.                     Pn_Fg.Visible = false;
  218.                     Pn_Gc.Visible = false;
  219.                     Pn_Gs.Visible = false;
  220.                     Pn_HS.Visible = false;
  221.                     Jqb_FW.Visible = false;
  222.                       IB_Collect.Visible = true;
  223.                       Application.Visible = false;
  224.                       Pn_ZG.Visible = false;
  225.                     BT_Jqb_HZ.Visible = false;
  226.                     BT_View_Jqb_HZ.Visible = true;
  227.                     BT_Jqb_HZ2.Visible = false;
  228.                     BT_View_Jqb_HZ2.Visible = true;
  229.                     //this.BT_Jqb_HZ.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_HZ').value);");
  230.                     this.BT_View_Jqb_HZ.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_HZ').value);");
  231.                     this.BT_View_Jqb_HZ2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_HZ2').value);");
  232.                     TB_JqbXTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  233.                     break;
  234.                 case 3:         //工程管理分析
  235.                     BT_Untread.Visible = false;
  236.                     BT_Confirm.Visible = false;
  237.                     TB_ProjectName.Enabled = false;
  238.                     Pn_Jqb_BX.Visible = false;
  239.                     Pn_Fg.Visible = false;
  240.                     Pn_Gc.Visible = false;
  241.                     Pn_Gs.Visible = false;
  242.                     Pn_HS.Visible = false;
  243.                     Jqb_FW.Visible = false;
  244.                     Application.Visible = false;
  245.                     Pn_ZG.Visible = false;
  246.                     Pn_Jqb_HZ.Visible = false;
  247.                    // BT_Gcgl_XF.Visible = false;
  248.                     BT_View_Gcgl_XF.Visible = true;
  249.                    // this.BT_Gcgl_XF.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Gcgl_XF').value);");
  250.                     this.BT_View_Gcgl_XF2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Gcgl_XF2').value);");
  251.                   //  string FileName_Gcgl_XF = al[0].ToString().Trim();
  252.                     if (!IsPostBack)
  253.                     {
  254.                         if (Status == "2")   //判断是否是退回的活动
  255.                         {
  256.                             PrjGetAll();
  257.                         }
  258.                         else
  259.                         {
  260.                             PrjGetAll();
  261.                             //TB_Gcgl_XF.Text =EtongZwf.MakeNewFileNameWithDate(FileName_Gcgl_XF);
  262.                             //if (!Util.Copyfile(path + "\" + FileName_Gcgl_XF, path + "\DocTemplate\" + this.TB_Gcgl_XF.Text))
  263.                             //{
  264.                             //    Common.RunScript(this.Page, "文件拷贝失败,请检查相关设置!");
  265.                             //    return;
  266.                             //}
  267.                         }
  268.                     }
  269.                     TB_GcglXTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  270.                     break;
  271.                 case 6:          //分管领导审批
  272.                     BT_Untread.Visible = false;
  273.                     BT_Confirm.Visible = false;
  274.                     BT_NoPass.Visible = true;
  275.                     TB_ProjectName.Enabled = false;
  276.                     Pn_Jqb_BX.Visible = false;
  277.                     Pn_Gc.Visible = false;
  278.                     Pn_Gs.Visible = false;
  279.                     Pn_HS.Visible = false;
  280.                     Jqb_FW.Visible = false;
  281.                     Application.Visible = false;
  282.                     Pn_ZG.Visible = false;
  283.                     Pn_Jqb_HZ.Visible = false;
  284.                     BT_View_Gcgl_XF.Visible = true;
  285.                     break;
  286.                 case 4:         //计企部计划清单
  287.                     BT_Untread.Visible = true;
  288.                     BT_Confirm.Visible = false;
  289.                     TB_ProjectName.Enabled = false;
  290.                    // BT_Gcgl_XF.Visible = false;
  291.                     BT_View_Gcgl_XF.Visible = true;
  292.                     Pn_Fg.Enabled = false;
  293.                     Pn_Gc.Visible = false;
  294.                     Pn_Gs.Visible = false;
  295.                     Pn_HS.Visible = false;
  296.                     Jqb_FW.Visible = false;
  297.                     Application.Visible = false;
  298.                     Pn_ZG.Visible = false;
  299.                     Pn_Jqb_HZ.Visible = false;
  300.                     BT_Jqb_BX.Visible = false;
  301.                     BT_View_Jqb_BX.Visible = true;
  302.                     //this.BT_Jqb_BX.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_BX').value);");
  303.                     //string FileName_Jqb_BX = al[0].ToString().Trim();
  304.                     if (!IsPostBack)
  305.                     {
  306.                         if (Status == "2")   //判断是否是退回的活动
  307.                         {
  308.                             PrjGetAll();
  309.                         }
  310.                         else
  311.                         {
  312.                             PrjGetAll();
  313.                             //TB_Jqb_BX.Text =EtongZwf.MakeNewFileNameWithDate(FileName_Jqb_BX);
  314.                             //if (!Util.Copyfile(path + "\" + FileName_Jqb_BX, path + "\DocTemplate\" + this.TB_Jqb_BX.Text))
  315.                             //{
  316.                             //    Common.RunScript(this.Page, "文件拷贝失败,请检查相关设置!");
  317.                             //    return;
  318.                             //}
  319.                         }
  320.                     }
  321.                     TB_JqbBTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  322.                     break;
  323.                 case 7:         //工程预算委员会审批
  324.                     BT_Untread.Visible = false;
  325.                     BT_Confirm.Visible = false;
  326.                     TB_ProjectName.Enabled = false;
  327.                    // BT_Gcgl_XF.Visible = false;
  328.                     BT_View_Gcgl_XF.Visible = true;
  329.                     BT_Jqb_BX.Visible = false;
  330.                     BT_View_Jqb_BX.Visible = true;
  331.                     Pn_Fg.Enabled = false;
  332.                     Pn_Gs.Visible = false;
  333.                     Pn_HS.Visible = false;
  334.                     Jqb_FW.Visible = false;
  335.                     BT_NoPass.Visible = true;
  336.                     Application.Visible = false;
  337.                     Pn_ZG.Visible = false;
  338.                     Pn_Jqb_HZ.Visible = false;
  339.                     break;
  340.                 case 9:           //工程办公室审批
  341.                     BT_Untread.Visible = true;
  342.                     BT_Confirm.Visible = false;
  343.                     TB_ProjectName.Enabled = false;
  344.                    // BT_Gcgl_XF.Visible = false;
  345.                     BT_View_Gcgl_XF.Visible = true;
  346.                     BT_Jqb_BX.Visible = false;
  347.                     BT_View_Jqb_BX.Visible = true;
  348.                     Pn_Fg.Enabled = false;
  349.                     Pn_Gc.Enabled = false;
  350.                     Pn_Gs.Visible= false;
  351.                     Jqb_FW.Visible = false;
  352.                     Application.Visible = false;
  353.                     Pn_ZG.Visible = false;
  354.                     Pn_Jqb_HZ.Visible = false;
  355.                     BT_HS.Visible = false;
  356.                     BT_View_HS.Visible = true;
  357.                     //this.BT_HS.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_HS').value);");
  358.                   //  string FileName_HS = al[0].ToString().Trim();
  359.                     if (!IsPostBack)
  360.                     {
  361.                         if (Status == "2")   //判断是否是退回的活动
  362.                         {
  363.                             PrjGetAll();
  364.                         }
  365.                         else
  366.                         {
  367.                             PrjGetAll();
  368.                             //TB_HS.Text =EtongZwf.MakeNewFileNameWithDate(FileName_HS);
  369.                             //if (!Util.Copyfile(path + "\" + FileName_HS, path + "\DocTemplate\" + this.TB_HS.Text))
  370.                             //{
  371.                             //    Common.RunScript(this.Page, "文件拷贝失败,请检查相关设置!");
  372.                             //    return;
  373.                             //}
  374.                         }
  375.                     }
  376.                     TB_HSTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  377.                     break;
  378.                 case 8:         //公司领导审批
  379.                     BT_Untread.Visible = true;
  380.                     BT_Confirm.Visible = false;
  381.                     TB_ProjectName.Enabled = false;
  382.                    // BT_Gcgl_XF.Visible = false;
  383.                     BT_View_Gcgl_XF.Visible = true;
  384.                     BT_Jqb_BX.Visible = false;
  385.                     BT_View_Jqb_BX.Visible = true;
  386.                     Pn_Fg.Enabled = false;
  387.                     Pn_Gc.Enabled = false;
  388.                     BT_HS.Visible = false;
  389.                     BT_View_HS.Visible = true;
  390.                     Jqb_FW.Visible = false;
  391.                     Application.Visible = false;
  392.                     Pn_ZG.Visible = false;
  393.                     Pn_Jqb_HZ.Visible = false;
  394.                     break;
  395.                 case 10:          //计企部正式发文
  396.                     BT_Untread.Visible = true;
  397.                     BT_Confirm.Visible = false;
  398.                     TB_ProjectName.Enabled = false;
  399.                     //BT_Gcgl_XF.Visible = false;
  400.                     BT_View_Gcgl_XF.Visible = true;
  401.                     BT_Jqb_BX.Visible = false;
  402.                     BT_View_Jqb_BX.Visible = true;
  403.                     Pn_Fg.Enabled = false;
  404.                     Pn_Gc.Enabled = false;
  405.                     Pn_Gs.Enabled = false;
  406.                     BT_HS.Visible=false;
  407.                     BT_View_HS.Visible = true;
  408.                     Application.Visible = false;
  409.                     Pn_ZG.Visible = false;
  410.                     Pn_Jqb_HZ.Visible = false;
  411.                     BT_Jqb_FW.Visible = false;
  412.                     BT_View_Jqb_FW.Visible = true;
  413.                     TB_JqbZTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  414.                    // this.BT_Jqb_FW.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_FW').value);");
  415.                     break;
  416.             }
  417.             if (!IsPostBack)
  418.             {
  419.                 this.BtWord_JC.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('LB_JC').value,false);");
  420.                 this.BtWord_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_JC2').value,false);");
  421.                 this.BT_View_JC.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('LB_JC').value,false);");
  422.                 this.BT_View_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_JC2').value,false);");
  423.                 this.BT_View_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG').value,false);");
  424.                 this.BT_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG').value,false);");
  425.                 this.BT_View_ZG2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG2').value,false);");
  426.                 this.BT_ZG2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG2').value,false);");
  427.                 this.BT_Jqb_HZ.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_HZ').value,false);");
  428.                 this.BT_View_Jqb_HZ.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_HZ').value,false);");
  429.               //  this.BT_Gcgl_XF.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Gcgl_XF').value,false);");
  430.                 this.BT_View_Gcgl_XF.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Gcgl_XF').value,false);");
  431.                 this.BT_View_Gcgl_XF2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Gcgl_XF2').value,false);");
  432.                // this.BT_Jqb_BX.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_BX').value,false);");
  433.                 this.BT_View_Jqb_BX.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_BX').value,false);");
  434.                 this.BT_View_Jqb_BX2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_BX2').value,false);");
  435.                // this.BT_HS.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_HS').value,false);");
  436.                 this.BT_View_HS.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_HS').value,false);");
  437.                 this.BT_View_HS2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_HS2').value,false);");
  438.                // this.BT_Jqb_FW.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_FW').value,false);");
  439.                 this.BT_View_Jqb_FW.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_FW').value,false);");
  440.                 this.BT_View_Jqb_FW2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_FW2').value,false);");
  441.                 ArrayList alfp = EtongZwf.GetSFileNamePerm(iEmpID);        //授与编辑权限的文件集合
  442.                 for (int i = 0; i < alfp.Count; i++)
  443.                 {
  444.                     string[] str = alfp[i].ToString().Trim().Split(new Char[] { '.' });
  445.                     int JC = LB_JC.Text.IndexOf(str[0].Trim(), 0);
  446.                     int JC2 = TB_JC2.Text.IndexOf(str[0].Trim(), 0);
  447.                     int ZG = TB_ZG.Text.IndexOf(str[0].Trim(), 0);
  448.                     int Jqb_HZ = TB_Jqb_HZ.Text.IndexOf(str[0].Trim(), 0);
  449.                     int Gcgl_XF = TB_Gcgl_XF.Text.IndexOf(str[0].Trim(), 0);
  450.                     int Jqb_BX = TB_Jqb_BX.Text.IndexOf(str[0].Trim(), 0);
  451.                     int HS = TB_HS.Text.IndexOf(str[0].Trim(), 0);
  452.                     int Jqb_FW = TB_Jqb_FW.Text.IndexOf(str[0].Trim(), 0);
  453.                     if (JC >= 0)
  454.                     {
  455.                         this.BtWord_JC.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('LB_JC').value,true);");
  456.                         this.BT_View_JC.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('LB_JC').value,true);");
  457.                     }
  458.                     if (JC2 >= 0)
  459.                     {
  460.                         this.BtWord_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_JC2').value,true);");
  461.                         this.BT_View_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_JC2').value,true);");
  462.                     }
  463.                     if (ZG >= 0)
  464.                     {
  465.                         this.BT_View_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG').value,true);");
  466.                         this.BT_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG').value,true);");
  467.                     }
  468.                     if (Jqb_HZ >= 0)
  469.                     {
  470.                         this.BT_Jqb_HZ.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_HZ').value,true);");
  471.                         this.BT_View_Jqb_HZ.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_HZ').value,true);");
  472.                     }
  473.                     if (Gcgl_XF >= 0)
  474.                     {
  475.                       //  this.BT_Gcgl_XF.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Gcgl_XF').value,true);");
  476.                         this.BT_View_Gcgl_XF.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Gcgl_XF').value,true);");
  477.                     }
  478.                     if (Jqb_BX >= 0)
  479.                     {
  480.                         this.BT_Jqb_BX.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_BX').value,true);");
  481.                         this.BT_View_Jqb_BX.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_BX').value,true);");
  482.                     }
  483.                     if (HS >= 0)
  484.                     {
  485.                         this.BT_HS.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_HS').value,true);");
  486.                         this.BT_View_HS.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_HS').value,true);");
  487.                     }
  488.                     if (Jqb_FW >= 0)
  489.                     {
  490.                         this.BT_Jqb_FW.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_FW').value,true);");
  491.                         this.BT_View_Jqb_FW.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_Jqb_FW').value,true);");
  492.                     }
  493.                 }
  494.             }
  495.        }
  496.     }
  497.     
  498.     /// <summary>
  499.     /// 获取当前项目内容
  500.     /// </summary>
  501.     protected void PrjGetAll()
  502.     {
  503.        EtongZwf etongzwf = new EtongZwf();
  504.        int prjid = Convert.ToInt32(txt_ProjectID.Value.Trim());
  505.        DataView dvPrjGetAll = etongzwf.ProjectGetAll(prjid);
  506.        if (dvPrjGetAll.Count == 0)
  507.        {
  508.            return;
  509.        }
  510.        TB_ProjectName.Text = dvPrjGetAll[0]["ProjectName"].ToString();
  511.        TB_JcTransactor.Text = dvPrjGetAll[0]["JcTransactor"].ToString();
  512.        string[] JCFName = dvPrjGetAll[0]["JcFName"].ToString().Trim().Split(new Char[] { '\' });
  513.        LB_JC.Text = JCFName[JCFName.Length - 1].ToString();
  514.        //this.BT_View_JC.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('LB_JC').value);");
  515.        string[] JCFName2 = dvPrjGetAll[0]["QuestOrg"].ToString().Trim().Split(new Char[] { '\' });
  516.        TB_JC2.Text = JCFName2[JCFName2.Length - 1].ToString();
  517.       // this.BT_View_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('TB_JC2').value);");
  518.     
  519.        string[] ZgFName = dvPrjGetAll[0]["ZgFName"].ToString().Trim().Split(new Char[] { '\' });
  520.        //TB_ZG.Text = ZgFName[ZgFName.Length - 1].ToString();
  521.        this.BT_View_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('TB_ZG').value);");
  522.        TB_ZgTransactor.Text = dvPrjGetAll[0]["ZgTransactor"].ToString();
  523.  
  524.        string[] Jqb_HZ = dvPrjGetAll[0]["JqbXFName"].ToString().Trim().Split(new Char[] { '\' });
  525.       // TB_Jqb_HZ.Text = Jqb_HZ[Jqb_HZ.Length - 1].ToString();
  526.        //this.BT_View_Jqb_HZ.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('TB_Jqb_HZ').value);");
  527.        TB_JqbXTransactor.Text = dvPrjGetAll[0]["JqbXTransactor"].ToString();
  528.  
  529.        string[] Gcgl_XF = dvPrjGetAll[0]["GcglXFName"].ToString().Trim().Split(new Char[] { '\' });
  530.      //  TB_Gcgl_XF.Text = Jqb_HZ[Jqb_HZ.Length - 1].ToString();         // Gcgl_XF[Gcgl_XF.Length - 1].ToString();
  531.        EtongWord EWord = new EtongWord();
  532.        EWord.sort = -1;
  533.       // EWord.opSort = "99";
  534.        EWord.XmlNodesNames = "XMLrecord";
  535.        string path= Server.MapPath("doc").Replace("\", "\\");
  536.        EWord.Address = path +"\\DocTemplate\\" + Jqb_HZ[Jqb_HZ.Length - 1].ToString(); 
  537.        ArrayList alfn = new ArrayList();
  538.        EtongXml alfn1 = new EtongXml();
  539.        try
  540.        {
  541.            alfn = EWord.ReadXMLFName();
  542.            //alfn1 = alfn[0] as EtongXml;
  543.            TB_Gcgl_XF.Text = ((EtongXml)alfn[0]).DocFileName.ToString();
  544.            TB_Gcgl_XF2.Text = ((EtongXml)alfn[1]).DocFileName.ToString();
  545.            TB_Jqb_BX.Text = ((EtongXml)alfn[0]).DocFileName.ToString();
  546.            TB_Jqb_BX2.Text = ((EtongXml)alfn[1]).DocFileName.ToString();
  547.            TB_HS.Text = ((EtongXml)alfn[0]).DocFileName.ToString();
  548.            TB_HS2.Text = ((EtongXml)alfn[1]).DocFileName.ToString();
  549.            TB_Jqb_FW.Text = ((EtongXml)alfn[0]).DocFileName.ToString();
  550.            TB_Jqb_FW2.Text = ((EtongXml)alfn[1]).DocFileName.ToString();
  551.        }
  552.        catch
  553.        {
  554.          // Common.RunScript(this.Page, EWord.Address.ToString());      //"操作失败:未能找到文件!");
  555.          //   return;
  556.        }
  557.        TB_GcglXTransactor.Text = dvPrjGetAll[0]["GcglXTransactor"].ToString();
  558.        string[] Jqb_BX = dvPrjGetAll[0]["JqbBFName"].ToString().Trim().Split(new Char[] { '\' });
  559.        TB_JqbBTransactor.Text = dvPrjGetAll[0]["JqbBTransactor"].ToString();
  560.     
  561.        if (MustChooseItem != 6)
  562.        {
  563.            TB_FgIdea.Text = dvPrjGetAll[0]["FgIdea"].ToString();
  564.        }
  565.        if (MustChooseItem != 7)
  566.        {
  567.            TB_ZjwyhIdea.Text = dvPrjGetAll[0]["ZjwyhIdea"].ToString();
  568.        }
  569.        if (MustChooseItem != 8)
  570.        {
  571.            TB_GsIdea.Text = dvPrjGetAll[0]["GsIdea"].ToString();
  572.        }
  573.        string[] GcglQIdea = dvPrjGetAll[0]["GcglQIdea"].ToString().Trim().Split(new Char[] { '\' });
  574.        TB_HSTransactor.Text = dvPrjGetAll[0]["GcglQTransactor"].ToString();
  575.        TB_JqbZTransactor.Text = dvPrjGetAll[0]["JqbZTransactor"].ToString();
  576.     }
  577.    
  578.     protected void BT_Confirm_Click(object sender, ImageClickEventArgs e)              //基层单位提交
  579.     {
  580.         string Status = "";
  581.         try{
  582.             ActID=Convert.ToInt32(((HtmlInputHidden)this.FindControl("txt_ActID")).Value.Trim());
  583.             Status =EtongZwf.GetStatus(ActID);
  584.         }
  585.         catch{
  586.             Status = "";
  587.         }
  588.         if (Status == "2")  //if(退回)
  589.         { WFInstADD(); }
  590.         else
  591.         {
  592.             string ProjectName = TB_ProjectName.Text.Trim();
  593.             EtongZwf etongzwf = new EtongZwf();
  594.            //******************************************************申报人提交*************************************************************
  595.             ProjectInfo projectinfo = new ProjectInfo(-1, ProjectName, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 0);
  596.             int ReProjectValue = etongzwf.WFProjectAdd(projectinfo);
  597.             ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value = ReProjectValue.ToString();
  598.             if (ReProjectValue != 0)
  599.             {
  600.                 //产生工作流实例
  601.                 WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  602.                         userid, -1, -1, DateTime.Now, 1, Convert.ToDateTime(DateTime.Now.ToShortDateString()), wfid, ReProjectValue);
  603.                 int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
  604.                 WFInstanceID = ReInstanceValue;
  605.                 ((HtmlInputHidden)this.FindControl("txt_WFInstanceID")).Value = WFInstanceID.ToString();
  606.                 //产生当前活动实例
  607.                 DataView dvActID = etongzwf.GetActivityByWFID(wfid);            //获取当前工作流启始活动
  608.                 ActivityID = Convert.ToInt32(dvActID[0][0].ToString().Trim());
  609.                 DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  610.                 int CurrentRoleID = Convert.ToInt16(dv[0]["CurrentRoleID"].ToString().Trim()); 
  611.                 WFActInsInfo wfactinsinfo = new WFActInsInfo(-1, ActivityID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  612.                                                   0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID,"99", userid, CurrentRoleID);
  613.                 ActID = etongzwf.WFActInsADD(wfactinsinfo);
  614.                 ((HtmlInputHidden)this.FindControl("txt_ActID")).Value = ActID.ToString();
  615.                 WFInstADD();
  616.             }
  617.         }
  618.     }
  619.     /// <summary>
  620.     /// 提交到上级部门用户申核
  621.     /// </summary>
  622.     protected string NextColonyRole(int ParentActID, int ParentRoleID, int ParentEmp,int WFInsID)
  623.     {
  624.         string ReValue="";
  625.         //获取某业务角色对应的类型
  626.         EtongZwf etongzwf = new EtongZwf();
  627.         string Opsort;
  628.        if(MustChooseItem==11)      //是否提交到主管                  
  629.            Opsort = etongzwf.GetEmpType(iEmpID);
  630.         else
  631.           Opsort=EtongZwf.GetOpRole(ParentRoleID);   
  632.         WFActInsInfo wfactinsinfo = new WFActInsInfo(-1, ParentActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  633.                                                       0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInsID, Opsort, ParentEmp, ParentRoleID);
  634.         int ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
  635.         if (ReActInsValue > 0)
  636.         {
  637.             DataView dvRoleName = etongzwf.GetOrgzation(ParentRoleID);
  638.             if (dvRoleName.Count != 0)
  639.             {
  640.                 ReValue = dvRoleName[0][0].ToString();
  641.             }
  642.         }
  643.         else
  644.             ReValue = "";
  645.         return ReValue;
  646.     }
  647.     /// <summary>
  648.     /// 改变工作流活动实例状态   
  649.     /// </summary>
  650.     protected void WFInstADD()
  651.     {
  652.         if (WFInstanceID > 0)
  653.         {
  654.             //int ReActInsValue = 0;
  655.             if (MustChooseItem == 0)                                                                     //标记起始活动实例
  656.             {
  657.                 ActID = Convert.ToInt16(((HtmlInputHidden)this.FindControl("txt_ActID")).Value.Trim());  //活动实例
  658.             }
  659.             else
  660.             {
  661.                 string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  662.                 ActID = Convert.ToInt32(ActIDtxt);
  663.             }
  664.             EtongZwf etongzwf = new EtongZwf();
  665.             DataView dv= etongzwf.ColonyUserGetByActId(ActivityID);  
  666.             int CurrentRoleID = -1;
  667.             int ParentActID = -1;
  668.             int ParentRoleID = -1;
  669.             string ReValueRole = "";
  670.             if (dv.Count > 0)
  671.             {
  672.                 for (int i = 0; i <= dv.Count-1; i++)
  673.                 {
  674.                         string shuntflag = dv[i]["shuntflag"].ToString().Trim();
  675.                         if (shuntflag != "2" || MustChooseItem == 1)       // "0" || (MustChooseItem == 6 && shuntflag=="1"))
  676.                         {
  677.                             CurrentRoleID = Convert.ToInt16(dv[i]["CurrentRoleID"].ToString().Trim());
  678.                             ParentActID = Convert.ToInt16(dv[i]["ParentActID"].ToString().Trim());
  679.                             ParentRoleID = Convert.ToInt16(dv[i]["ParentRoleID"].ToString().Trim());          //提交到下一活动  的 角色ID  
  680.                             if (ParentActID != -1)
  681.                             {
  682.                                 //产生下一个活动实例并提交到下一个角色的用户申核
  683.                                 ReValueRole = ReValueRole + NextColonyRole(ParentActID, ParentRoleID, -1, WFInstanceID) + ",";
  684.                             }
  685.                             else
  686.                             {  //工作流任务完成
  687.                                 etongzwf.WFActInsUpdata(ActID, userid, 1);
  688.                                 string projectid = ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value;
  689.                                 bool re = etongzwf.WF_End("", "", -1, -1, wfid, 1, Convert.ToInt32(projectid.Trim()));
  690.                                 if (re == true)
  691.                                 {
  692.                                     ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目申报完成!');top.location.href='../Main.aspx';</script>");
  693.                                     return;
  694.                                 }
  695.                             }
  696.                         }
  697.                 }
  698.                  bool returnvalue = false;
  699.                  //更新当前活动实例状态
  700.                  etongzwf.WFActInsUpdata(ActID, userid, 1);
  701.                  ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功,转到:  " + ReValueRole + "  申核处理!');top.location.href='../Main.aspx';</script>");  
  702.             }
  703.         }
  704.     }
  705.   
  706.     protected void BT_Pass_Click(object sender, ImageClickEventArgs e)    //申核 
  707.     {
  708.         int projectid = Convert.ToInt32(((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value.Trim());
  709.         EtongZwf etongzwf = new EtongZwf();
  710.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  711.         //******************************************************基层部门*************************************************************
  712.         if (MustChooseItem == 11)
  713.         {
  714.             string JCFName = LB_JC.Text;
  715.             string JCFName2 = TB_JC2.Text;
  716.             //判断上级活动实例是否产生
  717.             string JCXMLFName =  path + "\DocTemplate\";
  718.             DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  719.             int CurrentRoleID = Convert.ToInt16(dv[0]["CurrentRoleID"].ToString().Trim());
  720.             string Opsort = EtongZwf.GetOpRole(CurrentRoleID);  
  721.             bool bl = true;
  722.             bl= etongzwf.CheckUpActCompleteActIns(ActivityID, WFInstanceID,false,"");
  723.             if (bl == false)
  724.             {
  725.                 string NewFName = "";
  726.                 try
  727.                 {
  728.                     NewFName = etongzwf.ProjectGetAll(projectid)[0]["JcFName"].ToString().Trim();
  729.                   
  730.                 }
  731.                 catch {NewFName = ""; }
  732.                 if (NewFName == "" || NewFName == null)
  733.                 {
  734.                     NewFName = EtongZwf.MakeNewFileNameWithDate("XML.xml");
  735.                     if (!Util.Copyfile(path + "\" + "XML.xml", path + "\DocTemplate\" + NewFName))
  736.                     {
  737.                         Common.RunScript(this.Page, "操作失败,请重试!");
  738.                         return;
  739.                     }
  740.                     etongzwf.Project_JC(projectid, NewFName, 0);
  741.                 }
  742.                 JCXMLFName = JCXMLFName + NewFName;
  743.                 WFInstADD();
  744.             }
  745.             else
  746.             {
  747.                 DataView dvPrjGetAll = etongzwf.ProjectGetAll(projectid);
  748.                 JCXMLFName = JCXMLFName + dvPrjGetAll[0]["JcFName"].ToString();
  749.                 
  750.                 //同类型的上级活动是否产生
  751.                     bool bOpsort = true;
  752.                     bOpsort = etongzwf.CheckUpActCompleteActIns(ActivityID, WFInstanceID,true,Opsort);
  753.                     if(bOpsort==false)
  754.                       WFInstADD();
  755.                     else
  756.                     //改变当前活动实例状态
  757.                         etongzwf.WFActInsUpdata(ActID, userid, 1);
  758.                     
  759.                   ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功,转到 主管部门 处理!');top.location.href='../Main.aspx';</script>");
  760.                
  761.             }
  762.            
  763.             //写入XML文档
  764.             etongzwf.WriteXML(JCXMLFName, JCFName, sEmpName, Opsort, DateTime.Now.ToShortDateString());
  765.             etongzwf.WriteXML(JCXMLFName, JCFName2, sEmpName, Opsort, DateTime.Now.ToShortDateString());
  766.         }
  767.         //******************************************************业务主管审定*************************************************************
  768.         if (MustChooseItem == 1)
  769.         {
  770.             string ZgFName = ((HtmlInputHidden)this.FindControl("txt_ZgFname")).Value;           // TB_ZG.Text;     
  771.             if (ZgFName == "" || ZgFName == null)
  772.             {
  773.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:请先汇总!');</script>");
  774.                 return;
  775.             }
  776.             etongzwf.Project_Zg(projectid, "", ZgFName, 0);
  777.             bool bl = true;
  778.             bl= etongzwf.CheckUpActCompleteActIns(ActivityID, WFInstanceID,false,"");
  779.             if (bl == false)
  780.             {
  781.                 WFInstADD();
  782.             }
  783.             else
  784.             {
  785.                 etongzwf.WFActInsUpdata(ActID, userid, 1);
  786.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功,转到 计企部汇总!');top.location.href='../Main.aspx';</script>");
  787.             }
  788.         }
  789.         //******************************************************计企部*************************************************************
  790.         if (MustChooseItem == 2)
  791.         {
  792.             //判断是否汇总过
  793.             string JqbXFName = ((HtmlInputHidden)this.FindControl("txt_FName")).Value;                  //TB_Jqb_HZ.Text;     
  794.             if (JqbXFName == "" || JqbXFName == null)
  795.             {
  796.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:请先汇总!');</script>");
  797.                 return;
  798.             }
  799.            
  800.             bool ReValue_JqbX = false;
  801.             ReValue_JqbX = etongzwf.Project_JqbX(projectid, "", JqbXFName, 0);
  802.             if (ReValue_JqbX == true)
  803.                 WFInstADD();
  804.         }
  805.         //******************************************************工程管理办公室**************************************************************
  806.         if (MustChooseItem == 3)
  807.         {
  808.             string GcglXTransactor = sEmpName + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";  
  809.             string GcglXFName = TB_Gcgl_XF.Text;    
  810.             bool ReValue_Jqb_GcglX = false;
  811.             ReValue_Jqb_GcglX = etongzwf.Project_JQP_GcglX(projectid, GcglXTransactor, GcglXFName, 0);
  812.             if (ReValue_Jqb_GcglX == true)
  813.                 WFInstADD();
  814.         }
  815.         // ******************************************************计企部计划清单**************************************************************
  816.         if (MustChooseItem == 4)
  817.         {
  818.             string JqbBTransactor = sEmpName + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";   
  819.             string JqbBFName = TB_Jqb_BX.Text;   
  820.             bool ReValue_JqbB = false;
  821.             ReValue_JqbB = etongzwf.Project_JqbB(projectid, JqbBTransactor, JqbBFName, 0);
  822.             if (ReValue_JqbB == true)
  823.                 WFInstADD();
  824.         }
  825.         //******************************************************分管领导审批**************************************************************
  826.         if (MustChooseItem == 6)
  827.         {
  828.             string FgIdea = TB_FgIdea.Text.Trim() + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";    //分管领导审核意见和审核时间
  829.             string FgTransactor = sEmpName;                                                            //分管领导签字
  830.             if (FgIdea == "")                   
  831.             {
  832.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:意见不可为空!');</script>");
  833.                 return;
  834.             }
  835.             bool ReValue_Fg = false;
  836.             ReValue_Fg = etongzwf.Project_Fg(projectid, FgTransactor, FgIdea, 0);
  837.             if (ReValue_Fg == true)
  838.                 WFInstADD();
  839.         }
  840.         //******************************************************工程预算委员会审批**************************************************************
  841.         if (MustChooseItem == 7)
  842.         {
  843.             string ZjwyhIdea = TB_ZjwyhIdea.Text.Trim() + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";  
  844.             string ZjwyhTransactor = sEmpName;                                                        
  845.             if (ZjwyhIdea == "")
  846.             {
  847.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:意见不可为空!');</script>");
  848.                 return;
  849.             }
  850.             bool ReValue_Zjwyh = false;
  851.             ReValue_Zjwyh = etongzwf.Project_Zjwyh(projectid,ZjwyhTransactor,ZjwyhIdea,0);
  852.             if (ReValue_Zjwyh == true)
  853.                 WFInstADD();
  854.         }
  855.        //******************************************************公司领导审批******************************************************************
  856.         if (MustChooseItem == 8)
  857.         {
  858.             string GsIdea = TB_GsIdea.Text.Trim() + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";    //公司领导审核意见和审核时间
  859.             string GsTransactor = sEmpName;                                                            //公司领导签字
  860.             if (GsIdea == "")
  861.             {
  862.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:意见不可为空!');</script>");
  863.                 return;
  864.             }
  865.             bool ReValue_Gs = false;
  866.             ReValue_Gs = etongzwf.Project_Gs(projectid, GsTransactor, GsIdea, 0);
  867.             if (ReValue_Gs == true)
  868.                 WFInstADD();
  869.         }
  870.         //******************************************************总经济师核算******************************************************************
  871.         if (MustChooseItem == 9)
  872.         {
  873.             string HSTransactor = sEmpName + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";   //主管部门提交人和时间
  874.             string JqbBFName = TB_HS.Text; 
  875.             bool ReValue_JqbB = false;
  876.             ReValue_JqbB = etongzwf.Project_GcglQ(projectid, HSTransactor, JqbBFName, 0);
  877.             if (ReValue_JqbB == true)
  878.                 WFInstADD();
  879.         }
  880.         //******************************************************计企部正式发文******************************************************************
  881.         if (MustChooseItem == 10)
  882.         {
  883.             string JqbZTransactor = sEmpName + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";   //计企部正式发文提交人和时间
  884.             string JqbZFName = TB_Jqb_FW.Text;
  885.             string ProjectName = TB_ProjectName.Text;
  886.             bool ReValue_JqbZ = false;
  887.             ReValue_JqbZ = etongzwf.Project_JqbZ(projectid, JqbZTransactor, JqbZFName, 1);
  888.             if (ReValue_JqbZ == true)
  889.                 WFInstADD();
  890.            //转到  工程项目实施流程
  891.            //  DataView dvprj=etongzwf.GetProject(WFInstanceID);
  892.             //string prjsort = "99";     //dvprj[0]["PrjSort"].ToString();
  893.             //ConstructInfo constructinfo = new ConstructInfo(ProjectName, prjsort, "", "",JqbZFName, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 1);
  894.             //ProjectImplment projectimplment = new ProjectImplment();
  895.             //int revalue = 0;
  896.             //revalue = projectimplment.AddConstruct(constructinfo);
  897.             //string ReValueRole = "";
  898.             //if (revalue != 0)
  899.             //{
  900.             //    int WorkFlowID = -1;
  901.             //    WorkFlowID = etongzwf.GetConWfID();
  902.             //    WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  903.             //            userid, -1, -1, DateTime.Now, 2, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WorkFlowID, revalue);
  904.             //    int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
  905.             //    //产生下一活动实例
  906.             //    if (ReInstanceValue != 0)
  907.             //    {
  908.                //     WFInstADD();
  909.                 //    DataView dvCU = etongzwf.ActivityColony_User(4);
  910.                 //    int actid = Convert.ToInt16(dvCU[0]["ActivityID"].ToString().Trim());
  911.                 //    int roleid = Convert.ToInt16(dvCU[0]["RoleID"].ToString().Trim());
  912.                 //    ReValueRole = ReValueRole  + NextColonyRole(actid, roleid, -1, ReInstanceValue) + ",";    //转到 项目实施  
  913.                 //}
  914.                 //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功,转到:  " + ReValueRole + "  申核处理!');top.location.href='../Main.aspx';</script>");  
  915.            // }
  916.         }
  917.     }
  918.     protected void BT_Untread_Click(object sender, ImageClickEventArgs e)   //回退
  919.     {
  920.         EtongZwf etongzwf = new EtongZwf();
  921.         
  922.         bool ReActInsValue = false;
  923.         string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  924.         ActID = Convert.ToInt32(ActIDtxt);
  925.         ReActInsValue = etongzwf.WFActInsUpdata(ActID, userid, 3);
  926.           if (ReActInsValue ==true)
  927.           { 
  928.             //产生回退活动事例
  929.             // 注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  930.               int ReActInsValue2 = 0;
  931.               DataView dvAct = etongzwf.ActivityGetByActInsId(ActID);
  932.              // DataView dvAct = etongzwf.ColonyUserGetByAct(ActivityID);    
  933.               int PreviousActID = -1;
  934.               int PreviousUserID = -1;
  935.               int PreviousRoleID = -1;
  936.               if (dvAct!= null)
  937.               {
  938.                   PreviousActID = Convert.ToInt16(dvAct[0]["PreviousActID"].ToString().Trim());
  939.                   PreviousUserID = Convert.ToInt16(dvAct[0]["PreviousUserID"].ToString().Trim());
  940.                   PreviousRoleID = Convert.ToInt16(dvAct[0]["PreviousRoleID"].ToString().Trim());
  941.               }
  942.         
  943.               WFActInsInfo wfactinsinfo2 = new WFActInsInfo(-1, PreviousActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  944.                                                                   2, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, "", PreviousUserID, PreviousRoleID);
  945.               ReActInsValue2 = etongzwf.WFActInsADD(wfactinsinfo2);
  946.       
  947.               if (ReActInsValue2 != 0)
  948.                   ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退成功!');top.location.href='../Main.aspx';</script>");
  949.               else
  950.                   ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退失败!');top.location.href='../Main.aspx';</script>");
  951.           }
  952.     }
  953.     protected void BT_Revoke_Click(object sender, ImageClickEventArgs e)  //作废
  954.     {
  955.         EtongZwf etongzwf = new EtongZwf();
  956.         int projectid = Convert.ToInt32(((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value.Trim());
  957.         if (projectid != -1)
  958.             etongzwf.Project_Untread(projectid, 2);//改变当前项目状态
  959.         else
  960.         {
  961.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退操作失败!');top.location.href='../Main.aspx';</script>");
  962.             return;
  963.         }
  964.         bool ActInsStatus = false;
  965.         ActInsStatus = etongzwf.ActInsStatusChange(WFInstanceID, ActivityID, 4);
  966.         if (ActInsStatus == true)
  967.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作成功!');top.location.href='../Main.aspx';</script>");
  968.         else
  969.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作失败!');top.location.href='../Main.aspx';</script>");
  970.     }
  971.     protected void IB_chakan_Click(object sender, ImageClickEventArgs e) //查看
  972.     {
  973.         string ProjectID = ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value.Trim();
  974.         string sURL = "WFLog.aspx?ProjectID=" + ProjectID;
  975.         Response.Redirect(sURL);
  976.     }
  977.     protected void IB_quxiao_Click(object sender, ImageClickEventArgs e)  //取消
  978.     {
  979.         ClientScript.RegisterStartupScript(this.GetType(), "", "<script>if (confirm('系统提示:确认取消本次申请吗?')){top.mainFrame.location.href='../SpacePage.aspx';}</script>");
  980.         
  981.     }
  982.     protected void BT_NoPass_Click(object sender, ImageClickEventArgs e)    //不通过
  983.     {
  984.         //工程预算委员会 不通过
  985.         // DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  986.           int PreviousRoleID = -1;
  987.           int PreviousActID = -1;
  988.           int PreviousUserID = -1;
  989.           EtongZwf etongzwf = new EtongZwf();
  990.           bool ReActInsValue = false;
  991.           string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  992.           ActID = Convert.ToInt32(ActIDtxt);
  993.           ReActInsValue = etongzwf.WFActInsUpdata(ActID, userid, 3);
  994.           DataView dvAct = etongzwf.ActivityGetByActInsId(ActID);
  995.           if (dvAct != null)
  996.           {
  997.               PreviousActID = Convert.ToInt16(dvAct[0]["PreviousActID"].ToString().Trim());
  998.               PreviousUserID = Convert.ToInt16(dvAct[0]["PreviousUserID"].ToString().Trim());
  999.               PreviousRoleID = Convert.ToInt16(dvAct[0]["PreviousRoleID"].ToString().Trim());
  1000.           }
  1001.           if (MustChooseItem == 6) // 分管领导不通时,返回至下下级
  1002.           {
  1003.               int PreviousActInsID = -1;
  1004.               PreviousActInsID = Convert.ToInt16(dvAct[0]["PreviousActInsID"].ToString().Trim());
  1005.               DataView dv = etongzwf.ActivityGetByActInsId(PreviousActInsID);
  1006.               if (dvAct != null)
  1007.               {
  1008.                   PreviousActID = Convert.ToInt16(dv[0]["PreviousActID"].ToString().Trim());
  1009.                   PreviousUserID = Convert.ToInt16(dv[0]["PreviousUserID"].ToString().Trim());
  1010.                   PreviousRoleID = Convert.ToInt16(dv[0]["PreviousRoleID"].ToString().Trim());
  1011.               }
  1012.           
  1013.           }
  1014.             WFActInsInfo wfactinsinfo2 = new WFActInsInfo(-1, PreviousActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  1015.                                                                              2, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, "", PreviousUserID, PreviousRoleID);
  1016.             int  ReActInsValue2 = 0;
  1017.             ReActInsValue2 = etongzwf.WFActInsADD(wfactinsinfo2);
  1018.             if (ReActInsValue2 != 0 && ReActInsValue==true)
  1019.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功!');top.location.href='../Main.aspx';</script>");
  1020.             else
  1021.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  1022.     }
  1023.     protected void IB_Collect_Click(object sender, ImageClickEventArgs e)    //汇总
  1024.     {
  1025.         MyDocMerger objMerger = new MyDocMerger();
  1026.         DocMerger docmerger = new DocMerger();
  1027.         EtongWord EWord = new EtongWord();
  1028.         EtongZwf etongzwf = new EtongZwf();
  1029.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  1030.         int prjid = Convert.ToInt32(txt_ProjectID.Value.Trim());
  1031.         DataView dvprj = etongzwf.ProjectGetAll(prjid);
  1032.         string FName = "";
  1033.         string FName1 = "";
  1034.         string FName2="";
  1035.         //string opsort = etongzwf.ActInsSort(ActID)[0]["BlockReason"].ToString();  //类型
  1036.         string opsort = etongzwf.GetEmpType(iEmpID);
  1037.         //新建要存储汇总文件的XML文档
  1038.         FName1 = EtongZwf.MakeNewFileNameWithDate("项目预算表.doc"); 
  1039.         FName2 = EtongZwf.MakeNewFileNameWithDate("项目计划汇总表.xls");  
  1040.         string JCXMLFName ="";          
  1041.         string NewFName = "";         
  1042.         //JCXMLFName = JCXMLFName + NewFName;
  1043.         EtongFlyChouWFPrj etongflychouwfprj = new EtongFlyChouWFPrj();
  1044.         etongflychouwfprj.sID = ActID;
  1045.         etongflychouwfprj.iStatus = 1;
  1046.         etongflychouwfprj.sBlockReason = etongzwf.GetEmpType(iEmpID);
  1047.         etongflychouwfprj.PrjID = prjid;
  1048.         etongflychouwfprj.wID = wfid;
  1049.         if (MustChooseItem == 1)    //主管汇总
  1050.         {
  1051.             EWord.opSort = opsort;
  1052.              FName = path + "\DocTemplate\" + dvprj[0]["JcFName"].ToString();                 //+ "XML2007811142752.xml";
  1053.             //判断同类型的所有活动是否走完
  1054.             bool re = etongflychouwfprj.CheckUpActCompleteSort();
  1055.             if (re == false)
  1056.             {
  1057.                 Common.RunScript(this.Page, "系统提示:基层单位同类型电子文档未全部提交,不能汇总!");
  1058.                 return;
  1059.             }
  1060.             TB_ZG.Text = FName1;
  1061.             TB_ZG2.Text = FName2;
  1062.              try
  1063.                 {
  1064.                     NewFName = etongzwf.ProjectGetAll(prjid)[0]["ZgFName"].ToString().Trim();
  1065.                 }
  1066.                 catch { NewFName = ""; }
  1067.                 if (NewFName == "" || NewFName == null)
  1068.                 {
  1069.                     NewFName = EtongZwf.MakeNewFileNameWithDate("XML.xml");
  1070.                    
  1071.                     if (!Util.Copyfile(path + "\" + "XML.xml", path + "\DocTemplate\" + NewFName))
  1072.                     {
  1073.                         Common.RunScript(this.Page, "操作失败,请重试!");
  1074.                         return;
  1075.                     }
  1076.                 }
  1077.                 ((HtmlInputHidden)this.FindControl("txt_ZgFname")).Value = NewFName;
  1078.         }
  1079.         if (MustChooseItem == 2)    //计企部汇总
  1080.         {
  1081.             //判断所有活动是否走完 
  1082.             bool re = etongflychouwfprj.CheckUpActComplete();
  1083.             if (re == false)
  1084.             {
  1085.                 Common.RunScript(this.Page, "系统提示:主管部门电子文档未全部提交,不能汇总!");
  1086.                 return;
  1087.             }
  1088.             FName = path + "\DocTemplate\" + dvprj[0]["ZgFName"].ToString();       
  1089.             EWord.sort = -1;
  1090.             TB_Jqb_HZ.Text = FName1;
  1091.             TB_Jqb_HZ2.Text = FName2;
  1092.             NewFName = EtongZwf.MakeNewFileNameWithDate("XML.xml");
  1093.             ((HtmlInputHidden)this.FindControl("txt_FName")).Value = NewFName;
  1094.             if (!Util.Copyfile(path + "\" + "XML.xml", path + "\DocTemplate\" + NewFName))
  1095.             {
  1096.                 Common.RunScript(this.Page, "操作失败,请重试!");
  1097.                 return;
  1098.             }
  1099.         }
  1100.         EWord.XmlNodesNames = "XMLrecord";
  1101.         EWord.Address = FName;
  1102.         ArrayList alfn = new ArrayList();
  1103.         try
  1104.         {
  1105.             alfn = EWord.ReadXMLFName();
  1106.         }
  1107.         catch 
  1108.         {
  1109.             Common.RunScript(this.Page, "操作失败:未能找到文件!");
  1110.             return;
  1111.         }
  1112.         int count = alfn.Count;
  1113.         string[] fname=new string[count];
  1114.         ArrayList aldoc = new ArrayList();
  1115.         ArrayList alxls = new ArrayList();
  1116.         for (int k = 0; k < count; k++)
  1117.         {
  1118.             EtongXml alfn1 = new EtongXml();
  1119.             alfn1 = alfn[k] as EtongXml;
  1120.             fname[k] = path  +"\\DocTemplate\\" + alfn1.DocFileName.ToString();
  1121.             string[] a = fname[k].ToString().Split('.');
  1122.             if (a[1].ToString().Trim() == "doc")
  1123.                aldoc.Add(fname[k]);
  1124.            if (a[1].ToString().Trim() == "xls")
  1125.               alxls.Add(fname[k]);
  1126.         }
  1127.        int count_doc= aldoc.Count;
  1128.        string[] Docfname = new string[count_doc];
  1129.        for (int i = 0; i < count_doc; i++)
  1130.            Docfname[i] = aldoc[i].ToString().Trim();
  1131.            if (!Util.Copyfile(path + "\" + "项目预算表.doc", path + "\DocTemplate\" + FName1))
  1132.            {
  1133.                Common.RunScript(this.Page, "文件拷贝失败,请检查相关设置!");
  1134.                return;
  1135.            }
  1136.         string filename = path + "\\DocTemplate\\" + FName1;
  1137.         JCXMLFName = path + "\DocTemplate\" + NewFName;
  1138.          try
  1139.          {
  1140.             objMerger.MergeDocArray(filename, Docfname, filename);      //汇总Doc文档
  1141.             EtongExcel EExcel = new EtongExcel(Server.MapPath("doc\\项目计划汇总表.xls"), Server.MapPath("doc\\DocTemplate\\") + FName2);
  1142.             EExcel.RangeCellSet(alxls, 3, 10);
  1143.             EExcel.SaveAsFile();          
  1144.             //将汇总的文件写入XML文档中
  1145.             etongzwf.WriteXML(JCXMLFName, FName1, sEmpName, opsort, DateTime.Now.ToShortDateString());
  1146.             etongzwf.WriteXML(JCXMLFName, FName2, sEmpName, opsort, DateTime.Now.ToShortDateString());
  1147.             Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('系统提示:汇总成功!');</script>");
  1148.         }
  1149.         catch (Exception ex)
  1150.         {
  1151.             ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  1152.         }
  1153.       
  1154.     }
  1155. }