889 lines
41 KiB
C#
889 lines
41 KiB
C#
using Aspose.Words;
|
||
using BLL;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using AspNet = System.Web.UI.WebControls;
|
||
|
||
namespace FineUIPro.Web.HSSE.SolutionNew
|
||
{
|
||
public partial class ConstructSolution : PageBase
|
||
{
|
||
#region 获取按钮权限
|
||
/// <summary>
|
||
/// 获取按钮权限
|
||
/// </summary>
|
||
/// <param name="button"></param>
|
||
/// <returns></returns>
|
||
private void GetButtonPower()
|
||
{
|
||
if (Request.Params["value"] == "0")
|
||
{
|
||
return;
|
||
}
|
||
var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.UserId, Const.CQMSConstructSolutionMenuId);
|
||
if (buttonList.Count() > 0)
|
||
{
|
||
if (buttonList.Contains(Const.BtnAdd))
|
||
{
|
||
btnNew.Hidden = false;
|
||
|
||
}
|
||
if (buttonList.Contains(Const.BtnModify) || buttonList.Contains(Const.BtnSubmit))
|
||
{
|
||
btnMenuModify.Hidden = false;
|
||
}
|
||
if (buttonList.Contains(Const.BtnDelete))
|
||
{
|
||
btnMenuDel.Hidden = false;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
GetButtonPower();
|
||
BLL.SolutionTempleteTypeService.InitSolutionTempleteDropDownList(drpSolutionType, true);
|
||
//Funs.FineUIPleaseSelect(drpState);
|
||
UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true);
|
||
CNProfessionalService.InitCNProfessionalDownList(drpCNProfessional, true);
|
||
UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpProposeUnit, CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
|
||
btnNew.OnClientClick = window_tt.GetShowReference("EditConstructSolution.aspx") + "return false;";
|
||
if (this.CurrUser.UnitId != null && this.CurrUser.UnitId != Const.UnitId_CD && this.CurrUser.UnitId != Const.hfnbdId)
|
||
{
|
||
this.drpProposeUnit.Hidden = true;
|
||
}
|
||
BindGrid();
|
||
}
|
||
else
|
||
{
|
||
var eventArgs = GetRequestEventArgument(); // 此函数所在文件:PageBase.cs
|
||
if (eventArgs.StartsWith("ButtonClick"))
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string path = string.Empty;
|
||
if (drpModelType.SelectedValue == "1")
|
||
{
|
||
path = Const.CQMSConstructSolutionTemplateUrl1;
|
||
}
|
||
else
|
||
{
|
||
path = Const.CQMSConstructSolutionTemplateUrl3;
|
||
}
|
||
string uploadfilepath = rootPath + path;
|
||
string fileName = Path.GetFileName(uploadfilepath);
|
||
FileInfo fileInfo = new FileInfo(uploadfilepath);
|
||
FileInfo info = new FileInfo(uploadfilepath);
|
||
long fileSize = info.Length;
|
||
Response.Clear();
|
||
Response.ContentType = "application/octet-stream";
|
||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||
Response.TransmitFile(uploadfilepath, 0, fileSize);
|
||
Response.Flush();
|
||
}
|
||
}
|
||
}
|
||
|
||
protected string ConvertEdition(object edition)
|
||
{
|
||
return string.Format("{0:#0.#}",((int)edition)/10.0);
|
||
}
|
||
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
||
{
|
||
int i = e.RowIndex;
|
||
string id = Grid1.Rows[i].DataKeys[0].ToString();
|
||
var solution = HSSEConstructSolutionService.GetConstructSolutionByConstructSolutionId(id);
|
||
|
||
//Grid1.Rows[i].Values[""]
|
||
if (solution.Edition.Value>=3)
|
||
|
||
{ //闭环
|
||
Grid1.Rows[i].RowCssClass = "red";
|
||
}
|
||
////else if( checkControl.LimitDate> )
|
||
//else if (Convert.ToDateTime(checkControl.LimitDate).AddDays(1).Date < DateTime.Now && checkControl.State != BLL.Const.CheckControl_Complete) //延期未整改
|
||
//{
|
||
// Grid1.Rows[i].RowCssClass = "orange";
|
||
//}
|
||
//else //期内未整改
|
||
//{
|
||
// Grid1.Rows[i].RowCssClass = "red";
|
||
//}
|
||
}
|
||
protected DataTable ChecklistData()
|
||
{
|
||
|
||
string strSql = @"SELECT chec.ConstructSolutionId,chec.ProjectId,chec.UnitId,Edition,chec.UnitWorkIds,chec.CNProfessionalCodes,"
|
||
+ @" chec.CompileMan,chec.CompileDate,chec.code,chec.state,chec.SolutionType,chec.SolutionName,"
|
||
+ @" unit.UnitName,u.userName as CompileManName,chec.SpecialSchemeTypeId,s.SolutionTempleteTypeName,"
|
||
+ @" t.SpecialSchemeTypeName ,(select top 1 case when ApproveDate is null then getdate() else ApproveDate end from
|
||
Solution_HSSEConstructSolutionApprove approve
|
||
where approve.ConstructSolutionId = chec.ConstructSolutionId and approve.ApproveType != 'S' order by ApproveDate desc) as ApproveDate "
|
||
+ @" FROM Solution_HSSEConstructSolution chec "
|
||
+ @" left join Base_Unit unit on unit.unitId=chec.UnitId "
|
||
+ @" left join sys_User u on u.userId = chec.CompileMan"
|
||
+ @" left join[dbo].[Base_SolutionTempleteType] s on chec.SolutionType=s.SolutionTempleteTypeCode"
|
||
+ @" left join[dbo].[Base_SpecialSchemeType] t on chec.SpecialSchemeTypeId=t.SpecialSchemeTypeId"
|
||
+ @" where chec.ProjectId=@ProjectId";
|
||
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
|
||
if (this.CurrUser.UnitId != null && this.CurrUser.UnitId != Const.UnitId_CD && this.CurrUser.UnitId != Const.hfnbdId)
|
||
{
|
||
strSql += " AND chec.UnitId='" + this.CurrUser.UnitId + "'";
|
||
}
|
||
if (drpProposeUnit.SelectedValue != Const._Null)
|
||
{
|
||
strSql += " AND chec.UnitId=@unitId";
|
||
listStr.Add(new SqlParameter("@unitId", drpProposeUnit.SelectedValue));
|
||
}
|
||
if (drpSolutionType.SelectedValue != Const._Null)
|
||
{
|
||
strSql += " AND chec.SolutionType=@SolutionType";
|
||
listStr.Add(new SqlParameter("@SolutionType", drpSolutionType.SelectedValue));
|
||
}
|
||
if (drpUnitWork.SelectedValue != Const._Null)
|
||
{
|
||
strSql += " AND CHARINDEX(@unitworkId,chec.unitworkIds) > 0 ";
|
||
listStr.Add(new SqlParameter("@unitworkId", drpUnitWork.SelectedValue));
|
||
}
|
||
if (drpCNProfessional.SelectedValue != Const._Null)
|
||
{
|
||
strSql += " AND CHARINDEX(@CNProfessionalCode,chec.CNProfessionalCodes) > 0 ";
|
||
//strSql += " AND chec.CNProfessionalCode=@CNProfessionalCode";
|
||
listStr.Add(new SqlParameter("@CNProfessionalCode", drpCNProfessional.SelectedValue));
|
||
}
|
||
if (drpState.SelectedValue != Const._Null)
|
||
{
|
||
if (drpState.SelectedValue == "1") //已闭合
|
||
{
|
||
strSql += " AND State=@State";
|
||
listStr.Add(new SqlParameter("@State", "3"));
|
||
}
|
||
else //未闭合
|
||
{
|
||
strSql += " AND State!=@State";
|
||
listStr.Add(new SqlParameter("@State", "3"));
|
||
}
|
||
}
|
||
strSql += " order by ApproveDate desc ";
|
||
//if (drpUnitWork.SelectedValue != Const._Null)
|
||
//{
|
||
// strSql += " AND chec.unitworkId=@unitworkId";
|
||
// listStr.Add(new SqlParameter("@unitworkId", drpUnitWork.SelectedValue));
|
||
//}
|
||
//if (drpCNProfessional.SelectedValue != Const._Null)
|
||
//{
|
||
// strSql += " AND chec.CNProfessionalCode=@CNProfessionalCode";
|
||
// listStr.Add(new SqlParameter("@CNProfessionalCode", drpCNProfessional.SelectedValue));
|
||
//}
|
||
//if (drpQuestionType.SelectedValue != Const._Null)
|
||
//{
|
||
// strSql += " AND chec.QuestionType=@QuestionType";
|
||
// listStr.Add(new SqlParameter("@QuestionType", drpQuestionType.SelectedValue));
|
||
//}
|
||
//if (dpHandelStatus.SelectedValue != Const._Null)
|
||
//{
|
||
// if (dpHandelStatus.SelectedValue.Equals("1"))
|
||
// {
|
||
// strSql += " AND (chec.state='5' or chec.state='6')";
|
||
// }
|
||
// else if (dpHandelStatus.SelectedValue.Equals("2"))
|
||
// {
|
||
// strSql += " AND chec.state='7'";
|
||
// }
|
||
// else if (dpHandelStatus.SelectedValue.Equals("3"))
|
||
// {
|
||
// strSql += " AND DATEADD(day,1,chec.LimitDate)< GETDATE() and chec.state<>5 and chec.state<>6 and chec.state<>7";
|
||
// }
|
||
// else if (dpHandelStatus.SelectedValue.Equals("4"))
|
||
// {
|
||
// strSql += " AND DATEADD(day,1,chec.LimitDate)> GETDATE() and chec.state<>5 and chec.state<>6 and chec.state<>7";
|
||
// }
|
||
//}
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
return tb;
|
||
}
|
||
private void BindGrid()
|
||
{
|
||
var list = ChecklistData();
|
||
Grid1.RecordCount = list.Rows.Count;
|
||
var CNProfessional = CNProfessionalService.GetCNProfessionalItem();
|
||
var uniWork = UnitWorkService.GetUnitWorkLists(CurrUser.LoginProjectId);
|
||
if (list.Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < list.Rows.Count; i++)
|
||
{
|
||
if (list.Rows[i]["CNProfessionalCodes"] != null)
|
||
{
|
||
var code = list.Rows[i]["CNProfessionalCodes"].ToString().Split(',');
|
||
var listf = CNProfessional.Where(p => code.Contains(p.Value)).Select(p => p.Text).ToArray();
|
||
list.Rows[i]["CNProfessionalCodes"] = string.Join(",", listf);
|
||
}
|
||
if (list.Rows[i]["UnitWorkIds"] != null)
|
||
{
|
||
var code = list.Rows[i]["UnitWorkIds"].ToString().Split(',');
|
||
var workid = uniWork.Where(p => code.Contains(p.UnitWorkId)).Select(p => p.UnitWorkName + BLL.UnitWorkService.GetProjectType(p.ProjectType)).ToArray();
|
||
list.Rows[i]["UnitWorkIds"] = string.Join(",", workid);
|
||
}
|
||
}
|
||
}
|
||
list = GetFilteredTable(Grid1.FilteredData, list);
|
||
var table = GetPagedDataTable(Grid1, list);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||
{
|
||
object[] keys = Grid1.DataKeys[e.RowIndex];
|
||
string fileId = string.Empty;
|
||
if (keys == null)
|
||
{
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
fileId = keys[0].ToString();
|
||
}
|
||
if (e.CommandName == "exportSuggestion")
|
||
{
|
||
Model.Solution_HSSEConstructSolution constructSolution = HSSEConstructSolutionService.GetConstructSolutionByConstructSolutionId(fileId);
|
||
var list = HSSEConstructSolutionApproveService.getListDataForExport(fileId);
|
||
|
||
string rootPath = Server.MapPath("~/");
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
|
||
initTemplatePath = Const.ConstructSolutionSuggestTemplateUrl;
|
||
uploadfilepath = rootPath + initTemplatePath;
|
||
newUrl = uploadfilepath.Replace(".doc", constructSolution.Code.Replace("/", "-") + ".doc");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Bookmark bookmarkProjectName = doc.Range.Bookmarks["projectName"];
|
||
Bookmark bookmarkProjectName2 = doc.Range.Bookmarks["projectName2"];
|
||
Bookmark bookmarkprojectNum = doc.Range.Bookmarks["projectNum"];
|
||
Bookmark FileNum = doc.Range.Bookmarks["FileNum"];
|
||
if (FileNum != null)
|
||
{
|
||
FileNum.Text = constructSolution.Code;
|
||
}
|
||
if (bookmarkProjectName != null)
|
||
{
|
||
var project = ProjectService.GetProjectByProjectId(constructSolution.ProjectId);
|
||
if (project != null)
|
||
{
|
||
bookmarkProjectName.Text = project.ProjectName;
|
||
bookmarkProjectName2.Text = project.ProjectName;
|
||
bookmarkprojectNum.Text = project.ProjectCode;
|
||
}
|
||
}
|
||
Bookmark bookmarkEdition = doc.Range.Bookmarks["Edition"];
|
||
if (bookmarkEdition != null && constructSolution.Edition.HasValue)
|
||
{
|
||
bookmarkEdition.Text =""+ (constructSolution.Edition.Value/10.0).ToString("0.0");
|
||
}
|
||
Bookmark bookmarkoption1 = doc.Range.Bookmarks["option1"];
|
||
Bookmark bookmarkAuditer1 = doc.Range.Bookmarks["Auditer1"];
|
||
Bookmark bookmarkAuditDate1 = doc.Range.Bookmarks["AuditDate1"];
|
||
|
||
if (bookmarkoption1 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u=>u.SignType=="ZY").ToList();
|
||
for (int i = 0; i < listtemp.Count; i++)
|
||
{
|
||
|
||
option += string.Format("{0}\n", listtemp[i].ApproveIdea);
|
||
|
||
}
|
||
bookmarkoption1.Text = option;
|
||
var temp = list.Where(u => u.SignType == "ZY").LastOrDefault();
|
||
if (temp != null)
|
||
{
|
||
var user = UserService.GetUserByUserId(temp.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer1.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate1.Text = temp.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
|
||
}
|
||
}
|
||
Bookmark bookmarkoption2 = doc.Range.Bookmarks["option2"];
|
||
Bookmark bookmarkAuditer2 = doc.Range.Bookmarks["Auditer2"];
|
||
Bookmark bookmarkAuditDate2 = doc.Range.Bookmarks["AuditDate2"];
|
||
|
||
|
||
if (bookmarkoption2 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "ZL").ToList();
|
||
for (int i = 0; i < listtemp.Count; i++)
|
||
{
|
||
|
||
option += string.Format("{0}\n", listtemp[i].ApproveIdea);
|
||
|
||
}
|
||
bookmarkoption2.Text = option;
|
||
|
||
var temp = list.Where(u => u.SignType == "ZL").LastOrDefault();
|
||
if (temp != null)
|
||
{
|
||
var user = UserService.GetUserByUserId(temp.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer2.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate2.Text = temp.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
|
||
}
|
||
}
|
||
Bookmark bookmarkoption3 = doc.Range.Bookmarks["option3"];
|
||
Bookmark bookmarkAuditer3 = doc.Range.Bookmarks["Auditer3"];
|
||
Bookmark bookmarkAuditDate3 = doc.Range.Bookmarks["AuditDate3"];
|
||
|
||
if (bookmarkoption3 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "AQ").ToList();
|
||
for (int i = 0; i < listtemp.Count; i++)
|
||
{
|
||
var puser = ProjectUserService.GetProjectUserByUserIdProjectId(constructSolution.ProjectId, listtemp[i].ApproveMan);
|
||
if (puser.RoleId.Contains(Const.HSSEEngineer))
|
||
{
|
||
var user = UserService.GetUserByUserId(listtemp[i].ApproveMan);
|
||
|
||
option += string.Format("{0}\n", listtemp[i].ApproveIdea);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer3.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate3.Text = listtemp[i].ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
}
|
||
}
|
||
bookmarkoption3.Text = option;
|
||
|
||
}
|
||
Bookmark bookmarkoption4 = doc.Range.Bookmarks["option4"];
|
||
Bookmark bookmarkAuditer4 = doc.Range.Bookmarks["Auditer4"];
|
||
Bookmark bookmarkAuditDate4 = doc.Range.Bookmarks["AuditDate4"];
|
||
|
||
if (bookmarkoption4 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "AQ").ToList();
|
||
for (int i = 0; i < listtemp.Count; i++)
|
||
{
|
||
var puser = ProjectUserService.GetProjectUserByUserIdProjectId(constructSolution.ProjectId, listtemp[i].ApproveMan);
|
||
if (puser.RoleId.Contains(Const.HSSEManager))
|
||
{
|
||
var user = UserService.GetUserByUserId(listtemp[i].ApproveMan);
|
||
|
||
option += string.Format("{0}\n", listtemp[i].ApproveIdea);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer4.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate4.Text = listtemp[i].ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
}
|
||
}
|
||
bookmarkoption4.Text = option;
|
||
|
||
|
||
}
|
||
Bookmark bookmarkoption5 = doc.Range.Bookmarks["option5"];
|
||
Bookmark bookmarkAuditer5 = doc.Range.Bookmarks["Auditer5"];
|
||
Bookmark bookmarkAuditDate5 = doc.Range.Bookmarks["AuditDate5"];
|
||
if (bookmarkoption5!= null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "SG").ToList();
|
||
for (int i = 0; i < listtemp.Count; i++)
|
||
{
|
||
|
||
option += string.Format("{0}\n", listtemp[i].ApproveIdea);
|
||
|
||
}
|
||
bookmarkoption5.Text = option;
|
||
var temp = list.Where(u => u.SignType == "SG").LastOrDefault();
|
||
if (temp != null)
|
||
{
|
||
var user = UserService.GetUserByUserId(temp.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer5.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate5.Text = temp.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
|
||
}
|
||
}
|
||
doc.Save(newUrl);
|
||
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
//验证参数
|
||
if (doc1 == null) { throw new Exception("Word文件无效"); }
|
||
string fileName = Path.GetFileName(newUrl);
|
||
FileInfo info = new FileInfo(newUrl);
|
||
long fileSize = info.Length;
|
||
Response.Clear();
|
||
Response.ContentType = "application/x-zip-compressed";
|
||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||
Response.TransmitFile(newUrl, 0, fileSize);
|
||
Response.Flush();
|
||
Response.Close();
|
||
File.Delete(newUrl);
|
||
}
|
||
else if (e.CommandName == "exportApproval")
|
||
{
|
||
Model.Solution_HSSEConstructSolution constructSolution = HSSEConstructSolutionService.GetConstructSolutionByConstructSolutionId(fileId);
|
||
var list = HSSEConstructSolutionApproveService.getListData(fileId);
|
||
|
||
string rootPath = Server.MapPath("~/");
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
|
||
initTemplatePath = Const.ConstructSolutionApproveTemplateUrl;
|
||
uploadfilepath = rootPath + initTemplatePath;
|
||
newUrl = uploadfilepath.Replace(".doc", constructSolution.Code.Replace("/", "-") + ".doc");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Bookmark bookmarkProjectName = doc.Range.Bookmarks["projectName"];
|
||
Bookmark bookmarkProjectName2 = doc.Range.Bookmarks["projectName2"];
|
||
Bookmark bookmarkprojectNum = doc.Range.Bookmarks["projectNum"];
|
||
Bookmark FileNum = doc.Range.Bookmarks["FileNum"];
|
||
if (FileNum !=null)
|
||
{
|
||
FileNum.Text = constructSolution.Code;
|
||
}
|
||
if (bookmarkProjectName != null)
|
||
{
|
||
var project = ProjectService.GetProjectByProjectId(constructSolution.ProjectId);
|
||
if (project != null)
|
||
{
|
||
bookmarkProjectName.Text = project.ProjectName;
|
||
bookmarkProjectName2.Text = project.ProjectName;
|
||
bookmarkprojectNum.Text = project.ProjectCode;
|
||
}
|
||
}
|
||
Bookmark bookmarkEdition = doc.Range.Bookmarks["Edition"];
|
||
if (bookmarkEdition != null && constructSolution.Edition.HasValue)
|
||
{
|
||
bookmarkEdition.Text = "" + (constructSolution.Edition.Value / 10.0).ToString("0.0");
|
||
}
|
||
Bookmark bookmarkoption1 = doc.Range.Bookmarks["option1"];
|
||
Bookmark bookmarkAuditer1 = doc.Range.Bookmarks["Auditer1"];
|
||
Bookmark bookmarkAuditDate1 = doc.Range.Bookmarks["AuditDate1"];
|
||
|
||
if (bookmarkoption1 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "ZY").LastOrDefault();
|
||
if (listtemp != null)
|
||
{
|
||
option += string.Format("{0}\n", listtemp.ApproveIdea);
|
||
var user = UserService.GetUserByUserId(listtemp.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer1.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate1.Text = listtemp.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
}
|
||
bookmarkoption1.Text = option;
|
||
}
|
||
Bookmark bookmarkoption2 = doc.Range.Bookmarks["option2"];
|
||
Bookmark bookmarkAuditer2 = doc.Range.Bookmarks["Auditer2"];
|
||
Bookmark bookmarkAuditDate2 = doc.Range.Bookmarks["AuditDate2"];
|
||
|
||
if (bookmarkoption2 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "ZL").LastOrDefault();
|
||
if (listtemp != null)
|
||
{
|
||
option += string.Format("{0}\n", listtemp.ApproveIdea);
|
||
var user = UserService.GetUserByUserId(listtemp.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer2.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate2.Text = listtemp.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
|
||
}
|
||
bookmarkoption2.Text = option;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
Bookmark bookmarkoption3 = doc.Range.Bookmarks["option3"];
|
||
Bookmark bookmarkAuditer3 = doc.Range.Bookmarks["Auditer3"];
|
||
Bookmark bookmarkAuditDate3 = doc.Range.Bookmarks["AuditDate3"];
|
||
|
||
if (bookmarkoption3 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "AQ").ToList();
|
||
Model.Solution_HSSEConstructSolutionApprove lastApprove = null;
|
||
for (int i = 0; i < listtemp.Count; i++)
|
||
{
|
||
var puser = ProjectUserService.GetProjectUserByUserIdProjectId(constructSolution.ProjectId, listtemp[i].ApproveMan);
|
||
if (puser.RoleId.Contains(Const.HSSEEngineer))
|
||
{
|
||
lastApprove = listtemp[i];
|
||
}
|
||
|
||
}
|
||
if(lastApprove != null)
|
||
{
|
||
option += string.Format("{0}\n", lastApprove.ApproveIdea);
|
||
|
||
var user = UserService.GetUserByUserId(lastApprove.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer3.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate3.Text = lastApprove.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
|
||
}
|
||
|
||
bookmarkoption3.Text = option;
|
||
}
|
||
Bookmark bookmarkoption4 = doc.Range.Bookmarks["option4"];
|
||
Bookmark bookmarkAuditer4 = doc.Range.Bookmarks["Auditer4"];
|
||
Bookmark bookmarkAuditDate4 = doc.Range.Bookmarks["AuditDate4"];
|
||
|
||
if (bookmarkoption4 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "AQ").ToList();
|
||
Model.Solution_HSSEConstructSolutionApprove lastApprove = null;
|
||
|
||
for (int i = 0; i < listtemp.Count; i++)
|
||
{
|
||
var puser = ProjectUserService.GetProjectUserByUserIdProjectId(constructSolution.ProjectId, listtemp[i].ApproveMan);
|
||
if (puser.RoleId.Contains(Const.HSSEManager))
|
||
{
|
||
lastApprove = listtemp[i];
|
||
}
|
||
|
||
}
|
||
if (lastApprove != null)
|
||
{
|
||
option += string.Format("{0}\n", lastApprove.ApproveIdea);
|
||
var user = UserService.GetUserByUserId(lastApprove.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer4.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate4.Text = lastApprove.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
|
||
}
|
||
|
||
bookmarkoption4.Text = option;
|
||
}
|
||
Bookmark bookmarkoption5 = doc.Range.Bookmarks["option5"];
|
||
Bookmark bookmarkAuditer5 = doc.Range.Bookmarks["Auditer5"];
|
||
Bookmark bookmarkAuditDate5 = doc.Range.Bookmarks["AuditDate5"];
|
||
if (bookmarkoption5 != null)
|
||
{
|
||
string option = "";
|
||
var listtemp = list.Where(u => u.SignType == "SG").LastOrDefault();
|
||
if (listtemp != null)
|
||
{
|
||
option += string.Format("{0}\n", listtemp.ApproveIdea);
|
||
var user = UserService.GetUserByUserId(listtemp.ApproveMan);
|
||
if (user != null)
|
||
{
|
||
bookmarkAuditer5.Text = user.UserName;
|
||
}
|
||
bookmarkAuditDate5.Text = listtemp.ApproveDate.Value.ToString("yyyy年 MM月 dd日");
|
||
|
||
}
|
||
bookmarkoption5.Text = option;
|
||
}
|
||
doc.Save(newUrl);
|
||
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
//验证参数
|
||
if (doc1 == null) { throw new Exception("Word文件无效"); }
|
||
string fileName = Path.GetFileName(newUrl);
|
||
FileInfo info = new FileInfo(newUrl);
|
||
long fileSize = info.Length;
|
||
Response.Clear();
|
||
Response.ContentType = "application/x-zip-compressed";
|
||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||
Response.TransmitFile(newUrl, 0, fileSize);
|
||
Response.Flush();
|
||
Response.Close();
|
||
File.Delete(newUrl);
|
||
}
|
||
else if (e.CommandName == "attchUrl")
|
||
{
|
||
Model.Solution_HSSEConstructSolution constructSolution = HSSEConstructSolutionService.GetConstructSolutionByConstructSolutionId(fileId);
|
||
|
||
if (constructSolution != null)
|
||
{
|
||
if (string.IsNullOrEmpty(constructSolution.CQMSConstructSolutionId))
|
||
{
|
||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/Solution&menuId={2}",
|
||
-1, constructSolution.ConstructSolutionId + constructSolution.Edition, Const.CQMSConstructSolutionMenuId)));
|
||
}
|
||
else
|
||
{
|
||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/Solution&menuId={2}",
|
||
-1, constructSolution.CQMSConstructSolutionId + constructSolution.Edition, Const.CQMSConstructSolutionMenuId)));
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
protected void btnQuery_Click(object sender, EventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
|
||
protected void btnRset_Click(object sender, EventArgs e)
|
||
{
|
||
drpSolutionType.SelectedIndex = 0;
|
||
drpProposeUnit.SelectedIndex = 0;
|
||
drpUnitWork.SelectedIndex = 0;
|
||
drpCNProfessional.SelectedIndex = 0;
|
||
drpState.SelectedIndex = 0;
|
||
BindGrid();
|
||
}
|
||
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
|
||
protected void btnMenuModify_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string id = Grid1.SelectedRowID.Split(',')[0];
|
||
Model.Solution_HSSEConstructSolution constructSolution = HSSEConstructSolutionService.GetConstructSolutionByConstructSolutionId(id);
|
||
if (constructSolution.State == Const.CQMSConstructSolution_Complete)
|
||
{
|
||
Alert.ShowInTop("该方案已经审批完成,无法操作,请右键查看!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else if (!string.IsNullOrEmpty(constructSolution.CQMSConstructSolutionId))
|
||
{
|
||
Alert.ShowInTop("该方案为质量模块施工方案备份内容,请右键查看!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else if (constructSolution.State == Const.CQMSConstructSolution_Compile)
|
||
{
|
||
if (constructSolution.CompileMan == CurrUser.UserId || CurrUser.UserId == Const.sysglyId)
|
||
{
|
||
|
||
PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("EditConstructSolution.aspx?constructSolutionId={0}", id)));
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您不是编制人,无法操作!请右键查看", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else if (constructSolution.State == Const.CQMSConstructSolution_Audit || constructSolution.State == Const.CQMSConstructSolution_ReCompile)
|
||
{
|
||
Model.Solution_HSSEConstructSolutionApprove approve = HSSEConstructSolutionApproveService.GetConstructSolutionApproveByApproveMan(id, CurrUser.UserId);
|
||
if (approve != null || CurrUser.UserId == Const.sysglyId)
|
||
{
|
||
PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("EditConstructSolution.aspx?constructSolutionId={0}", id)));
|
||
return;
|
||
//Response.Redirect("CQMSConstructSolutionAudit.aspx?constructSolutionId=" + id);
|
||
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", id, "查看 - ")));
|
||
}
|
||
else
|
||
{
|
||
if (constructSolution.CompileMan.Equals(CurrUser.UserId))
|
||
{
|
||
PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("EditConstructSolution.aspx?constructSolutionId={0}", id)));
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您不是办理用户,无法操作!请右键查看", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
protected void btnMenuView_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string id = Grid1.SelectedRowID.Split(',')[0];
|
||
PageContext.RegisterStartupScript(window_tt.GetShowReference(String.Format("ConstructSolutionView.aspx?constructSolutionId={0}", id)));
|
||
|
||
}
|
||
|
||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string id = Grid1.SelectedRowID.Split(',')[0];
|
||
if (CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.UserId, Const.CQMSConstructSolutionMenuId, Const.BtnDelete))
|
||
{
|
||
var constructSolution = HSSEConstructSolutionService.GetConstructSolutionByConstructSolutionId(id);
|
||
HSSEConstructSolutionApproveService.DeleteConstructSolutionApprovesByConstructSolutionId(id);
|
||
HSSEConstructSolutionService.DeleteConstructSolution(id);
|
||
LogService.AddSys_Log(CurrUser, constructSolution.Code, id, Const.CQMSConstructSolutionMenuId, "删除方案审查");
|
||
BindGrid();
|
||
Alert.ShowInTop("删除成功!", MessageBoxIcon.Success);
|
||
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Success);
|
||
}
|
||
}
|
||
protected void btnOut_Click(object sender, EventArgs e)
|
||
{
|
||
Response.ClearContent();
|
||
string filename = Funs.GetNewFileName();
|
||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("安全施工方案" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||
Response.ContentType = "application/excel";
|
||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
this.Grid1.PageSize = 100000;
|
||
this.BindGrid();
|
||
Response.Write(GetGridTableHtml(Grid1));
|
||
Response.End();
|
||
}
|
||
/// <summary>
|
||
/// 导出方法
|
||
/// </summary>
|
||
/// <param name="grid"></param>
|
||
/// <returns></returns>
|
||
public static string GetGridTableHtml(Grid grid)
|
||
{
|
||
StringBuilder sb = new StringBuilder();
|
||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||
sb.Append("<tr>");
|
||
|
||
foreach (GridColumn column in grid.Columns)
|
||
{
|
||
if (column.ColumnID == "exportSuggestion" || column.ColumnID == "exportApproval" || column.ColumnID == "AttchUrl")
|
||
{
|
||
continue;
|
||
}
|
||
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||
}
|
||
sb.Append("</tr>");
|
||
foreach (GridRow row in grid.Rows)
|
||
{
|
||
sb.Append("<tr>");
|
||
foreach (GridColumn column in grid.Columns)
|
||
{
|
||
string html = row.Values[column.ColumnIndex].ToString();
|
||
if (column.ColumnID == "tfPageIndex" && (row.FindControl("lblPageIndex") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "Edition" && (row.FindControl("Label41") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("Label41") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "AuditDate" && (row.FindControl("Label2") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("Label2") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "State" && (row.FindControl("Label1") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("Label1") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "ToAuditMan")
|
||
{
|
||
html = (row.FindControl("Label3") as AspNet.Label).Text;
|
||
}
|
||
// 处理CheckBox
|
||
if (html.Contains("f-grid-static-checkbox"))
|
||
{
|
||
if (!html.Contains("f-checked"))
|
||
{
|
||
html = "×";
|
||
}
|
||
else
|
||
{
|
||
html = "√";
|
||
}
|
||
}
|
||
if(column.ColumnID == "exportSuggestion" || column.ColumnID == "exportApproval"|| column.ColumnID == "AttchUrl")
|
||
{
|
||
continue;
|
||
}
|
||
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
||
// sb.AppendFormat("<td>{0}</td>", html);
|
||
}
|
||
|
||
sb.Append("</tr>");
|
||
}
|
||
|
||
sb.Append("</table>");
|
||
|
||
return sb.ToString();
|
||
}
|
||
|
||
|
||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
|
||
protected void window_tt_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
|
||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||
{
|
||
btnMenuModify_Click(sender, e);
|
||
}
|
||
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
Grid1.PageIndex = e.NewPageIndex;
|
||
BindGrid();
|
||
}
|
||
}
|
||
} |