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

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using com.etong.DAL;
  12. using com.etong.DBUtility;
  13. using com.etong.Inform;
  14. using com.etong.BusinessRule;
  15. using com.etong.BusinessRule.Zwf;
  16. using com.etong.Model;
  17. using com.etong.Utility;
  18. using DocMergerComponent;
  19. public partial class Workflow_OldMaterialManagement : System.Web.UI.Page
  20. {
  21.     protected int userid = -1;
  22.     protected int wfid = -1;//当前工作流ID
  23.     protected int MustChooseItem = -1;//必选项
  24.     protected int ActivityID = -1;//活动ID
  25.     protected int WFInstanceID = -1;//工作流实例ID
  26.     protected int actinstanceid = -1;//活动实例ID
  27.     protected int ActID = -1;//活动实例ID
  28.     protected bool IsUntread = true;//是否回退
  29.     protected int shuntFlag = 0;//分流标志(0、不分流;1、小件;2、大件;)
  30.     protected int MatID = -1;
  31.     protected bool IsCollect = false;
  32.     protected string rolestr()
  33.     {
  34.         string rolestr = "";
  35.         if (userid != -1)
  36.         {
  37.             EtongZwf etongzwf = new EtongZwf();
  38.             DataView dvrole = etongzwf.RoleGetByID(userid);
  39.             for (int i = 0; i < dvrole.Count; i++)
  40.             {
  41.                 rolestr = rolestr + dvrole[i][0].ToString().Trim() + ",";
  42.             }
  43.         }
  44.         return rolestr;
  45.     }
  46.     protected void Page_Load(object sender, EventArgs e)
  47.     {
  48.         //------------------------------------------变量定义-----------------------------------------------
  49.         DataView dv = null;
  50.         CheckUserInfo cui = null;
  51.         if (Request.QueryString["MustChooseItem"] != null)
  52.         {
  53.             string MustChooseItemtxt = "";
  54.             MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
  55.             MustChooseItem = Convert.ToInt16(MustChooseItemtxt);
  56.         }
  57.         string ActivityIDtxt = "";
  58.         if (Request.QueryString["ActivityID"] != null)
  59.         {
  60.             ActivityIDtxt = Request.QueryString["ActivityID"].ToString().Trim();
  61.             ActivityID = Convert.ToInt32(ActivityIDtxt);
  62.         }
  63.         string WFInstanceIDtxt = "";
  64.         if (Request.QueryString["WFInstanceID"] != null)
  65.         {
  66.             WFInstanceIDtxt = Request.QueryString["WFInstanceID"].ToString().Trim();
  67.         }
  68.         string WFIDtxt = "";
  69.         if (Request.QueryString["WFID"] != null)
  70.         {
  71.             WFIDtxt = Request.QueryString["WFID"].ToString().Trim();
  72.             wfid = Convert.ToInt16(WFIDtxt);
  73.         }
  74.         if (Request.QueryString["ActID"] != null)
  75.         {
  76.             actinstanceid = Convert.ToInt32(Request.QueryString["ActID"].ToString());
  77.         }
  78.         //----------------------------------------对象定义--------------------------------------------------
  79.         if (Session["checkuserinfo"] != null)
  80.         {
  81.             cui = (CheckUserInfo)Session["checkuserinfo"];
  82.             userid = cui.UserID;
  83.         }
  84.         if (ActivityIDtxt != "" && WFInstanceIDtxt != "")
  85.         {
  86.             if (Convert.ToInt32(ActivityIDtxt) != -1 && Convert.ToInt32(WFInstanceIDtxt) != -1)
  87.             {
  88.                 WFInstanceID = Convert.ToInt32(WFInstanceIDtxt);
  89.                 string sql = "select * from [tb_WF_Instance] where [WFInstanceID]=" + WFInstanceID;
  90.                 dv = SqlServer.GetDataView(sql);
  91.                 if (dv.Count > 0)
  92.                 {
  93.                     wfid = Convert.ToInt32(dv[0][8].ToString().Trim());
  94.                     this.MatID = Convert.ToInt32(dv[0][9].ToString().Trim());
  95.                 }
  96.             }
  97.         }
  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 69:
  108.                 SetAllPanelsVisibility(true, false, false, false, false, false, false, false, false, false, true);
  109.                 IsUntread = false;//起始活动不可回退
  110.                 break;
  111.             /*==============================================================================================
  112.              * 
  113.              *                                基层单位上报废旧物资
  114.              * 
  115.              *=============================================================================================*/
  116.             case 70:
  117.                 SetAllPanelsVisibility(true, true, false, false, false, false, false, false, false, false, true);
  118.                 if (!this.Page.IsPostBack)
  119.                 {
  120.                     BindPrjOldMatInfoToPageControls();
  121.                     string filename_MaterialRemove = GetDocumentFileName(this.ActivityID);
  122.                     this.txt_MaterialRemove.Value = MakeNewFileNameWithDate(filename_MaterialRemove);
  123.                     /*-------------------------------文档拷贝-------------------------------*/
  124.                     if (!(Util.Copyfile(path + "\" + filename_MaterialRemove, path + "\DocTemplateMat\" + this.txt_MaterialRemove.Value)))
  125.                     {
  126.                         Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  127.                         return;
  128.                     }
  129.                     this.ShowOperatorAndTime_ReportOldMaterial.InnerHtml = "<div align='center'>上报人/上报时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + "</font></div>";
  130.                     this.BT_OpenDocument_MaterialRemove.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialRemove').value,'" + cui.EmpName + "');");
  131.                 }
  132.                 break;
  133.             /*==============================================================================================
  134.              * 
  135.              *                                主管部门废旧物资汇总
  136.              * 
  137.              *=============================================================================================*/
  138.             case 77:
  139.                 SetAllPanelsVisibility(true, true, true, false, false, false, false, false, false, false, true);
  140.                 if (!this.Page.IsPostBack)
  141.                 {
  142.                     BindPrjOldMatInfoToPageControls();
  143.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  144.                     this.TB_OpenDocument_ZgHZFName.Enabled = false;
  145.                     this.TB_OpenDocument_ZGxFName.Enabled = false;
  146.                     this.IB_Collect.Visible = true;
  147.                     string filename_DJ = "废旧物资汇总大件表" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
  148.                     string filename_XJ = "废旧物资汇总表" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
  149.                     this.txt_ZGxFName.Value = filename_XJ;
  150.                     this.txt_ZGdFName.Value = filename_DJ;
  151.                     /*-------------------------------文档(大件、小件文档)拷贝-------------------------------*/
  152.                     if (!(Util.Copyfile(path + "\大件汇总表.doc", path + "\DocTemplateMat\" + filename_DJ) && Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + filename_XJ)))
  153.                     {
  154.                         Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  155.                         return;
  156.                     }
  157.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  158.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  159.                 }
  160.                 break;
  161.             /*==============================================================================================
  162.              * 
  163.              *                                废旧物资大件
  164.              * 
  165.              *=============================================================================================*/
  166.             case 71:
  167.                 SetAllPanelsVisibility(true, false, true, false, false, false, false, false, false, false, true);
  168.                 if (!this.Page.IsPostBack)
  169.                 {
  170.                     BindPrjOldMatInfoToPageControls();
  171.                     this.TB_OpenDocument_ZGxFName.Enabled = false;
  172.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  173.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  174.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  175.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  176.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  177.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  178.                 }
  179.                 break;
  180.             /*==============================================================================================
  181.              * 
  182.              *                                废旧物资小件
  183.              * 
  184.              *=============================================================================================*/
  185.             case 72:
  186.                 SetAllPanelsVisibility(true, false, true, false, false, false, false, false, false, false, true);
  187.                 if (!this.Page.IsPostBack)
  188.                 {
  189.                     BindPrjOldMatInfoToPageControls();
  190.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  191.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  192.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  193.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  194.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  195.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  196.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  197.                 }
  198.                 break;
  199.             /*==============================================================================================
  200.              * 
  201.              *                                物资公司收集汇总材料
  202.              * 
  203.              *=============================================================================================*/
  204.             case 73:
  205.                 SetAllPanelsVisibility(true, false, true, true, false, false, false, false, false, false, true);
  206.                 if (!this.Page.IsPostBack)
  207.                 {
  208.                     BindPrjOldMatInfoToPageControls();
  209.                     this.TB_WZjIdea.Text = "同意";
  210.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  211.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  212.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  213.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  214.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  215.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  216.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  217.                 }
  218.                 break;
  219.             /*==============================================================================================
  220.              * 
  221.              *                                物资公司汇总
  222.              * 
  223.              *=============================================================================================*/
  224.             case 78:
  225.                 SetAllPanelsVisibility(true, false, true, true, true, false, false, false, false, false, true);
  226.                 if (!this.Page.IsPostBack)
  227.                 {
  228.                     BindPrjOldMatInfoToPageControls();
  229.                     this.TB_WZjIdea.Enabled = false;
  230.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  231.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  232.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  233.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  234.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  235.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  236.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  237.                     string filename_MaterialCollect = "物资汇总表.doc";
  238.                     this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
  239.                     if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
  240.                     {
  241.                         Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  242.                         return;
  243.                     }
  244.                     this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
  245.                 }
  246.                 break;
  247.             /*==============================================================================================
  248.              * 
  249.              *                                编写废旧物资
  250.              * 
  251.              *=============================================================================================*/
  252.             case 79:
  253.                 SetAllPanelsVisibility(true, false, true, true, false, true, false, false, false, false, true);
  254.                 if (!this.Page.IsPostBack)
  255.                 {
  256.                     BindPrjOldMatInfoToPageControls();
  257.                     this.TB_WZjIdea.Enabled = false;
  258.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  259.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  260.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  261.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  262.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  263.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  264.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  265.                     string filename_OldMaterial = GetDocumentFileName(this.ActivityID);
  266.                     this.txt_WZqFName.Value =MakeNewFileNameWithDate (filename_OldMaterial );
  267.                     if (!(Util.Copyfile(path + "\" + filename_OldMaterial, path + "\DocTemplateMat\" + this.txt_WZqFName.Value)))
  268.                     {
  269.                         Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  270.                         return;
  271.                     }
  272.                     this.BT_OpenDocument_OldMaterialBill.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_WZqFName').value,'" + cui.EmpName + "');");
  273.                 }
  274.                 break;
  275.             /*==============================================================================================
  276.              * 
  277.              *                                工程管理办公室审核
  278.              * 
  279.              *=============================================================================================*/
  280.             case 75:
  281.                 SetAllPanelsVisibility(true, false, true, true, true, false, true, false, false, false, true);
  282.                 if (!this.Page.IsPostBack)
  283.                 {
  284.                     BindPrjOldMatInfoToPageControls();
  285.                     this.TB_GcglIdea.Text = "同意";
  286.                     this.TB_WZjIdea.Enabled = false;
  287.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  288.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  289.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  290.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  291.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  292.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  293.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  294.                     //string filename_MaterialCollect = "物资汇总表.doc";
  295.                     //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
  296.                     //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
  297.                     //{
  298.                     //    Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  299.                     //    return;
  300.                     //}
  301.                     this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
  302.                     this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
  303.                 }
  304.                 break;
  305.             /*==============================================================================================
  306.              * 
  307.              *                                  公司领导审核
  308.              * 
  309.              *=============================================================================================*/
  310.             case 74:
  311.                 SetAllPanelsVisibility(true, false, true, true, true, false, true, true, false, false, true);
  312.                 if (!this.Page.IsPostBack)
  313.                 {
  314.                     BindPrjOldMatInfoToPageControls();
  315.                     this.TB_GcglIdea.Enabled = false;
  316.                     this.TB_GSldIdea.Text = "同意";
  317.                     this.TB_WZjIdea.Enabled = false;
  318.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  319.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  320.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  321.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  322.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  323.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  324.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  325.                     //string filename_MaterialCollect = "物资汇总表.doc";
  326.                     //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
  327.                     //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
  328.                     //{
  329.                     //    Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  330.                     //    return;
  331.                     //}
  332.                     this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
  333.                     this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
  334.                 }
  335.                 break;
  336.             /*==============================================================================================
  337.              * 
  338.              *                                  物资公司审核
  339.              * 
  340.              *=============================================================================================*/
  341.             case 76:
  342.                 SetAllPanelsVisibility(true, false, true, true, true, false, true, true, true, false, true);
  343.                 if (!this.Page.IsPostBack)
  344.                 {
  345.                     BindPrjOldMatInfoToPageControls();
  346.                     this.TB_GcglIdea.Enabled = false;
  347.                     this.TB_GSldIdea.Enabled = false;
  348.                     this.TB_WZjIdea.Enabled = false;
  349.                     this.TB_WZfIdea.Text = "同意";
  350.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  351.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  352.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  353.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  354.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  355.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  356.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  357.                     //string filename_MaterialCollect = "物资汇总表.doc";
  358.                     //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
  359.                     //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
  360.                     //{
  361.                     //    Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  362.                     //    return;
  363.                     //}
  364.                     this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
  365.                     this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
  366.                 }
  367.                 break;
  368.             /*==============================================================================================
  369.            * 
  370.            *                                  竣工材料存档
  371.              * 
  372.              *=============================================================================================*/
  373.             case 100:
  374.                 SetAllPanelsVisibility(true, false, true, true, true, false, true, true, true, true, true);
  375.                 if (!this.Page.IsPostBack)
  376.                 {
  377.                     BindPrjOldMatInfoToPageControls();
  378.                     this.TB_GcglIdea.Enabled = false;
  379.                     this.TB_GSldIdea.Enabled = false;
  380.                     this.TB_WZjIdea.Enabled = false;
  381.                     this.TB_WZfIdea.Enabled = false;
  382.                     this.TB_ZGgIdea.Text="同意";
  383.                     this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  384.                     this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  385.                     this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
  386.                     this.TB_OpenDocument_ZGdFName.Enabled = false;
  387.                     this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
  388.                     this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
  389.                     this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
  390.                     //string filename_MaterialCollect = "物资汇总表.doc";
  391.                     //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
  392.                     //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
  393.                     //{
  394.                     //    Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  395.                     //    return;
  396.                     //}
  397.                     this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
  398.                     this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
  399.                 }
  400.                 break;
  401.         }
  402.         if (!this.Page.IsPostBack)
  403.         {
  404.             CreateYearToBindDropDownList_Year();
  405.             this.UpdateMaterialName.Attributes.Add("href", "javascript:winOpen(" + this.MatID + ",'" + GetPrjOldMatInfo(this.MatID)[0]["MatName"].ToString() + "')");
  406.         }
  407.     }
  408.     private void BindPrjOldMatInfoToPageControls()
  409.     {
  410.         DataView dv = GetPrjOldMatInfo(this.MatID);
  411.         if (dv.Count > 0)
  412.         {
  413.             this.DDL_Year.SelectedValue = dv[0]["nf"].ToString();
  414.             this.DDL_Year.Enabled = false;
  415.             this.DDL_Quarter.SelectedValue = dv[0]["jd"].ToString();
  416.             this.DDL_Quarter.Enabled = false;
  417.             //this.txt_MaterialRemove.Value = dv[0][""].ToString();
  418.             this.ShowOperatorAndTime_ReportOldMaterial.InnerHtml = "<div align='center'>上报人/上报时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["JcTransactor"].ToString() + "</font></div>";
  419.             this.txt_ZgHZFName.Value = GetEmpTypeDocument();
  420.             this.txt_ZGdFName.Value = dv[0]["ZGdFName"].ToString();
  421.             this.txt_ZGxFName.Value = dv[0]["ZGxFName"].ToString();
  422.             this.ShowOperatorAndTime_ZgTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["ZgTransactor"].ToString() + "</font></div>";
  423.             this.TB_WZjIdea.Text = dv[0]["WZjIdea"].ToString();
  424.             this.ShowOperatorAndTime_WZjTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["WZjTransactor"].ToString() + "</font></div>";
  425.             this.txt_MaterialCollect.Value = dv[0]["WZhFName"].ToString();
  426.             this.ShowOperatorAndTime_WZhTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["WZhTransactor"].ToString() + "</font></div>";
  427.             this.txt_WZqFName.Value = dv[0]["WZqFName"].ToString();
  428.             this.ShowOperatorAndTime_WZqTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["WZqTransactor"].ToString() + "</font></div>";
  429.             this.TB_GcglIdea.Text = dv[0]["GcglIdea"].ToString();
  430.             this.ShowOperatorAndTime_GcglTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["GcglTransactor"].ToString() + "</font></div>";
  431.             this.TB_GSldIdea.Text = dv[0]["GSldIdea"].ToString();
  432.             this.ShowOperatorAndTime_GSldTansactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["GSldTansactor"].ToString() + "</font></div>";
  433.             this.TB_WZfIdea.Text = dv[0]["WZfIdea"].ToString();
  434.             this.ShowOperatorAndTime_WZfTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["WZfTransactor"].ToString() + "</font></div>";
  435.             this.TB_ZGgIdea.Text = dv[0]["ZGgIdea"].ToString();
  436.             this.ShowOperatorAndTime_ZGgTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;" + dv[0]["ZGgTransactor"].ToString() + "</font></div>";
  437.         }
  438.     }
  439.     private DataView GetPrjOldMatInfo(int matid)
  440.     {
  441.         string sql = "select * from [tb_PrjOldMat] where [MatID]=" + matid;
  442.         DataView dv = SqlServer.GetDataView(sql);
  443.         return dv;
  444.     }
  445.     private void SetAllPanelsVisibility(
  446.         bool flag_BeginOldMaterialManagement, bool flag_ReportOldMaterial, bool flag_MasterDepartCollectOldMaterial, bool flag_CollectOldMaterial,
  447.         bool flag_MaterialCompanyCollect, bool flag_EditOldMaterialBill, bool flag_ProjectManagementOfficeCheck, bool flag_CompanyLeaderCheck,
  448.         bool flag_MaterialCompanyCheck, bool flag_SaveCompleteMaterial, bool flag_Button)
  449.     {
  450.         this.Panel_BeginOldMaterialManagement.Visible = flag_BeginOldMaterialManagement;
  451.         this.Panel_ReportOldMaterial.Visible = flag_ReportOldMaterial;
  452.         this.Panel_MasterDepartCollectOldMaterial.Visible = flag_MasterDepartCollectOldMaterial;
  453.         this.Panel_CollectOldMaterial.Visible = flag_CollectOldMaterial;
  454.         this.Panel_MaterialCompanyCollect.Visible = flag_MaterialCompanyCollect;
  455.         this.Panel_EditOldMaterialBill.Visible = flag_EditOldMaterialBill;
  456.         this.Panel_ProjectManagementOfficeCheck.Visible = flag_ProjectManagementOfficeCheck;
  457.         this.Panel_CompanyLeaderCheck.Visible = flag_CompanyLeaderCheck;
  458.         this.Panel_MaterialCompanyCheck.Visible = flag_MaterialCompanyCheck;
  459.         this.Panel_SaveCompleteMaterial.Visible = flag_SaveCompleteMaterial;
  460.         this.Panel_Button.Visible = flag_Button;
  461.     }
  462.     private void CreateYearToBindDropDownList_Year()
  463.     {
  464.         int year = DateTime.Now.Year;
  465.         for (int i = year ; i >= year-10; i--)
  466.         {
  467.             this.DDL_Year.Items.Add(new ListItem(i.ToString(), i.ToString()));
  468.         }
  469.     }
  470.     protected void BT_Pass_Click(object sender, ImageClickEventArgs e)
  471.     {
  472.         if (Request.QueryString["MustChooseItem"] != null)
  473.         {
  474.             string MustChooseItemtxt = "";
  475.             MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
  476.             MustChooseItem = Convert.ToInt16(MustChooseItemtxt);
  477.         }
  478.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  479.         CheckUserInfo cui = (CheckUserInfo)Session["checkuserinfo"];
  480.         string sql = "";
  481.         switch (MustChooseItem)
  482.         {
  483.             /*==============================================================================================
  484.              * 
  485.              *                                 废旧物资开始(审核通过code)
  486.              * 
  487.              *=============================================================================================*/
  488.             case 69:
  489.                 int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
  490.                 if (tempStatus == 2)
  491.                 {
  492.                     WFInstADD("您已审核通过!",false);
  493.                 }
  494.                 else
  495.                 {
  496.                     string xmlFileName = "CollectDocument" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".xml";
  497.                     string year = this.DDL_Year.SelectedValue;
  498.                     string quarter = this.DDL_Quarter.SelectedValue;
  499.                     sql = "update [tb_PrjOldMat] set [nf]='" + year + "',[jd]='" + quarter + "',[DocumentXML]='" + xmlFileName + "' where [MatID]=" + this.MatID;
  500.                     if (SqlServer.RunSql(sql))
  501.                     {
  502.                         XML xml = new XML();
  503.                         if (xml.CreateXMLDocument(path + "\DocTemplateMat\" + xmlFileName))
  504.                             WorkFlowOperation(this.MatID,false);
  505.                         else
  506.                             Common.RunScript(this.Page, "XML文档创建失败,请检查相关设置");
  507.                     }
  508.                 }
  509.                 break;
  510.             /*==============================================================================================
  511.              * 
  512.              *                                基层单位上报废旧物资
  513.              * 
  514.              *=============================================================================================*/
  515.             case 70:
  516.                 //string jcTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  517.                 string jcTransactor = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  518.                 sql = "update [tb_PrjOldMat] set [JcTransactor]='" + jcTransactor + "' where [MatID]=" + this.MatID;
  519.                 if (SqlServer.RunSql(sql))
  520.                 {
  521.                     string xmlFileName = GetPrjOldMatInfo(this.MatID)[0]["DocumentXML"].ToString();
  522.                     string filename = this.txt_MaterialRemove.Value;
  523.                     string checker = cui.EmpName;
  524.                     string time = DateTime.Now.ToString();
  525.                     string type = ProjectImplment.GetEmpType(cui.EmpID);
  526.                     XML xml1 = new XML(path + "\DocTemplateMat\" + xmlFileName);
  527.                     xml1.AddXmlNode(new DocumentNode(filename, checker, time, type));//将基层上报的文档信息写入XML文档
  528.                     string xmlMasterFileName = GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
  529.                     if (xmlMasterFileName == "")//如果XML文档不存在,则创建,否则不创建
  530.                     {
  531.                         xmlMasterFileName = "MasterDepartDocument" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".xml";
  532.                         sql = "update [tb_PrjOldMat] set [ZgHZFName]='" + xmlMasterFileName + "' where [MatID]=" + this.MatID;
  533.                         if (SqlServer.RunSql(sql))
  534.                         {
  535.                             if (xml1.CreateXMLDocument(path + "\DocTemplateMat\" + xmlMasterFileName) == false)
  536.                             {
  537.                                 Common.RunScript(this.Page, "XML文档创建失败,请检查相关设置");
  538.                             }
  539.                         }
  540.                     }
  541.                     if (CheckEmpTypeIsEqualBlockReason() == false)
  542.                     {
  543.                         WFInstADD("您已审核通过!",true);
  544.                     }
  545.                     else
  546.                     {
  547.                         WorkFolw workflow = new WorkFolw();
  548.                         if (workflow.WFActInsUpdata(actinstanceid, 1, userid))
  549.                         {
  550.                             EtongZwf etongzwf = new EtongZwf();
  551.                             DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  552.                             int ParentRoleID = -1;
  553.                             if (dv.Count > 0)
  554.                             {
  555.                                 ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
  556.                                 ProjectImplment pi = new ProjectImplment();
  557.                                 DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  558.                                 string nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
  559.                                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:您已经审核通过,转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
  560.                             }
  561.                         }
  562.                     }
  563.                 }
  564.                 else
  565.                 {
  566.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  567.                 }
  568.                 break;
  569.             /*==============================================================================================
  570.              * 
  571.              *                                主管部门废旧物资汇总
  572.              * 
  573.              *=============================================================================================*/
  574.             case 77:
  575.                 //if (this.IsCollect == false)
  576.                 if ((this.TB_OpenDocument_ZGdFName.Enabled == false) && (this.TB_OpenDocument_ZgHZFName.Enabled == false) && (this.TB_OpenDocument_ZGxFName.Enabled == false))
  577.                 {
  578.                     Common.RunScript(this.Page, "您尚未汇总废旧物资,不能审核通过!");
  579.                 }
  580.                 else
  581.                 {
  582.                     string zgTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  583.                     //sql = "update [tb_PrjOldMat] set [ZgTransactor]='" + zgTransactor + "',[ZgHZFName]='" + this.txt_ZgHZFName.Value + "',[ZGxFName]='" + this.txt_ZGxFName.Value + "',[ZGdFName]='" + this.txt_ZGdFName.Value + "' where [MatID]=" + this.MatID;
  584.                     sql = "update [tb_PrjOldMat] set [ZgTransactor]='" + zgTransactor + "',[ZGxFName]='" + this.txt_ZGxFName.Value + "',[ZGdFName]='" + this.txt_ZGdFName.Value + "' where [MatID]=" + this.MatID;
  585.                     if (SqlServer.RunSql(sql))
  586.                     {
  587.                         WorkFlowOperation(this.MatID,true);
  588.                     }
  589.                 }
  590.                 break;
  591.             /*==============================================================================================
  592.              * 
  593.              *                                废旧物资大件
  594.              * 
  595.              *=============================================================================================*/
  596.             case 71:
  597.                 WFInstADD("您已审核通过!",true);
  598.                 break;
  599.             /*==============================================================================================
  600.              * 
  601.              *                                废旧物资小件
  602.              * 
  603.              *=============================================================================================*/
  604.             case 72:
  605.                 WFInstADD("您已审核通过!",true);
  606.                 break;
  607.             /*==============================================================================================
  608.              * 
  609.              *                                物资公司收集汇总材料
  610.              * 
  611.              *=============================================================================================*/
  612.             case 73:
  613.                 string WZjIdea = this.TB_WZjIdea.Text.Trim();
  614.                 string WZjTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  615.                 sql = "update [tb_PrjOldMat] set [WZjIdea]='" + WZjIdea + "',[WZjTransactor]='" + WZjTransactor + "' where [MatID]=" + this.MatID;
  616.                 if (SqlServer.RunSql(sql))
  617.                 {
  618.                     WorkFlowOperation(this.MatID,false);
  619.                 }
  620.                 else
  621.                 {
  622.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  623.                 }
  624.                 break;
  625.             /*==============================================================================================
  626.              * 
  627.              *                                物资公司汇总
  628.              * 
  629.              *=============================================================================================*/
  630.             case 78:
  631.                 /*com.etong.DAL.FC.EtongFlyChouWFPrj etongFlyChouWFPrj = new com.etong.DAL.FC.EtongFlyChouWFPrj();
  632.                 etongFlyChouWFPrj.sID = this.actinstanceid;
  633.                 etongFlyChouWFPrj.PrjID = this.MatID;
  634.                 etongFlyChouWFPrj.wID = this.wfid;
  635.                 etongFlyChouWFPrj.iStatus = 5;
  636.                 //etongFlyChouWFPrj.sBlockReason = WorkFolw.GetBlockReason(this.actinstanceid);
  637.                 if (etongFlyChouWFPrj.CheckUpActComplete() == false)
  638.                 {
  639.                     Common.RunScript(this.Page, "工作流上级所属活动未完成,不能审核通过!");
  640.                 }
  641.                 else
  642.                 {*/
  643.                     //string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  644.                 string xmlDoc = path + "\DocTemplateMat\" + GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
  645.                     XML xmlxml = new XML(xmlDoc);
  646.                     ArrayList list = xmlxml.ReadNode("Documents", "",false);
  647.                     string[] filename1 = new string[list.Count];
  648.                     for (int i = 0; i < filename1.Length; i++)
  649.                     {
  650.                         DocumentNode node = (DocumentNode)list[i];
  651.                         filename1[i] = path + "\DocTemplateMat\" + node.FileName;
  652.                     }
  653.                     MyDocMerger myDocMeger = new MyDocMerger();
  654.                     string orgDocName = path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value;
  655.                     myDocMeger.MergeDocArray(orgDocName, filename1, orgDocName);
  656.                     string WZhFName = this.txt_MaterialCollect.Value;
  657.                     string WZhTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  658.                     sql = "update [tb_PrjOldMat] set [WZhFName]='" + WZhFName + "',[WZhTransactor]='" + WZhTransactor + "',[hz]='2' where [MatID]=" + this.MatID;
  659.                     if (SqlServer.RunSql(sql))
  660.                     {
  661.                         WFInstADD("您已审核通过!",false);
  662.                     }
  663.                     else
  664.                     {
  665.                         Common.RunScript(this.Page, "操作失败,请检查数据!");
  666.                     }
  667.                // }
  668.                 break;
  669.             /*==============================================================================================
  670.              * 
  671.              *                                编写废旧物资
  672.              * 
  673.              *=============================================================================================*/
  674.             case 79:
  675.                 string WZqFName = this.txt_WZqFName.Value;
  676.                 string WZqTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  677.                 sql = "update [tb_PrjOldMat] set [WZqFName]='" + WZqFName + "',[WZqTransactor]='" + WZqTransactor + "' where [MatID]=" + this.MatID;
  678.                 if (SqlServer.RunSql(sql))
  679.                 {
  680.                     WFInstADD("您已审核通过!",false);
  681.                 }
  682.                 else
  683.                 {
  684.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  685.                 }
  686.                 break;
  687.             /*==============================================================================================
  688.              * 
  689.              *                                工程管理办公室审核
  690.              * 
  691.              *=============================================================================================*/
  692.             case 75:
  693.                 string GcglIdea = this.TB_GcglIdea.Text;
  694.                 string GcglTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  695.                 sql = "update [tb_PrjOldMat] set [GcglIdea]='" + GcglIdea + "',[GcglTransactor]='" + GcglTransactor + "' where [MatID]=" + this.MatID;
  696.                 if (SqlServer.RunSql(sql))
  697.                 {
  698.                     WFInstADD("您已审核通过!",false);
  699.                 }
  700.                 else
  701.                 {
  702.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  703.                 }
  704.                 break;
  705.             /*==============================================================================================
  706.              * 
  707.              *                                  公司领导审核
  708.              * 
  709.              *=============================================================================================*/
  710.             case 74:
  711.                 string GSldIdea = this.TB_GSldIdea.Text;
  712.                 string GSldTansactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  713.                 sql = "update [tb_PrjOldMat] set [GSldIdea]='" + GSldIdea + "',[GSldTansactor]='" + GSldTansactor + "' where [MatID]=" + this.MatID;
  714.                 if (SqlServer.RunSql(sql))
  715.                 {
  716.                     WFInstADD("您已审核通过!",false);
  717.                 }
  718.                 else
  719.                 {
  720.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  721.                 }
  722.                 break;
  723.             /*==============================================================================================
  724.              * 
  725.              *                                  物资公司审核
  726.              * 
  727.              *=============================================================================================*/
  728.             case 76:
  729.                 string WZfIdea = this.TB_WZfIdea.Text;
  730.                 string WZfTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  731.                 sql = "update [tb_PrjOldMat] set [WZfIdea]='" + WZfIdea + "',[WZfTransactor]='" + WZfTransactor + "' where [MatID]=" + this.MatID;
  732.                 if (SqlServer.RunSql(sql))
  733.                 {
  734.                    // WFInstADD("您已审核通过!",false);
  735.                     WorkFlowOperation(this.MatID, false);
  736.                 }
  737.                 else
  738.                 {
  739.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  740.                 }
  741.                 break;
  742.             /*==============================================================================================
  743.            * 
  744.            *                                  竣工材料存档
  745.              * 
  746.              *=============================================================================================*/
  747.             case 100:
  748.                 string ZGgIdea = this.TB_ZGgIdea.Text;
  749.                 string ZGgTransactor = cui.EmpName + "   " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
  750.                 sql = "update [tb_PrjOldMat] set [ZGgIdea]='" + ZGgIdea + "',[ZGgTransactor]='" + ZGgTransactor + "',[status]=2 where [MatID]=" + this.MatID;
  751.                 if (SqlServer.RunSql(sql))
  752.                 {
  753.                     WFInstADD("您已审核通过!",false);
  754.                 }
  755.                 else
  756.                 {
  757.                     Common.RunScript(this.Page, "操作失败,请检查数据!");
  758.                 }
  759.                 break;
  760.         }
  761.     }
  762.     /*============================================================对并发活动的特殊处理======================================================
  763.      * 
  764.      *                                                 工作流操作,分3步
  765.      * 1.产生工作流实例纪录,注意matid必须真实存在 
  766.      * 2.更新当前活动实例状态 由WFInstADD中的WFActInsUpdata执行
  767.      * 3.产生新的工作流实例纪录,即产生下一个活动实例并提交到下一个部门的用户申核,由NextColonyRole操作完成                                
  768.      * 
  769.      *=====================================================================================================================================*/
  770.     protected void WorkFlowOperation(int matid,bool isMaster)
  771.     {
  772.         EtongZwf etongzwf = new EtongZwf();
  773.         ProjectImplment projectImplment = new ProjectImplment();
  774.         string sql = " select * from [tb_WF_Instance] where [Status]=5 and [PrjID]=" + this.MatID;
  775.         DataView dv = SqlServer.GetDataView(sql);
  776.         if (dv.Count == 0)//如果实例存在则不添加
  777.         {
  778.             DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
  779.             //添加工作流实例 (将添加成功的constructid添加到工作流实例表里,注意是加到该表的PrjID字段中)
  780.             WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  781.                     userid, -1, -1, DateTime.Now, 5, SuccessDate, wfid,matid);
  782.             int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
  783.             //产生当前工作流实例ID
  784.             WFInstanceID = ReInstanceValue;
  785.         }
  786.         dv = etongzwf.ColonyUserGetByActId(ActivityID);
  787.         if (dv.Count > 0)
  788.         {
  789.             /*int ParentOrgID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
  790.             //DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
  791.             DataTable dataTable = projectImplment.GetDepartmentByID(ParentOrgID);
  792.             if (dataTable.Rows.Count == 0)
  793.             {
  794.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!(请联系相关部门或系统管理员)');</script>");
  795.                 return;
  796.             }*/
  797.             /*DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
  798.             //添加工作流实例 (将添加成功的constructid添加到工作流实例表里,注意是加到该表的PrjID字段中)
  799.             WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  800.                     userid, -1, -1, DateTime.Now, 5, SuccessDate, wfid, matid);
  801.             int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
  802.             //产生当前工作流实例ID
  803.             WFInstanceID = ReInstanceValue;*/
  804.             string nextCheckDepartment = "";
  805.             for (int i = 0; i < dv.Count; i++)//找到所有部门
  806.             {
  807.                 int ParentRoleID = Convert.ToInt32(dv[i]["ParentRoleID"].ToString().Trim());
  808.                 ProjectImplment pi = new ProjectImplment();
  809.                 //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
  810.                 DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  811.                 nextCheckDepartment += dt.Rows[0]["OpName"].ToString()+"、";
  812.             }
  813.             for (int i = 0; i < dv.Count; i++)
  814.             {
  815.                 int CurrentRoleID = Convert.ToInt32(dv[i]["CurrentRoleID"].ToString().Trim());
  816.                 int ParentActID = Convert.ToInt32(dv[i]["ParentActID"].ToString().Trim());
  817.                 int ParentRoleID = Convert.ToInt32(dv[i]["ParentRoleID"].ToString().Trim());
  818.               
  819.                 if (WFInstanceID > 0)
  820.                 {
  821.                     WorkFolw workflow = new WorkFolw();
  822.                     string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  823.                     ActID = Convert.ToInt32(ActIDtxt);
  824.                     bool returnvalue = false;
  825.                     //产生当前活动实例  如果是不是第一个活动,只需 修改 UserID 和 Status
  826.                     int ReActInsValue = 0;
  827.                     
  828.                     //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
  829.                     returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
  830.                     if (returnvalue == true)
  831.                         ReActInsValue = ActID;
  832.                     if (ReActInsValue > 0)
  833.                     {
  834.                         if (ParentActID != -1)
  835.                         {
  836.                             NextColonyRole(ParentActID, ParentRoleID, "您已审核通过", nextCheckDepartment,isMaster);  //(ReActInsValue);     //产生下一个活动实例并提交到下一个角色的用户申核
  837.                         }
  838.                         else   // 不存在上级活动,将 活动状态(Status) 改为 "完成"   注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  839.                         {
  840.                             bool ReValueAIUpdata = false;
  841.                             //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
  842.                             ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
  843.                             if (ReValueAIUpdata == true)
  844.                             {
  845.                                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工完成!');top.location.href='../Main.aspx';</script>");
  846.                             }
  847.                             else
  848.                             {
  849.                                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  850.                             }
  851.                         }
  852.                     }
  853.                 }
  854.             }
  855.         }
  856.     }
  857.     /*===========================================================================================================================
  858.      * 
  859.      *                                    工作流操作,分3步 
  860.      * 1.产生工作流实例纪录,注意constructid必须真实存在 
  861.      * 2.更新当前活动实例状态 由WFInstADD中的WFActInsUpdata执行
  862.      * 3.产生新的工作流实例纪录,即产生下一个活动实例并提交到下一个部门的用户申核,由NextColonyRole操作完成                                
  863.      * 
  864.      *==========================================================================================================================*/
  865.     protected void WorkFlowOperation(int matid, string showmessage,bool isMaster)
  866.     {
  867.         EtongZwf etongzwf = new EtongZwf();
  868.         ProjectImplment projectImplment = new ProjectImplment();
  869.         string sql = " select * from [tb_WF_Instance] where [Status]=2 and [PrjID]=" + this.MatID;
  870.         DataView dv = SqlServer.GetDataView(sql);
  871.         if (dv.Count == 0)//如果实例存在则不添加
  872.         {
  873.             DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
  874.             //添加工作流实例 (将添加成功的constructid添加到工作流实例表里,注意是加到该表的PrjID字段中)
  875.             WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  876.                     userid, -1, -1, DateTime.Now, 5, SuccessDate, wfid,matid);
  877.             int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
  878.             //产生当前工作流实例ID
  879.             WFInstanceID = ReInstanceValue;
  880.         }
  881.         dv = etongzwf.ColonyUserGetByActId(ActivityID);
  882.         if (dv.Count > 0)
  883.         {
  884.             //int ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
  885.             ////DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
  886.             //DataTable dt = projectImplment.GetDepartmentByID(ParentRoleID);
  887.             //if (dt.Rows.Count == 0)
  888.             //{
  889.             //    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!(请联系相关部门或系统管理员)');</script>");
  890.             //    return;
  891.             //}
  892.             //获取当前工作流启始活动    为什么要获取当前工作流启始活动?            
  893.             //DataView dvActID = etongzwf.GetActivityByWFID(wfid);
  894.             //ActivityID = Convert.ToInt32(dvActID[0][0].ToString().Trim());
  895.             if (WFInstanceID > 0)
  896.             {
  897.                 WFInstADD(showmessage,isMaster);
  898.             }
  899.         }
  900.     }
  901.     /// <summary>
  902.     /// 改变工作流活动实例状态   
  903.     /// </summary>
  904.     /// 
  905.     protected void WFInstADD(string showMessage,bool isMaster)
  906.     {
  907.         if (WFInstanceID > 0)
  908.         {
  909.             com.etong.DAL.WorkFolw workflow = new com.etong.DAL.WorkFolw();
  910.             DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
  911.             EtongZwf etongzwf = new EtongZwf();
  912.             DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  913.             // int CurrentActID = -1;
  914.             int CurrentRoleID = -1;
  915.             int ParentActID = -1;
  916.             int ParentRoleID = -1;
  917.             string nextCheckDepartment = null;
  918.             if (dv.Count > 0)
  919.             {
  920.                 if (dv.Count ==1)//不分流
  921.                 {
  922.                     CurrentRoleID = Convert.ToInt32(dv[0]["CurrentRoleID"].ToString().Trim());
  923.                     ParentActID = Convert.ToInt32(dv[0]["ParentActID"].ToString().Trim());
  924.                     ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
  925.                 }
  926.                 else//分流
  927.                 {
  928.                     for (int i = 0; i < dv.Count; i++)
  929.                     {
  930.                         if (Convert.ToInt32(dv[i]["shuntflag"]) == shuntFlag)
  931.                         {
  932.                             CurrentRoleID = Convert.ToInt32(dv[i]["CurrentRoleID"].ToString().Trim());
  933.                             ParentActID = Convert.ToInt32(dv[i]["ParentActID"].ToString().Trim());
  934.                             ParentRoleID = Convert.ToInt32(dv[i]["ParentRoleID"].ToString().Trim());
  935.                         }
  936.                     }
  937.                 }
  938.             }
  939.             //产生当前活动实例  如果是不是第一个活动,只需 修改 UserID 和 Status
  940.             int ReActInsValue = 0;
  941.             int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
  942.             if (MustChooseItem == 69)//对起始活动的操作
  943.             {
  944.                 if (tempStatus == 2)//回退活动
  945.                 {
  946.                     string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  947.                     ActID = Convert.ToInt32(ActIDtxt);
  948.                     bool returnvalue = false;
  949.                     //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
  950.                     returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
  951.                     if (returnvalue == true)
  952.                         ReActInsValue = ActID;
  953.                     if (ReActInsValue > 0)
  954.                     {
  955.                         if (ParentActID != -1)
  956.                         {
  957.                             ProjectImplment pi = new ProjectImplment();
  958.                             //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
  959.                             DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  960.                             nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
  961.                             NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment,isMaster);  //(ReActInsValue);     //产生下一个活动实例并提交到下一个角色的用户申核
  962.                         }
  963.                         else//不存在上级活动,将 活动状态(Status) 改为 "完成"   注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  964.                         {
  965.                             bool ReValueAIUpdata = false;
  966.                             //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
  967.                             ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
  968.                             if (ReValueAIUpdata == true)
  969.                             {
  970.                                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工完成!');top.location.href='../Main.aspx';</script>");
  971.                             }
  972.                             else
  973.                             {
  974.                                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  975.                             }
  976.                         }
  977.                     }
  978.                 }
  979.                 else
  980.                 {
  981.                     WFActInsInfo wfactinsinfo = new WFActInsInfo(-1, ActivityID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  982.                                                                      1, SuccessDate, WFInstanceID, "", userid, CurrentRoleID);
  983.                     ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
  984.                     ProjectImplment pi = new ProjectImplment();
  985.                     //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
  986.                     DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  987.                     if (dt.Rows.Count > 0)
  988.                     {
  989.                         nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
  990.                         //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:计划下达成功,转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
  991.                     }
  992.                     NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment,isMaster);//提交给下一部门用户审核
  993.                 }
  994.             }
  995.             else//对不是起始活动的操作
  996.             {
  997.                 string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  998.                 ActID = Convert.ToInt32(ActIDtxt);
  999.                 bool returnvalue = false;
  1000.                 //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
  1001.                 returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
  1002.                 if (returnvalue == true)
  1003.                     ReActInsValue = ActID;
  1004.                 if (ReActInsValue > 0)
  1005.                 {
  1006.                     if (ParentActID != -1)
  1007.                     {
  1008.                         ProjectImplment pi = new ProjectImplment();
  1009.                         //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
  1010.                         DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
  1011.                         nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
  1012.                         NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment,isMaster);  //(ReActInsValue);     //产生下一个活动实例并提交到下一个角色的用户申核
  1013.                     }
  1014.                     else   // 不存在上级活动,将 活动状态(Status) 改为 "完成"   注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  1015.                     {
  1016.                         bool ReValueAIUpdata = false;
  1017.                         //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
  1018.                         ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
  1019.                         if (ReValueAIUpdata == true)
  1020.                         {
  1021.                             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:废旧物资工作流活动完成!');top.location.href='../Main.aspx';</script>");
  1022.                         }
  1023.                         else
  1024.                         {
  1025.                             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  1026.                         }
  1027.                     }
  1028.                 }
  1029.             }
  1030.         }
  1031.     }
  1032.     /// <summary>
  1033.     /// 起始活动.
  1034.     /// </summary>
  1035.     protected int ActivityIDGetByWFID(int WfId)
  1036.     {
  1037.         EtongZwf etongzwf = new EtongZwf();
  1038.         DataView dvActivity = etongzwf.GetActivityByWFID(WfId);
  1039.         if (dvActivity.Count != 0)
  1040.         {
  1041.             int activity = Convert.ToInt32(dvActivity[0][0].ToString().Trim());
  1042.             return activity;
  1043.         }
  1044.         else
  1045.             return 0;
  1046.     }
  1047.     /// <summary>
  1048.     /// 提交到上级部门用户申核
  1049.     /// </summary>
  1050.     protected void NextColonyRole(int ParentActID, int ParentRoleID, string showMessage, string nextCheckDepartment,bool isMaster)
  1051.     {
  1052.         EtongZwf etongzwf = new EtongZwf();
  1053.         WFActInsInfo wfactinsinfo = null;
  1054.         if (isMaster == false)
  1055.         {
  1056.             wfactinsinfo = new WFActInsInfo(-1, ParentActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  1057.                                                                      0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, WorkFolw.GetOrgOpRoleType(ParentRoleID), -1, ParentRoleID);
  1058.         }
  1059.         else
  1060.         {
  1061.             CheckUserInfo cui = null;
  1062.             if (Session["checkuserinfo"] != null)
  1063.             {
  1064.                 cui = (CheckUserInfo)Session["checkuserinfo"];
  1065.             }
  1066.             string type = ProjectImplment.GetEmpType(cui.EmpID);
  1067.             wfactinsinfo = new WFActInsInfo(-1, ParentActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  1068.                                                                 0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, type, -1, ParentRoleID);
  1069.         }
  1070.         int ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
  1071.         if (ReActInsValue > 0)
  1072.         {
  1073.             //DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
  1074.             //if (dvRoleName.Count != 0)
  1075.             //{
  1076.             //InitializePage();        //初始化当前页面
  1077.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:" + showMessage + ",转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
  1078.             //}
  1079.             //else
  1080.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!');</script>");
  1081.         }
  1082.         else
  1083.         {
  1084.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
  1085.         }
  1086.     }
  1087.     protected void BT_Untread_Click(object sender, ImageClickEventArgs e)
  1088.     {
  1089.         if (IsUntread == false)
  1090.         {
  1091.             Common.RunScript(this.Page, "起始活动不可回退!");
  1092.             return;
  1093.         }
  1094.         else
  1095.         {
  1096.             EtongZwf etongzwf = new EtongZwf();
  1097.             bool ReActInsValue = false;
  1098.             string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  1099.             ActID = Convert.ToInt32(ActIDtxt);
  1100.             //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ActID.ToString() + "');</script>");
  1101.             //return;
  1102.             ReActInsValue = etongzwf.WFActInsUpdata(ActID, userid, 3);
  1103.             if (ReActInsValue == true)
  1104.             {
  1105.                 //产生回退活动事例
  1106.                 // 注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
  1107.                 int ReActInsValue2 = 0;
  1108.                 DataView dvAct = etongzwf.ActivityGetByActInsId(ActID);
  1109.                 // DataView dvAct = etongzwf.ColonyUserGetByAct(ActivityID);    
  1110.                 int PreviousActID = -1;
  1111.                 int PreviousUserID = -1;
  1112.                 int PreviousRoleID = -1;
  1113.                 if (dvAct != null)
  1114.                 {
  1115.                     PreviousActID = Convert.ToInt16(dvAct[0]["PreviousActID"].ToString().Trim());
  1116.                     PreviousUserID = Convert.ToInt16(dvAct[0]["PreviousUserID"].ToString().Trim());
  1117.                     PreviousRoleID = Convert.ToInt16(dvAct[0]["PreviousRoleID"].ToString().Trim());
  1118.                 }
  1119.                 WFActInsInfo wfactinsinfo2 = new WFActInsInfo(-1, PreviousActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  1120.                                                                     2, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, "", PreviousUserID, PreviousRoleID);
  1121.                 ReActInsValue2 = etongzwf.WFActInsADD(wfactinsinfo2);
  1122.                 if (ReActInsValue2 != 0)
  1123.                     ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退成功!');top.location.href='../Main.aspx';</script>");
  1124.                 else
  1125.                     ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退失败!');top.location.href='../Main.aspx';</script>");
  1126.             }
  1127.         }
  1128.     }
  1129.     protected void BT_Revoke_Click(object sender, ImageClickEventArgs e)
  1130.     {
  1131.         string sql = "update tb_WF_ACtIns set Status=4  where [WfInstanceID]=" + WFInstanceID + " and [ActivityID]=" + ActivityID;
  1132.         string sql1 = "update [tb_PrjOldMat] set [Status]=3 where [MatID]=" + this.MatID;
  1133.         if (SqlServer.RunSql(sql) && SqlServer.RunSql(sql1))
  1134.         {
  1135.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作成功!');top.location.href='../Main.aspx';</script>");
  1136.         }
  1137.         else
  1138.         {
  1139.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作失败!');top.location.href='../Main.aspx';</script>");
  1140.         }
  1141.     }
  1142.     //******************************************************得到指定活动的文档名称*************************************************************
  1143.     protected string GetDocumentFileName(int activityid)
  1144.     {
  1145.         string sql = "select [FName] from [tb_Colony_FileName1] a,[tb_Sys_FileName] b where a.[FID]=b.[FID] and [ActivityID]=" + activityid;
  1146.         string filename = "";
  1147.         //string tempfilename = "";
  1148.         DataView dv = SqlServer.GetDataView(sql);
  1149.         if (dv != null && dv.Count > 0)
  1150.         {
  1151.             filename = dv[0]["FName"].ToString();
  1152.             //if (filename.Length >= 2)
  1153.                // tempfilename = filename.Substring(filename.LastIndexOf("\\") + 2);
  1154.         }
  1155.         return filename;
  1156.     }
  1157.     protected string GetDocumentFileName(int activityid, int index)
  1158.     {
  1159.         string sql = "select [FName] from [tb_Colony_FileName1] a,[tb_Sys_FileName] b where a.[FID]=b.[FID] and [ActivityID]=" + activityid;
  1160.         string filename = "";
  1161.       //  string tempfilename = "";
  1162.         DataView dv = SqlServer.GetDataView(sql);
  1163.         if (dv != null && dv.Count > 0)
  1164.         {
  1165.             filename = dv[index]["FName"].ToString();
  1166.             //if (filename.Length >= 2)
  1167.               //  tempfilename = filename.Substring(filename.LastIndexOf("\\") + 2);
  1168.         }
  1169.         return filename;
  1170.     }
  1171.     ////******************************************************用最新日期生成最新文档*************************************************************
  1172.     protected string MakeNewFileNameWithDate(string filename)
  1173.     {
  1174.         if (filename.Length > 0)
  1175.         {
  1176.             string[] a = filename.Split('.');
  1177.             return a[0] + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + "." + a[1];
  1178.         }
  1179.         else
  1180.             return "";
  1181.     }
  1182.     ////******************************************************找到员工类型的汇总文档*************************************************************
  1183.     protected string GetEmpTypeDocument()
  1184.     {
  1185.         string EmpTypeFileName = "";
  1186.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  1187.         CheckUserInfo cui = null;
  1188.         if (Session["checkuserinfo"] != null)
  1189.         {
  1190.             cui = (CheckUserInfo)Session["checkuserinfo"];
  1191.         }
  1192.         string EmpType = ProjectImplment.GetEmpType(cui.EmpID);
  1193.         string filename = GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
  1194.         if (filename != "")
  1195.         {
  1196.             string xmlFileName = path + "\DocTemplateMat\" + filename;
  1197.             XML xml = new XML(xmlFileName);
  1198.             ArrayList list = xml.ReadNode("Documents", EmpType, true);
  1199.             if (list.Count > 0)
  1200.             {
  1201.                 DocumentNode node = (DocumentNode)list[0];
  1202.                 EmpTypeFileName = node.FileName;
  1203.             }
  1204.         }
  1205.         return EmpTypeFileName;
  1206.     }
  1207.     protected void IB_Collect_Click(object sender, ImageClickEventArgs e)
  1208.     {
  1209.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  1210.         CheckUserInfo cui = null;
  1211.         if (Session["checkuserinfo"] != null)
  1212.         {
  1213.             cui = (CheckUserInfo)Session["checkuserinfo"];
  1214.         }
  1215.         com.etong.DAL.FC.EtongFlyChouWFPrj etongFlyChouWFPrj = new com.etong.DAL.FC.EtongFlyChouWFPrj();
  1216.         etongFlyChouWFPrj.sID = this.actinstanceid;
  1217.         etongFlyChouWFPrj.PrjID = this.MatID;
  1218.         etongFlyChouWFPrj.wID = this.wfid;
  1219.         etongFlyChouWFPrj.iStatus = 5;
  1220.         etongFlyChouWFPrj.sBlockReason = WorkFolw.GetBlockReason(this.actinstanceid);
  1221.         if (etongFlyChouWFPrj.CheckUpActCompleteSort() == false)
  1222.         {
  1223.             Common.RunScript(this.Page, "工作流上级所属(同类型的)活动未完成,不能汇总文档");
  1224.             return;
  1225.         }
  1226.         else
  1227.         {
  1228.             string EmpType = ProjectImplment.GetEmpType(cui.EmpID);
  1229.             string orgfilename = GetDocumentFileName(this.ActivityID);
  1230.             string filename = "型物资汇总表";
  1231.             /*switch (EmpType)
  1232.             {
  1233.                 case "1": filename = "科技" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
  1234.                     break;
  1235.                 case "2": filename = "生产" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
  1236.                     break;
  1237.                 case "3": filename = "营销" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
  1238.                     break;
  1239.             }*/
  1240.             filename = EmpType + "-" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second;
  1241.             string checker = cui.EmpName;
  1242.             string time = DateTime.Now.ToString();
  1243.             string xmlFileName = path + "\DocTemplateMat\" + GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
  1244.             XML xml = new XML(xmlFileName);
  1245.             XML jcXml = new XML(path + "\DocTemplateMat\" + GetPrjOldMatInfo(this.MatID)[0]["DocumentXML"].ToString());
  1246.             ArrayList list = jcXml.ReadNode("Documents", EmpType, true);
  1247.             string[] filecopy = new string[list.Count];
  1248.             if (filecopy.Length > 0)
  1249.             {
  1250.                 for (int i = 0; i < filecopy.Length; i++)
  1251.                 {
  1252.                     DocumentNode documentNode = (DocumentNode)list[i];
  1253.                     filecopy[i] = path + "\DocTemplateMat\" + documentNode.FileName;
  1254.                 }
  1255.                 string[] houzhui = filecopy[0].Split('.');
  1256.                 MyDocMerger myDocMerger = new MyDocMerger();
  1257.                 string orgDocName = path + "\DocTemplateMat\" + filename + "." + houzhui[1];
  1258.                 this.txt_ZgHZFName.Value = filename + "." + houzhui[1];
  1259.                 if (xml.AddXmlNode(new DocumentNode(this.txt_ZgHZFName.Value, checker, time, EmpType)))
  1260.                 {
  1261.                     if (Util.Copyfile(path + "\" + orgfilename, orgDocName))
  1262.                     {
  1263.                         /*------------------------文档汇总----------------------*/
  1264.                         myDocMerger.MergeDocArray(orgDocName, filecopy, orgDocName);
  1265.                         /*---------------改变按钮组为可用状态-------------------*/
  1266.                         this.TB_OpenDocument_ZGdFName.Enabled = true;
  1267.                         this.TB_OpenDocument_ZgHZFName.Enabled = true;
  1268.                         this.TB_OpenDocument_ZGxFName.Enabled = true;
  1269.                         this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
  1270.                         this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
  1271.                         Common.RunScript(this.Page, "汇总成功!");
  1272.                         this.IsCollect = true;
  1273.                         this.IB_Collect.Enabled = false;
  1274.                     }
  1275.                     else
  1276.                     {
  1277.                         Common.RunScript(this.Page, "打开文档失败!");
  1278.                     }
  1279.                 }
  1280.                 else
  1281.                 {
  1282.                     Common.RunScript(this.Page, "汇总失败,请检查相关数据!");
  1283.                 }
  1284.             }
  1285.             else
  1286.             {
  1287.                 Common.RunScript(this.Page, "没有文档,不能汇总!");
  1288.             }
  1289.         }
  1290.     }
  1291.     //
  1292.     protected bool CheckEmpTypeIsEqualBlockReason()
  1293.     {
  1294.         bool flag = false;
  1295.         int wfid = -1;
  1296.         int actid = -1;
  1297.         CheckUserInfo cui = null;
  1298.         if (Session["checkuserinfo"] != null)
  1299.         {
  1300.             cui = (CheckUserInfo)Session["checkuserinfo"];
  1301.         }
  1302.         string type = ProjectImplment.GetEmpType(cui.EmpID);
  1303.         string sql = "select * from [tb_WF_Instance] where [Status]=5 and [PrjID]=" + this.MatID;
  1304.         DataView dv = SqlServer.GetDataView(sql);
  1305.         if (dv != null && dv.Count > 0)
  1306.         {
  1307.             wfid = Convert.ToInt32(dv[0]["WFInstanceID"].ToString());
  1308.             EtongZwf etongzwf = new EtongZwf();
  1309.             dv = etongzwf.ColonyUserGetByActId(ActivityID);
  1310.             if (dv.Count > 0)
  1311.             {
  1312.                 actid = Convert.ToInt32(dv[0]["ParentActID"].ToString().Trim());
  1313.                 sql = "select [BlockReason] from [tb_WF_ActIns] where [ActivityID]=" + actid + " and [WfInstanceID]=" + wfid;
  1314.                 dv = SqlServer.GetDataView(sql);
  1315.                 if (dv.Count > 0)
  1316.                 {
  1317.                     if (type == dv[0]["BlockReason"].ToString())
  1318.                         flag = true;
  1319.                 }
  1320.             }
  1321.         }
  1322.         return flag;
  1323.     }
  1324. }