OldMaterialManagement.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:80k
源码类别:
.net编程
开发平台:
C#
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using com.etong.DAL;
- using com.etong.DBUtility;
- using com.etong.Inform;
- using com.etong.BusinessRule;
- using com.etong.BusinessRule.Zwf;
- using com.etong.Model;
- using com.etong.Utility;
- using DocMergerComponent;
- public partial class Workflow_OldMaterialManagement : System.Web.UI.Page
- {
- protected int userid = -1;
- protected int wfid = -1;//当前工作流ID
- protected int MustChooseItem = -1;//必选项
- protected int ActivityID = -1;//活动ID
- protected int WFInstanceID = -1;//工作流实例ID
- protected int actinstanceid = -1;//活动实例ID
- protected int ActID = -1;//活动实例ID
- protected bool IsUntread = true;//是否回退
- protected int shuntFlag = 0;//分流标志(0、不分流;1、小件;2、大件;)
- protected int MatID = -1;
- protected bool IsCollect = false;
- protected string rolestr()
- {
- string rolestr = "";
- if (userid != -1)
- {
- EtongZwf etongzwf = new EtongZwf();
- DataView dvrole = etongzwf.RoleGetByID(userid);
- for (int i = 0; i < dvrole.Count; i++)
- {
- rolestr = rolestr + dvrole[i][0].ToString().Trim() + ",";
- }
- }
- return rolestr;
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- //------------------------------------------变量定义-----------------------------------------------
- DataView dv = null;
- CheckUserInfo cui = null;
- if (Request.QueryString["MustChooseItem"] != null)
- {
- string MustChooseItemtxt = "";
- MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
- MustChooseItem = Convert.ToInt16(MustChooseItemtxt);
- }
- string ActivityIDtxt = "";
- if (Request.QueryString["ActivityID"] != null)
- {
- ActivityIDtxt = Request.QueryString["ActivityID"].ToString().Trim();
- ActivityID = Convert.ToInt32(ActivityIDtxt);
- }
- string WFInstanceIDtxt = "";
- if (Request.QueryString["WFInstanceID"] != null)
- {
- WFInstanceIDtxt = Request.QueryString["WFInstanceID"].ToString().Trim();
- }
- string WFIDtxt = "";
- if (Request.QueryString["WFID"] != null)
- {
- WFIDtxt = Request.QueryString["WFID"].ToString().Trim();
- wfid = Convert.ToInt16(WFIDtxt);
- }
- if (Request.QueryString["ActID"] != null)
- {
- actinstanceid = Convert.ToInt32(Request.QueryString["ActID"].ToString());
- }
- //----------------------------------------对象定义--------------------------------------------------
- if (Session["checkuserinfo"] != null)
- {
- cui = (CheckUserInfo)Session["checkuserinfo"];
- userid = cui.UserID;
- }
- if (ActivityIDtxt != "" && WFInstanceIDtxt != "")
- {
- if (Convert.ToInt32(ActivityIDtxt) != -1 && Convert.ToInt32(WFInstanceIDtxt) != -1)
- {
- WFInstanceID = Convert.ToInt32(WFInstanceIDtxt);
- string sql = "select * from [tb_WF_Instance] where [WFInstanceID]=" + WFInstanceID;
- dv = SqlServer.GetDataView(sql);
- if (dv.Count > 0)
- {
- wfid = Convert.ToInt32(dv[0][8].ToString().Trim());
- this.MatID = Convert.ToInt32(dv[0][9].ToString().Trim());
- }
- }
- }
- string path = Server.MapPath("doc").Replace("\", "\\"); //获取项目所在路径
- int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
- switch (MustChooseItem)
- {
- /*==============================================================================================
- *
- * 废旧物资开始
- *
- *=============================================================================================*/
- case 69:
- SetAllPanelsVisibility(true, false, false, false, false, false, false, false, false, false, true);
- IsUntread = false;//起始活动不可回退
- break;
- /*==============================================================================================
- *
- * 基层单位上报废旧物资
- *
- *=============================================================================================*/
- case 70:
- SetAllPanelsVisibility(true, true, false, false, false, false, false, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- string filename_MaterialRemove = GetDocumentFileName(this.ActivityID);
- this.txt_MaterialRemove.Value = MakeNewFileNameWithDate(filename_MaterialRemove);
- /*-------------------------------文档拷贝-------------------------------*/
- if (!(Util.Copyfile(path + "\" + filename_MaterialRemove, path + "\DocTemplateMat\" + this.txt_MaterialRemove.Value)))
- {
- Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- return;
- }
- this.ShowOperatorAndTime_ReportOldMaterial.InnerHtml = "<div align='center'>上报人/上报时间:<font color='red'> " + cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + "</font></div>";
- this.BT_OpenDocument_MaterialRemove.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialRemove').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 主管部门废旧物资汇总
- *
- *=============================================================================================*/
- case 77:
- SetAllPanelsVisibility(true, true, true, false, false, false, false, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZgHZFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Enabled = false;
- this.IB_Collect.Visible = true;
- string filename_DJ = "废旧物资汇总大件表" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
- string filename_XJ = "废旧物资汇总表" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
- this.txt_ZGxFName.Value = filename_XJ;
- this.txt_ZGdFName.Value = filename_DJ;
- /*-------------------------------文档(大件、小件文档)拷贝-------------------------------*/
- if (!(Util.Copyfile(path + "\大件汇总表.doc", path + "\DocTemplateMat\" + filename_DJ) && Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + filename_XJ)))
- {
- Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- return;
- }
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 废旧物资大件
- *
- *=============================================================================================*/
- case 71:
- SetAllPanelsVisibility(true, false, true, false, false, false, false, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_OpenDocument_ZGxFName.Enabled = false;
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 废旧物资小件
- *
- *=============================================================================================*/
- case 72:
- SetAllPanelsVisibility(true, false, true, false, false, false, false, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 物资公司收集汇总材料
- *
- *=============================================================================================*/
- case 73:
- SetAllPanelsVisibility(true, false, true, true, false, false, false, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_WZjIdea.Text = "同意";
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 物资公司汇总
- *
- *=============================================================================================*/
- case 78:
- SetAllPanelsVisibility(true, false, true, true, true, false, false, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_WZjIdea.Enabled = false;
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- string filename_MaterialCollect = "物资汇总表.doc";
- this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
- if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
- {
- Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- return;
- }
- this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 编写废旧物资
- *
- *=============================================================================================*/
- case 79:
- SetAllPanelsVisibility(true, false, true, true, false, true, false, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_WZjIdea.Enabled = false;
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- string filename_OldMaterial = GetDocumentFileName(this.ActivityID);
- this.txt_WZqFName.Value =MakeNewFileNameWithDate (filename_OldMaterial );
- if (!(Util.Copyfile(path + "\" + filename_OldMaterial, path + "\DocTemplateMat\" + this.txt_WZqFName.Value)))
- {
- Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- return;
- }
- this.BT_OpenDocument_OldMaterialBill.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_WZqFName').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 工程管理办公室审核
- *
- *=============================================================================================*/
- case 75:
- SetAllPanelsVisibility(true, false, true, true, true, false, true, false, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_GcglIdea.Text = "同意";
- this.TB_WZjIdea.Enabled = false;
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- //string filename_MaterialCollect = "物资汇总表.doc";
- //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
- //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
- //{
- // Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- // return;
- //}
- this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
- this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 公司领导审核
- *
- *=============================================================================================*/
- case 74:
- SetAllPanelsVisibility(true, false, true, true, true, false, true, true, false, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_GcglIdea.Enabled = false;
- this.TB_GSldIdea.Text = "同意";
- this.TB_WZjIdea.Enabled = false;
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- //string filename_MaterialCollect = "物资汇总表.doc";
- //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
- //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
- //{
- // Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- // return;
- //}
- this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
- this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 物资公司审核
- *
- *=============================================================================================*/
- case 76:
- SetAllPanelsVisibility(true, false, true, true, true, false, true, true, true, false, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_GcglIdea.Enabled = false;
- this.TB_GSldIdea.Enabled = false;
- this.TB_WZjIdea.Enabled = false;
- this.TB_WZfIdea.Text = "同意";
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- //string filename_MaterialCollect = "物资汇总表.doc";
- //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
- //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
- //{
- // Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- // return;
- //}
- this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
- this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
- }
- break;
- /*==============================================================================================
- *
- * 竣工材料存档
- *
- *=============================================================================================*/
- case 100:
- SetAllPanelsVisibility(true, false, true, true, true, false, true, true, true, true, true);
- if (!this.Page.IsPostBack)
- {
- BindPrjOldMatInfoToPageControls();
- this.TB_GcglIdea.Enabled = false;
- this.TB_GSldIdea.Enabled = false;
- this.TB_WZjIdea.Enabled = false;
- this.TB_WZfIdea.Enabled = false;
- this.TB_ZGgIdea.Text="同意";
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGxFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Enabled = false;
- this.TB_OpenDocument_ZGxFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGxFName').value,'" + cui.EmpName + "');");
- this.TB_OpenDocument_ZGdFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZGdFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZGdFName').value,'" + cui.EmpName + "');");
- //string filename_MaterialCollect = "物资汇总表.doc";
- //this.txt_MaterialCollect.Value = MakeNewFileNameWithDate(filename_MaterialCollect);
- //if (!(Util.Copyfile(path + "\小件汇总表.doc", path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value)))
- //{
- // Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
- // return;
- //}
- this.BT_OpenDocument_MaterialCollect.Text = "浏览电子文档";
- this.BT_OpenDocument_MaterialCollect.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_MaterialCollect').value,'" + cui.EmpName + "');");
- }
- break;
- }
- if (!this.Page.IsPostBack)
- {
- CreateYearToBindDropDownList_Year();
- this.UpdateMaterialName.Attributes.Add("href", "javascript:winOpen(" + this.MatID + ",'" + GetPrjOldMatInfo(this.MatID)[0]["MatName"].ToString() + "')");
- }
- }
- private void BindPrjOldMatInfoToPageControls()
- {
- DataView dv = GetPrjOldMatInfo(this.MatID);
- if (dv.Count > 0)
- {
- this.DDL_Year.SelectedValue = dv[0]["nf"].ToString();
- this.DDL_Year.Enabled = false;
- this.DDL_Quarter.SelectedValue = dv[0]["jd"].ToString();
- this.DDL_Quarter.Enabled = false;
- //this.txt_MaterialRemove.Value = dv[0][""].ToString();
- this.ShowOperatorAndTime_ReportOldMaterial.InnerHtml = "<div align='center'>上报人/上报时间:<font color='red'> " + dv[0]["JcTransactor"].ToString() + "</font></div>";
- this.txt_ZgHZFName.Value = GetEmpTypeDocument();
- this.txt_ZGdFName.Value = dv[0]["ZGdFName"].ToString();
- this.txt_ZGxFName.Value = dv[0]["ZGxFName"].ToString();
- this.ShowOperatorAndTime_ZgTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["ZgTransactor"].ToString() + "</font></div>";
- this.TB_WZjIdea.Text = dv[0]["WZjIdea"].ToString();
- this.ShowOperatorAndTime_WZjTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["WZjTransactor"].ToString() + "</font></div>";
- this.txt_MaterialCollect.Value = dv[0]["WZhFName"].ToString();
- this.ShowOperatorAndTime_WZhTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["WZhTransactor"].ToString() + "</font></div>";
- this.txt_WZqFName.Value = dv[0]["WZqFName"].ToString();
- this.ShowOperatorAndTime_WZqTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["WZqTransactor"].ToString() + "</font></div>";
- this.TB_GcglIdea.Text = dv[0]["GcglIdea"].ToString();
- this.ShowOperatorAndTime_GcglTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["GcglTransactor"].ToString() + "</font></div>";
- this.TB_GSldIdea.Text = dv[0]["GSldIdea"].ToString();
- this.ShowOperatorAndTime_GSldTansactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["GSldTansactor"].ToString() + "</font></div>";
- this.TB_WZfIdea.Text = dv[0]["WZfIdea"].ToString();
- this.ShowOperatorAndTime_WZfTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["WZfTransactor"].ToString() + "</font></div>";
- this.TB_ZGgIdea.Text = dv[0]["ZGgIdea"].ToString();
- this.ShowOperatorAndTime_ZGgTransactor.InnerHtml = "<div align='center'>审核人/审核时间:<font color='red'> " + dv[0]["ZGgTransactor"].ToString() + "</font></div>";
- }
- }
- private DataView GetPrjOldMatInfo(int matid)
- {
- string sql = "select * from [tb_PrjOldMat] where [MatID]=" + matid;
- DataView dv = SqlServer.GetDataView(sql);
- return dv;
- }
- private void SetAllPanelsVisibility(
- bool flag_BeginOldMaterialManagement, bool flag_ReportOldMaterial, bool flag_MasterDepartCollectOldMaterial, bool flag_CollectOldMaterial,
- bool flag_MaterialCompanyCollect, bool flag_EditOldMaterialBill, bool flag_ProjectManagementOfficeCheck, bool flag_CompanyLeaderCheck,
- bool flag_MaterialCompanyCheck, bool flag_SaveCompleteMaterial, bool flag_Button)
- {
- this.Panel_BeginOldMaterialManagement.Visible = flag_BeginOldMaterialManagement;
- this.Panel_ReportOldMaterial.Visible = flag_ReportOldMaterial;
- this.Panel_MasterDepartCollectOldMaterial.Visible = flag_MasterDepartCollectOldMaterial;
- this.Panel_CollectOldMaterial.Visible = flag_CollectOldMaterial;
- this.Panel_MaterialCompanyCollect.Visible = flag_MaterialCompanyCollect;
- this.Panel_EditOldMaterialBill.Visible = flag_EditOldMaterialBill;
- this.Panel_ProjectManagementOfficeCheck.Visible = flag_ProjectManagementOfficeCheck;
- this.Panel_CompanyLeaderCheck.Visible = flag_CompanyLeaderCheck;
- this.Panel_MaterialCompanyCheck.Visible = flag_MaterialCompanyCheck;
- this.Panel_SaveCompleteMaterial.Visible = flag_SaveCompleteMaterial;
- this.Panel_Button.Visible = flag_Button;
- }
- private void CreateYearToBindDropDownList_Year()
- {
- int year = DateTime.Now.Year;
- for (int i = year ; i >= year-10; i--)
- {
- this.DDL_Year.Items.Add(new ListItem(i.ToString(), i.ToString()));
- }
- }
- protected void BT_Pass_Click(object sender, ImageClickEventArgs e)
- {
- if (Request.QueryString["MustChooseItem"] != null)
- {
- string MustChooseItemtxt = "";
- MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
- MustChooseItem = Convert.ToInt16(MustChooseItemtxt);
- }
- string path = Server.MapPath("doc").Replace("\", "\\"); //获取项目所在路径
- CheckUserInfo cui = (CheckUserInfo)Session["checkuserinfo"];
- string sql = "";
- switch (MustChooseItem)
- {
- /*==============================================================================================
- *
- * 废旧物资开始(审核通过code)
- *
- *=============================================================================================*/
- case 69:
- int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
- if (tempStatus == 2)
- {
- WFInstADD("您已审核通过!",false);
- }
- else
- {
- string xmlFileName = "CollectDocument" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".xml";
- string year = this.DDL_Year.SelectedValue;
- string quarter = this.DDL_Quarter.SelectedValue;
- sql = "update [tb_PrjOldMat] set [nf]='" + year + "',[jd]='" + quarter + "',[DocumentXML]='" + xmlFileName + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- XML xml = new XML();
- if (xml.CreateXMLDocument(path + "\DocTemplateMat\" + xmlFileName))
- WorkFlowOperation(this.MatID,false);
- else
- Common.RunScript(this.Page, "XML文档创建失败,请检查相关设置");
- }
- }
- break;
- /*==============================================================================================
- *
- * 基层单位上报废旧物资
- *
- *=============================================================================================*/
- case 70:
- //string jcTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- string jcTransactor = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [JcTransactor]='" + jcTransactor + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- string xmlFileName = GetPrjOldMatInfo(this.MatID)[0]["DocumentXML"].ToString();
- string filename = this.txt_MaterialRemove.Value;
- string checker = cui.EmpName;
- string time = DateTime.Now.ToString();
- string type = ProjectImplment.GetEmpType(cui.EmpID);
- XML xml1 = new XML(path + "\DocTemplateMat\" + xmlFileName);
- xml1.AddXmlNode(new DocumentNode(filename, checker, time, type));//将基层上报的文档信息写入XML文档
- string xmlMasterFileName = GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
- if (xmlMasterFileName == "")//如果XML文档不存在,则创建,否则不创建
- {
- xmlMasterFileName = "MasterDepartDocument" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".xml";
- sql = "update [tb_PrjOldMat] set [ZgHZFName]='" + xmlMasterFileName + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- if (xml1.CreateXMLDocument(path + "\DocTemplateMat\" + xmlMasterFileName) == false)
- {
- Common.RunScript(this.Page, "XML文档创建失败,请检查相关设置");
- }
- }
- }
- if (CheckEmpTypeIsEqualBlockReason() == false)
- {
- WFInstADD("您已审核通过!",true);
- }
- else
- {
- WorkFolw workflow = new WorkFolw();
- if (workflow.WFActInsUpdata(actinstanceid, 1, userid))
- {
- EtongZwf etongzwf = new EtongZwf();
- DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
- int ParentRoleID = -1;
- if (dv.Count > 0)
- {
- ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
- ProjectImplment pi = new ProjectImplment();
- DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
- string nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:您已经审核通过,转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
- }
- }
- }
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- break;
- /*==============================================================================================
- *
- * 主管部门废旧物资汇总
- *
- *=============================================================================================*/
- case 77:
- //if (this.IsCollect == false)
- if ((this.TB_OpenDocument_ZGdFName.Enabled == false) && (this.TB_OpenDocument_ZgHZFName.Enabled == false) && (this.TB_OpenDocument_ZGxFName.Enabled == false))
- {
- Common.RunScript(this.Page, "您尚未汇总废旧物资,不能审核通过!");
- }
- else
- {
- string zgTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- //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;
- sql = "update [tb_PrjOldMat] set [ZgTransactor]='" + zgTransactor + "',[ZGxFName]='" + this.txt_ZGxFName.Value + "',[ZGdFName]='" + this.txt_ZGdFName.Value + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- WorkFlowOperation(this.MatID,true);
- }
- }
- break;
- /*==============================================================================================
- *
- * 废旧物资大件
- *
- *=============================================================================================*/
- case 71:
- WFInstADD("您已审核通过!",true);
- break;
- /*==============================================================================================
- *
- * 废旧物资小件
- *
- *=============================================================================================*/
- case 72:
- WFInstADD("您已审核通过!",true);
- break;
- /*==============================================================================================
- *
- * 物资公司收集汇总材料
- *
- *=============================================================================================*/
- case 73:
- string WZjIdea = this.TB_WZjIdea.Text.Trim();
- string WZjTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [WZjIdea]='" + WZjIdea + "',[WZjTransactor]='" + WZjTransactor + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- WorkFlowOperation(this.MatID,false);
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- break;
- /*==============================================================================================
- *
- * 物资公司汇总
- *
- *=============================================================================================*/
- case 78:
- /*com.etong.DAL.FC.EtongFlyChouWFPrj etongFlyChouWFPrj = new com.etong.DAL.FC.EtongFlyChouWFPrj();
- etongFlyChouWFPrj.sID = this.actinstanceid;
- etongFlyChouWFPrj.PrjID = this.MatID;
- etongFlyChouWFPrj.wID = this.wfid;
- etongFlyChouWFPrj.iStatus = 5;
- //etongFlyChouWFPrj.sBlockReason = WorkFolw.GetBlockReason(this.actinstanceid);
- if (etongFlyChouWFPrj.CheckUpActComplete() == false)
- {
- Common.RunScript(this.Page, "工作流上级所属活动未完成,不能审核通过!");
- }
- else
- {*/
- //string path = Server.MapPath("doc").Replace("\", "\\"); //获取项目所在路径
- string xmlDoc = path + "\DocTemplateMat\" + GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
- XML xmlxml = new XML(xmlDoc);
- ArrayList list = xmlxml.ReadNode("Documents", "",false);
- string[] filename1 = new string[list.Count];
- for (int i = 0; i < filename1.Length; i++)
- {
- DocumentNode node = (DocumentNode)list[i];
- filename1[i] = path + "\DocTemplateMat\" + node.FileName;
- }
- MyDocMerger myDocMeger = new MyDocMerger();
- string orgDocName = path + "\DocTemplateMat\" + this.txt_MaterialCollect.Value;
- myDocMeger.MergeDocArray(orgDocName, filename1, orgDocName);
- string WZhFName = this.txt_MaterialCollect.Value;
- string WZhTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [WZhFName]='" + WZhFName + "',[WZhTransactor]='" + WZhTransactor + "',[hz]='2' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- WFInstADD("您已审核通过!",false);
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- // }
- break;
- /*==============================================================================================
- *
- * 编写废旧物资
- *
- *=============================================================================================*/
- case 79:
- string WZqFName = this.txt_WZqFName.Value;
- string WZqTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [WZqFName]='" + WZqFName + "',[WZqTransactor]='" + WZqTransactor + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- WFInstADD("您已审核通过!",false);
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- break;
- /*==============================================================================================
- *
- * 工程管理办公室审核
- *
- *=============================================================================================*/
- case 75:
- string GcglIdea = this.TB_GcglIdea.Text;
- string GcglTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [GcglIdea]='" + GcglIdea + "',[GcglTransactor]='" + GcglTransactor + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- WFInstADD("您已审核通过!",false);
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- break;
- /*==============================================================================================
- *
- * 公司领导审核
- *
- *=============================================================================================*/
- case 74:
- string GSldIdea = this.TB_GSldIdea.Text;
- string GSldTansactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [GSldIdea]='" + GSldIdea + "',[GSldTansactor]='" + GSldTansactor + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- WFInstADD("您已审核通过!",false);
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- break;
- /*==============================================================================================
- *
- * 物资公司审核
- *
- *=============================================================================================*/
- case 76:
- string WZfIdea = this.TB_WZfIdea.Text;
- string WZfTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [WZfIdea]='" + WZfIdea + "',[WZfTransactor]='" + WZfTransactor + "' where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- // WFInstADD("您已审核通过!",false);
- WorkFlowOperation(this.MatID, false);
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- break;
- /*==============================================================================================
- *
- * 竣工材料存档
- *
- *=============================================================================================*/
- case 100:
- string ZGgIdea = this.TB_ZGgIdea.Text;
- string ZGgTransactor = cui.EmpName + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute;
- sql = "update [tb_PrjOldMat] set [ZGgIdea]='" + ZGgIdea + "',[ZGgTransactor]='" + ZGgTransactor + "',[status]=2 where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql))
- {
- WFInstADD("您已审核通过!",false);
- }
- else
- {
- Common.RunScript(this.Page, "操作失败,请检查数据!");
- }
- break;
- }
- }
- /*============================================================对并发活动的特殊处理======================================================
- *
- * 工作流操作,分3步
- * 1.产生工作流实例纪录,注意matid必须真实存在
- * 2.更新当前活动实例状态 由WFInstADD中的WFActInsUpdata执行
- * 3.产生新的工作流实例纪录,即产生下一个活动实例并提交到下一个部门的用户申核,由NextColonyRole操作完成
- *
- *=====================================================================================================================================*/
- protected void WorkFlowOperation(int matid,bool isMaster)
- {
- EtongZwf etongzwf = new EtongZwf();
- ProjectImplment projectImplment = new ProjectImplment();
- string sql = " select * from [tb_WF_Instance] where [Status]=5 and [PrjID]=" + this.MatID;
- DataView dv = SqlServer.GetDataView(sql);
- if (dv.Count == 0)//如果实例存在则不添加
- {
- DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
- //添加工作流实例 (将添加成功的constructid添加到工作流实例表里,注意是加到该表的PrjID字段中)
- WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
- userid, -1, -1, DateTime.Now, 5, SuccessDate, wfid,matid);
- int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
- //产生当前工作流实例ID
- WFInstanceID = ReInstanceValue;
- }
- dv = etongzwf.ColonyUserGetByActId(ActivityID);
- if (dv.Count > 0)
- {
- /*int ParentOrgID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
- //DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
- DataTable dataTable = projectImplment.GetDepartmentByID(ParentOrgID);
- if (dataTable.Rows.Count == 0)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!(请联系相关部门或系统管理员)');</script>");
- return;
- }*/
- /*DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
- //添加工作流实例 (将添加成功的constructid添加到工作流实例表里,注意是加到该表的PrjID字段中)
- WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
- userid, -1, -1, DateTime.Now, 5, SuccessDate, wfid, matid);
- int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
- //产生当前工作流实例ID
- WFInstanceID = ReInstanceValue;*/
- string nextCheckDepartment = "";
- for (int i = 0; i < dv.Count; i++)//找到所有部门
- {
- int ParentRoleID = Convert.ToInt32(dv[i]["ParentRoleID"].ToString().Trim());
- ProjectImplment pi = new ProjectImplment();
- //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
- DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
- nextCheckDepartment += dt.Rows[0]["OpName"].ToString()+"、";
- }
- for (int i = 0; i < dv.Count; i++)
- {
- int CurrentRoleID = Convert.ToInt32(dv[i]["CurrentRoleID"].ToString().Trim());
- int ParentActID = Convert.ToInt32(dv[i]["ParentActID"].ToString().Trim());
- int ParentRoleID = Convert.ToInt32(dv[i]["ParentRoleID"].ToString().Trim());
- if (WFInstanceID > 0)
- {
- WorkFolw workflow = new WorkFolw();
- string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
- ActID = Convert.ToInt32(ActIDtxt);
- bool returnvalue = false;
- //产生当前活动实例 如果是不是第一个活动,只需 修改 UserID 和 Status
- int ReActInsValue = 0;
- //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
- returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
- if (returnvalue == true)
- ReActInsValue = ActID;
- if (ReActInsValue > 0)
- {
- if (ParentActID != -1)
- {
- NextColonyRole(ParentActID, ParentRoleID, "您已审核通过", nextCheckDepartment,isMaster); //(ReActInsValue); //产生下一个活动实例并提交到下一个角色的用户申核
- }
- else // 不存在上级活动,将 活动状态(Status) 改为 "完成" 注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
- {
- bool ReValueAIUpdata = false;
- //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
- ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
- if (ReValueAIUpdata == true)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工完成!');top.location.href='../Main.aspx';</script>");
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
- }
- }
- }
- }
- }
- }
- }
- /*===========================================================================================================================
- *
- * 工作流操作,分3步
- * 1.产生工作流实例纪录,注意constructid必须真实存在
- * 2.更新当前活动实例状态 由WFInstADD中的WFActInsUpdata执行
- * 3.产生新的工作流实例纪录,即产生下一个活动实例并提交到下一个部门的用户申核,由NextColonyRole操作完成
- *
- *==========================================================================================================================*/
- protected void WorkFlowOperation(int matid, string showmessage,bool isMaster)
- {
- EtongZwf etongzwf = new EtongZwf();
- ProjectImplment projectImplment = new ProjectImplment();
- string sql = " select * from [tb_WF_Instance] where [Status]=2 and [PrjID]=" + this.MatID;
- DataView dv = SqlServer.GetDataView(sql);
- if (dv.Count == 0)//如果实例存在则不添加
- {
- DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
- //添加工作流实例 (将添加成功的constructid添加到工作流实例表里,注意是加到该表的PrjID字段中)
- WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
- userid, -1, -1, DateTime.Now, 5, SuccessDate, wfid,matid);
- int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
- //产生当前工作流实例ID
- WFInstanceID = ReInstanceValue;
- }
- dv = etongzwf.ColonyUserGetByActId(ActivityID);
- if (dv.Count > 0)
- {
- //int ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
- ////DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
- //DataTable dt = projectImplment.GetDepartmentByID(ParentRoleID);
- //if (dt.Rows.Count == 0)
- //{
- // ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!(请联系相关部门或系统管理员)');</script>");
- // return;
- //}
- //获取当前工作流启始活动 为什么要获取当前工作流启始活动?
- //DataView dvActID = etongzwf.GetActivityByWFID(wfid);
- //ActivityID = Convert.ToInt32(dvActID[0][0].ToString().Trim());
- if (WFInstanceID > 0)
- {
- WFInstADD(showmessage,isMaster);
- }
- }
- }
- /// <summary>
- /// 改变工作流活动实例状态
- /// </summary>
- ///
- protected void WFInstADD(string showMessage,bool isMaster)
- {
- if (WFInstanceID > 0)
- {
- com.etong.DAL.WorkFolw workflow = new com.etong.DAL.WorkFolw();
- DateTime SuccessDate = Convert.ToDateTime(DateTime.Now.ToShortDateString().Trim());
- EtongZwf etongzwf = new EtongZwf();
- DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
- // int CurrentActID = -1;
- int CurrentRoleID = -1;
- int ParentActID = -1;
- int ParentRoleID = -1;
- string nextCheckDepartment = null;
- if (dv.Count > 0)
- {
- if (dv.Count ==1)//不分流
- {
- CurrentRoleID = Convert.ToInt32(dv[0]["CurrentRoleID"].ToString().Trim());
- ParentActID = Convert.ToInt32(dv[0]["ParentActID"].ToString().Trim());
- ParentRoleID = Convert.ToInt32(dv[0]["ParentRoleID"].ToString().Trim());
- }
- else//分流
- {
- for (int i = 0; i < dv.Count; i++)
- {
- if (Convert.ToInt32(dv[i]["shuntflag"]) == shuntFlag)
- {
- CurrentRoleID = Convert.ToInt32(dv[i]["CurrentRoleID"].ToString().Trim());
- ParentActID = Convert.ToInt32(dv[i]["ParentActID"].ToString().Trim());
- ParentRoleID = Convert.ToInt32(dv[i]["ParentRoleID"].ToString().Trim());
- }
- }
- }
- }
- //产生当前活动实例 如果是不是第一个活动,只需 修改 UserID 和 Status
- int ReActInsValue = 0;
- int tempStatus = WorkFolw.GetCurrentActivityInstanceStatus(this.actinstanceid);//当前活动实例状态
- if (MustChooseItem == 69)//对起始活动的操作
- {
- if (tempStatus == 2)//回退活动
- {
- string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
- ActID = Convert.ToInt32(ActIDtxt);
- bool returnvalue = false;
- //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
- returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
- if (returnvalue == true)
- ReActInsValue = ActID;
- if (ReActInsValue > 0)
- {
- if (ParentActID != -1)
- {
- ProjectImplment pi = new ProjectImplment();
- //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
- DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
- nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
- NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment,isMaster); //(ReActInsValue); //产生下一个活动实例并提交到下一个角色的用户申核
- }
- else//不存在上级活动,将 活动状态(Status) 改为 "完成" 注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
- {
- bool ReValueAIUpdata = false;
- //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
- ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
- if (ReValueAIUpdata == true)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工完成!');top.location.href='../Main.aspx';</script>");
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
- }
- }
- }
- }
- else
- {
- WFActInsInfo wfactinsinfo = new WFActInsInfo(-1, ActivityID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
- 1, SuccessDate, WFInstanceID, "", userid, CurrentRoleID);
- ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
- ProjectImplment pi = new ProjectImplment();
- //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
- DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
- if (dt.Rows.Count > 0)
- {
- nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
- //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:计划下达成功,转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
- }
- NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment,isMaster);//提交给下一部门用户审核
- }
- }
- else//对不是起始活动的操作
- {
- string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
- ActID = Convert.ToInt32(ActIDtxt);
- bool returnvalue = false;
- //returnvalue = etongzwf.WFActInsUpdata(ActID, userid, 1);
- returnvalue = workflow.WFActInsUpdata(ActID, 1, userid);
- if (returnvalue == true)
- ReActInsValue = ActID;
- if (ReActInsValue > 0)
- {
- if (ParentActID != -1)
- {
- ProjectImplment pi = new ProjectImplment();
- //DataTable dt = pi.GetDepartmentByID(ParentRoleID);
- DataTable dt = pi.GetNextOperatorRole(ParentRoleID);
- nextCheckDepartment = dt.Rows[0]["OpName"].ToString();
- NextColonyRole(ParentActID, ParentRoleID, showMessage, nextCheckDepartment,isMaster); //(ReActInsValue); //产生下一个活动实例并提交到下一个角色的用户申核
- }
- else // 不存在上级活动,将 活动状态(Status) 改为 "完成" 注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
- {
- bool ReValueAIUpdata = false;
- //ReValueAIUpdata = etongzwf.WFActInsUpdata(ReActInsValue, userid, 1);
- ReValueAIUpdata = workflow.WFActInsUpdata(ReActInsValue, 1, userid);
- if (ReValueAIUpdata == true)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:废旧物资工作流活动完成!');top.location.href='../Main.aspx';</script>");
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 起始活动.
- /// </summary>
- protected int ActivityIDGetByWFID(int WfId)
- {
- EtongZwf etongzwf = new EtongZwf();
- DataView dvActivity = etongzwf.GetActivityByWFID(WfId);
- if (dvActivity.Count != 0)
- {
- int activity = Convert.ToInt32(dvActivity[0][0].ToString().Trim());
- return activity;
- }
- else
- return 0;
- }
- /// <summary>
- /// 提交到上级部门用户申核
- /// </summary>
- protected void NextColonyRole(int ParentActID, int ParentRoleID, string showMessage, string nextCheckDepartment,bool isMaster)
- {
- EtongZwf etongzwf = new EtongZwf();
- WFActInsInfo wfactinsinfo = null;
- if (isMaster == false)
- {
- wfactinsinfo = new WFActInsInfo(-1, ParentActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
- 0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, WorkFolw.GetOrgOpRoleType(ParentRoleID), -1, ParentRoleID);
- }
- else
- {
- CheckUserInfo cui = null;
- if (Session["checkuserinfo"] != null)
- {
- cui = (CheckUserInfo)Session["checkuserinfo"];
- }
- string type = ProjectImplment.GetEmpType(cui.EmpID);
- wfactinsinfo = new WFActInsInfo(-1, ParentActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
- 0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, type, -1, ParentRoleID);
- }
- int ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
- if (ReActInsValue > 0)
- {
- //DataView dvRoleName = etongzwf.RoleGetName(ParentRoleID);
- //if (dvRoleName.Count != 0)
- //{
- //InitializePage(); //初始化当前页面
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:" + showMessage + ",转到『" + nextCheckDepartment + "』申核处理!');top.location.href='../Main.aspx';</script>");
- //}
- //else
- //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目施工停滞,没有上级申核人!');</script>");
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作失败!');top.location.href='../Main.aspx';</script>");
- }
- }
- protected void BT_Untread_Click(object sender, ImageClickEventArgs e)
- {
- if (IsUntread == false)
- {
- Common.RunScript(this.Page, "起始活动不可回退!");
- return;
- }
- else
- {
- EtongZwf etongzwf = new EtongZwf();
- bool ReActInsValue = false;
- string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
- ActID = Convert.ToInt32(ActIDtxt);
- //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ActID.ToString() + "');</script>");
- //return;
- ReActInsValue = etongzwf.WFActInsUpdata(ActID, userid, 3);
- if (ReActInsValue == true)
- {
- //产生回退活动事例
- // 注:Status状态(0、正常;1、完成;2、回退;3、回退并完成;4、作废)
- int ReActInsValue2 = 0;
- DataView dvAct = etongzwf.ActivityGetByActInsId(ActID);
- // DataView dvAct = etongzwf.ColonyUserGetByAct(ActivityID);
- int PreviousActID = -1;
- int PreviousUserID = -1;
- int PreviousRoleID = -1;
- if (dvAct != null)
- {
- PreviousActID = Convert.ToInt16(dvAct[0]["PreviousActID"].ToString().Trim());
- PreviousUserID = Convert.ToInt16(dvAct[0]["PreviousUserID"].ToString().Trim());
- PreviousRoleID = Convert.ToInt16(dvAct[0]["PreviousRoleID"].ToString().Trim());
- }
- WFActInsInfo wfactinsinfo2 = new WFActInsInfo(-1, PreviousActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
- 2, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInstanceID, "", PreviousUserID, PreviousRoleID);
- ReActInsValue2 = etongzwf.WFActInsADD(wfactinsinfo2);
- if (ReActInsValue2 != 0)
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退成功!');top.location.href='../Main.aspx';</script>");
- else
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:回退失败!');top.location.href='../Main.aspx';</script>");
- }
- }
- }
- protected void BT_Revoke_Click(object sender, ImageClickEventArgs e)
- {
- string sql = "update tb_WF_ACtIns set Status=4 where [WfInstanceID]=" + WFInstanceID + " and [ActivityID]=" + ActivityID;
- string sql1 = "update [tb_PrjOldMat] set [Status]=3 where [MatID]=" + this.MatID;
- if (SqlServer.RunSql(sql) && SqlServer.RunSql(sql1))
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作成功!');top.location.href='../Main.aspx';</script>");
- }
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:作废操作失败!');top.location.href='../Main.aspx';</script>");
- }
- }
- //******************************************************得到指定活动的文档名称*************************************************************
- protected string GetDocumentFileName(int activityid)
- {
- string sql = "select [FName] from [tb_Colony_FileName1] a,[tb_Sys_FileName] b where a.[FID]=b.[FID] and [ActivityID]=" + activityid;
- string filename = "";
- //string tempfilename = "";
- DataView dv = SqlServer.GetDataView(sql);
- if (dv != null && dv.Count > 0)
- {
- filename = dv[0]["FName"].ToString();
- //if (filename.Length >= 2)
- // tempfilename = filename.Substring(filename.LastIndexOf("\\") + 2);
- }
- return filename;
- }
- protected string GetDocumentFileName(int activityid, int index)
- {
- string sql = "select [FName] from [tb_Colony_FileName1] a,[tb_Sys_FileName] b where a.[FID]=b.[FID] and [ActivityID]=" + activityid;
- string filename = "";
- // string tempfilename = "";
- DataView dv = SqlServer.GetDataView(sql);
- if (dv != null && dv.Count > 0)
- {
- filename = dv[index]["FName"].ToString();
- //if (filename.Length >= 2)
- // tempfilename = filename.Substring(filename.LastIndexOf("\\") + 2);
- }
- return filename;
- }
- ////******************************************************用最新日期生成最新文档*************************************************************
- protected string MakeNewFileNameWithDate(string filename)
- {
- if (filename.Length > 0)
- {
- string[] a = filename.Split('.');
- return a[0] + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + "." + a[1];
- }
- else
- return "";
- }
- ////******************************************************找到员工类型的汇总文档*************************************************************
- protected string GetEmpTypeDocument()
- {
- string EmpTypeFileName = "";
- string path = Server.MapPath("doc").Replace("\", "\\"); //获取项目所在路径
- CheckUserInfo cui = null;
- if (Session["checkuserinfo"] != null)
- {
- cui = (CheckUserInfo)Session["checkuserinfo"];
- }
- string EmpType = ProjectImplment.GetEmpType(cui.EmpID);
- string filename = GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
- if (filename != "")
- {
- string xmlFileName = path + "\DocTemplateMat\" + filename;
- XML xml = new XML(xmlFileName);
- ArrayList list = xml.ReadNode("Documents", EmpType, true);
- if (list.Count > 0)
- {
- DocumentNode node = (DocumentNode)list[0];
- EmpTypeFileName = node.FileName;
- }
- }
- return EmpTypeFileName;
- }
- protected void IB_Collect_Click(object sender, ImageClickEventArgs e)
- {
- string path = Server.MapPath("doc").Replace("\", "\\"); //获取项目所在路径
- CheckUserInfo cui = null;
- if (Session["checkuserinfo"] != null)
- {
- cui = (CheckUserInfo)Session["checkuserinfo"];
- }
- com.etong.DAL.FC.EtongFlyChouWFPrj etongFlyChouWFPrj = new com.etong.DAL.FC.EtongFlyChouWFPrj();
- etongFlyChouWFPrj.sID = this.actinstanceid;
- etongFlyChouWFPrj.PrjID = this.MatID;
- etongFlyChouWFPrj.wID = this.wfid;
- etongFlyChouWFPrj.iStatus = 5;
- etongFlyChouWFPrj.sBlockReason = WorkFolw.GetBlockReason(this.actinstanceid);
- if (etongFlyChouWFPrj.CheckUpActCompleteSort() == false)
- {
- Common.RunScript(this.Page, "工作流上级所属(同类型的)活动未完成,不能汇总文档");
- return;
- }
- else
- {
- string EmpType = ProjectImplment.GetEmpType(cui.EmpID);
- string orgfilename = GetDocumentFileName(this.ActivityID);
- string filename = "型物资汇总表";
- /*switch (EmpType)
- {
- case "1": filename = "科技" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
- break;
- case "2": filename = "生产" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
- break;
- case "3": filename = "营销" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".doc";
- break;
- }*/
- filename = EmpType + "-" + filename + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second;
- string checker = cui.EmpName;
- string time = DateTime.Now.ToString();
- string xmlFileName = path + "\DocTemplateMat\" + GetPrjOldMatInfo(this.MatID)[0]["ZgHZFName"].ToString();
- XML xml = new XML(xmlFileName);
- XML jcXml = new XML(path + "\DocTemplateMat\" + GetPrjOldMatInfo(this.MatID)[0]["DocumentXML"].ToString());
- ArrayList list = jcXml.ReadNode("Documents", EmpType, true);
- string[] filecopy = new string[list.Count];
- if (filecopy.Length > 0)
- {
- for (int i = 0; i < filecopy.Length; i++)
- {
- DocumentNode documentNode = (DocumentNode)list[i];
- filecopy[i] = path + "\DocTemplateMat\" + documentNode.FileName;
- }
- string[] houzhui = filecopy[0].Split('.');
- MyDocMerger myDocMerger = new MyDocMerger();
- string orgDocName = path + "\DocTemplateMat\" + filename + "." + houzhui[1];
- this.txt_ZgHZFName.Value = filename + "." + houzhui[1];
- if (xml.AddXmlNode(new DocumentNode(this.txt_ZgHZFName.Value, checker, time, EmpType)))
- {
- if (Util.Copyfile(path + "\" + orgfilename, orgDocName))
- {
- /*------------------------文档汇总----------------------*/
- myDocMerger.MergeDocArray(orgDocName, filecopy, orgDocName);
- /*---------------改变按钮组为可用状态-------------------*/
- this.TB_OpenDocument_ZGdFName.Enabled = true;
- this.TB_OpenDocument_ZgHZFName.Enabled = true;
- this.TB_OpenDocument_ZGxFName.Enabled = true;
- this.TB_OpenDocument_ZgHZFName.Text = "浏览电子文档";
- this.TB_OpenDocument_ZgHZFName.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplateMat/'+document.all('txt_ZgHZFName').value,'" + cui.EmpName + "');");
- Common.RunScript(this.Page, "汇总成功!");
- this.IsCollect = true;
- this.IB_Collect.Enabled = false;
- }
- else
- {
- Common.RunScript(this.Page, "打开文档失败!");
- }
- }
- else
- {
- Common.RunScript(this.Page, "汇总失败,请检查相关数据!");
- }
- }
- else
- {
- Common.RunScript(this.Page, "没有文档,不能汇总!");
- }
- }
- }
- //
- protected bool CheckEmpTypeIsEqualBlockReason()
- {
- bool flag = false;
- int wfid = -1;
- int actid = -1;
- CheckUserInfo cui = null;
- if (Session["checkuserinfo"] != null)
- {
- cui = (CheckUserInfo)Session["checkuserinfo"];
- }
- string type = ProjectImplment.GetEmpType(cui.EmpID);
- string sql = "select * from [tb_WF_Instance] where [Status]=5 and [PrjID]=" + this.MatID;
- DataView dv = SqlServer.GetDataView(sql);
- if (dv != null && dv.Count > 0)
- {
- wfid = Convert.ToInt32(dv[0]["WFInstanceID"].ToString());
- EtongZwf etongzwf = new EtongZwf();
- dv = etongzwf.ColonyUserGetByActId(ActivityID);
- if (dv.Count > 0)
- {
- actid = Convert.ToInt32(dv[0]["ParentActID"].ToString().Trim());
- sql = "select [BlockReason] from [tb_WF_ActIns] where [ActivityID]=" + actid + " and [WfInstanceID]=" + wfid;
- dv = SqlServer.GetDataView(sql);
- if (dv.Count > 0)
- {
- if (type == dv[0]["BlockReason"].ToString())
- flag = true;
- }
- }
- }
- return flag;
- }
- }