1544 lines
64 KiB
C#
1544 lines
64 KiB
C#
using Aspose.Words;
|
||
using BLL;
|
||
using Model;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Configuration;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Reflection.Emit;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using AspNet = System.Web.UI.WebControls;
|
||
namespace FineUIPro.Web.CQMS.Check
|
||
{
|
||
public partial class CheckList : PageBase
|
||
{
|
||
/// <summary>
|
||
/// 项目id
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
public int TotalNum
|
||
{
|
||
get
|
||
{
|
||
return (int)ViewState["TotalNum"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["TotalNum"] = value;
|
||
}
|
||
}
|
||
public string code
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["code"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["code"] = value;
|
||
}
|
||
}
|
||
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
// 表头过滤
|
||
//FilterDataRowItem = FilterDataRowItemImplement;
|
||
if (!IsPostBack)
|
||
{
|
||
code = ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).ProjectCode + "-QC-TCC-XJ-";
|
||
|
||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||
GetButtonPower();
|
||
//if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
|
||
//{
|
||
// this.ProjectId = Request.Params["projectId"];
|
||
//}
|
||
//权限按钮方法
|
||
UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpSponsorUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
|
||
UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true);
|
||
CNProfessionalService.InitCNProfessionalDownList(drpCNProfessional, true);
|
||
QualityQuestionTypeService.InitQualityQuestionTypeDownList(drpQuestionType, true);
|
||
Funs.FineUIPleaseSelect(this.dpHandelStatus);
|
||
btnNew.OnClientClick = Window1.GetShowReference("ChecklistEdit.aspx") + "return false;";
|
||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
|
||
// 绑定表格
|
||
BindGrid();
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
#endregion
|
||
//public System.Web.UI.WebControls.ListItem[] GetHandelStatus()
|
||
//{
|
||
// var list = Handelstatus();
|
||
// System.Web.UI.WebControls.ListItem[] litem = new System.Web.UI.WebControls.ListItem[list.Count];
|
||
|
||
// for (int i = 0; i < list.Count; i++)
|
||
// {
|
||
|
||
// litem[i]= new System.Web.UI.WebControls.ListItem(list.Keys.ToString(),list.Values.ToString());
|
||
|
||
// }
|
||
// return litem;
|
||
//}
|
||
/// <summary>
|
||
/// 整改状态
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
protected IDictionary<int, string> Handelstatus()
|
||
{
|
||
Dictionary<int, string> dic = new Dictionary<int, string>();
|
||
dic.Add(1, "未确认");
|
||
dic.Add(2, "已闭环");
|
||
dic.Add(3, "超期未整改");
|
||
dic.Add(4, "未整改");
|
||
return dic;
|
||
}
|
||
public Task<DataTable> data()
|
||
{
|
||
Task<DataTable> task = new Task<DataTable>(() =>
|
||
{
|
||
return ChecklistData();
|
||
});
|
||
task.Start();
|
||
return task;
|
||
}
|
||
protected DataTable ChecklistData()
|
||
{
|
||
|
||
//string strSql = @"SELECT chec.CheckControlCode,chec.CheckSite,chec.ProjectId,chec.unitId,cNProfessional.ProfessionalName,"
|
||
// + @" QualityQuestionType.QualityQuestionType as QuestionType,"
|
||
// + @" chec.checkman,chec.CheckDate,chec.DocCode,chec.submitman,chec.state,chec.CNProfessionalCode,"
|
||
// + @" unit.UnitName,unitWork.UnitWorkName,u.userName "
|
||
// + @" FROM Check_CheckControl chec"
|
||
// + @" left join Base_Unit unit on unit.unitId=chec.unitId"
|
||
// + @" left join Base_CNProfessional cNProfessional on cNProfessional.CNProfessionalId=chec.CNProfessionalCode"
|
||
// + @" left join WBS_UnitWork unitWork on unitWork.UnitWorkId = chec.UnitWorkId"
|
||
// + @" left join Base_QualityQuestionType QualityQuestionType on QualityQuestionType.QualityQuestionTypeId = chec.QuestionType"
|
||
// + @" left join sys_User u on u.userId = chec.CheckMan"
|
||
// + @" where chec.ProjectId=@ProjectId";
|
||
|
||
//List<SqlParameter> listStr = new List<SqlParameter>();
|
||
//listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||
//strSql += " AND (chec.CheckDate>=@startTime or @startTime='') and (chec.CheckDate<=@endTime or @endTime='') ";
|
||
//listStr.Add(new SqlParameter("@startTime", !string.IsNullOrEmpty(txtStartTime.Text.Trim()) ? txtStartTime.Text.Trim() + " 00:00:00" : ""));
|
||
//listStr.Add(new SqlParameter("@endTime", !string.IsNullOrEmpty(txtEndTime.Text.Trim()) ? txtEndTime.Text.Trim() + " 23:59:59" : ""));
|
||
//if (drpSponsorUnit.SelectedValue != BLL.Const._Null)
|
||
//{
|
||
// strSql += " AND chec.unitId=@unitId";
|
||
// listStr.Add(new SqlParameter("@unitId", drpSponsorUnit.SelectedValue));
|
||
//}
|
||
//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);
|
||
|
||
var query = (from x in Funs.DB.Check_CheckControl
|
||
select new
|
||
{
|
||
CheckControlCode = x.CheckControlCode,
|
||
ProjectId = x.ProjectId,
|
||
ProjectName = Funs.DB.Base_Project.FirstOrDefault(p => p.ProjectId == x.ProjectId).ProjectName,
|
||
DocCode = x.DocCode,
|
||
States = x.State,
|
||
CheckSite = x.CheckSite,
|
||
QuestionDef = x.QuestionDef,
|
||
CheckDate = String.Format("{0:yyyy-MM-dd}", x.CheckDate),
|
||
LimitDate = String.Format("{0:yyyy-MM-dd}", x.LimitDate),
|
||
RectifyOpinion = x.RectifyOpinion,
|
||
CheckMan = x.CheckMan,
|
||
UnitWorkId = x.UnitWorkId,
|
||
AttachUrl = x.AttachUrl,
|
||
HandleWay = x.HandleWay,
|
||
RectifyDate = String.Format("{0:yyyy-MM-dd}", x.RectifyDate),
|
||
ReAttachUrl = x.ReAttachUrl,
|
||
IsOk = x.IsOK,
|
||
OKDescr = x.OKDescr,
|
||
UnitWorkName = (from y in Funs.DB.WBS_UnitWork where y.UnitWorkId == x.UnitWorkId select y.UnitWorkName).First(),
|
||
CheckManName = (from y in Funs.DB.Sys_User where y.UserId == x.CheckMan select y.UserName).First(),
|
||
PrincipalMan = x.DutyMan,
|
||
PrincipalManName = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == x.DutyMan).UserName,
|
||
CNProfessionalCode = x.CNProfessionalCode,
|
||
CNProfessionalCodeName = Funs.DB.Base_CNProfessional.FirstOrDefault(e => e.CNProfessionalId == x.CNProfessionalCode).ProfessionalName,
|
||
QuestionType = x.QuestionType,
|
||
QuestionTypeName = Funs.DB.Base_QualityQuestionType.FirstOrDefault(e => e.QualityQuestionTypeId == x.QuestionType).QualityQuestionType,
|
||
|
||
}).ToList();
|
||
DataTable td = ToDataTable(query);
|
||
return td;
|
||
}
|
||
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)
|
||
{
|
||
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 == "tfNumber" && (row.FindControl("labNumber") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "State" && (row.FindControl("labState") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("labState") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "AuditMan" && (row.FindControl("lbAuditMan") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("lbAuditMan") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "State2" && (row.FindControl("lbState2") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("lbState2") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "tfImageUrl1" && (row.FindControl("lbImageUrl") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("lbImageUrl") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "tfImageUrl2" && (row.FindControl("lbImageUrl2") as AspNet.Label) != null)
|
||
{
|
||
html = (row.FindControl("lbImageUrl2") as AspNet.Label).Text;
|
||
}
|
||
// 处理CheckBox
|
||
if (html.Contains("f-grid-static-checkbox"))
|
||
{
|
||
if (!html.Contains("f-checked"))
|
||
{
|
||
html = "×";
|
||
}
|
||
else
|
||
{
|
||
html = "√";
|
||
}
|
||
}
|
||
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();
|
||
}
|
||
|
||
#region 检查照片
|
||
protected string ConvertImageUrlByImage(object registrationId)
|
||
{
|
||
string url = string.Empty;
|
||
if (registrationId != null)
|
||
{
|
||
Model.Check_CheckControl m = Funs.DB.Check_CheckControl.FirstOrDefault(e => e.CheckControlCode == registrationId.ToString());
|
||
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], m.AttachUrl.TrimEnd(','));
|
||
}
|
||
return url;
|
||
}
|
||
#endregion
|
||
protected string ConvertImgUrlByImage(object registrationId)
|
||
{
|
||
string url = string.Empty;
|
||
if (registrationId != null)
|
||
{
|
||
Model.Check_CheckControl m = Funs.DB.Check_CheckControl.FirstOrDefault(e => e.CheckControlCode == registrationId.ToString());
|
||
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], m.ReAttachUrl.TrimEnd(','));
|
||
}
|
||
return url;
|
||
}
|
||
|
||
public string Convertstatus(Object code)
|
||
{
|
||
Model.Check_CheckControl checkControl = BLL.CheckControlService.GetCheckControl(code.ToString());
|
||
if (checkControl.State.Equals("1") )
|
||
{
|
||
return "待整改";
|
||
}
|
||
else if (checkControl.State.Equals("2"))
|
||
{ //闭环
|
||
return "待确认";
|
||
}
|
||
//else if( checkControl.LimitDate> )
|
||
else if (checkControl.State.Equals("3")) //延期未整改
|
||
{
|
||
return "已闭环";
|
||
|
||
}
|
||
else
|
||
{
|
||
return "";
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
|
||
public void BindGrid()
|
||
{
|
||
DataTable tb = ChecklistData();
|
||
|
||
// 2.获取当前分页数据
|
||
//var table = this.GetPagedDataTable(Grid1, tb1);
|
||
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
|
||
//for (int i = 0; i < Grid1.Rows.Count; i++)
|
||
//{
|
||
// string rowID = Grid1.Rows[i].DataKeys[0].ToString();
|
||
// if (rowID.Count() > 0)
|
||
// {
|
||
// Model.Check_CheckControl checkControl = BLL.CheckControlService.GetCheckControl(rowID);
|
||
// if (checkControl.State.Equals("5") || checkControl.State.Equals("6"))
|
||
// {
|
||
// Grid1.Rows[i].CellCssClasses[11] = "LightGreen";//未确认
|
||
// }
|
||
// else if (checkControl.State == Const.CheckControl_Complete)
|
||
// { //闭环
|
||
// Grid1.Rows[i].CellCssClasses[11] = "Green";
|
||
|
||
// }
|
||
// else if (Convert.ToDateTime(checkControl.LimitDate).AddDays(1) < DateTime.Now) //延期未整改
|
||
// {
|
||
// Grid1.Rows[i].CellCssClasses[11] = "Red";
|
||
// }
|
||
// else //期内未整改
|
||
// {
|
||
// Grid1.Rows[i].CellCssClasses[11] = " Yellow ";
|
||
// }
|
||
// }
|
||
//}
|
||
}
|
||
|
||
|
||
#region 查询
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 过滤表头、排序、分页、关闭窗口
|
||
/// <summary>
|
||
/// 过滤表头
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_FilterChange(object sender, EventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 分页
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
Grid1.PageIndex = e.NewPageIndex;
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||
{
|
||
//Grid1.SortDirection = e.SortDirection;
|
||
//Grid1.SortField = e.SortField;
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 分页显示条数下拉框
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭弹出窗
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region Grid双击事件
|
||
/// <summary>
|
||
/// Grid行双击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||
{
|
||
btnMenuModify_Click(null, null);
|
||
}
|
||
#endregion
|
||
#region 编辑
|
||
/// <summary>
|
||
/// 编辑按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuModify_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string codes = Grid1.SelectedRowID.Split(',')[0];
|
||
var checks = BLL.CheckControlService.GetCheckControl(codes);
|
||
|
||
if (checks != null)
|
||
{
|
||
if (checks.State.Equals(Const.CheckControl_Complete))
|
||
{
|
||
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
Model.Check_CheckControlApprove approve = BLL.CheckControlApproveService.GetCheckControlApproveByCheckControlId(codes);
|
||
if (approve != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(approve.ApproveMan))
|
||
{
|
||
if (this.CurrUser.UserId == approve.ApproveMan || CurrUser.UserId == Const.sysglyId)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListEdit.aspx?CheckControlCode={0}", codes, "编辑 - ")));
|
||
return;
|
||
}
|
||
else if (checks.State == BLL.Const.CheckControl_Complete)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", codes, "查看 - ")));
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
}
|
||
//if (this.btnMenuModify.Hidden || checks.State == BLL.Const.State_2) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
||
//{
|
||
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", codes, "查看 - ")));
|
||
// return;
|
||
//}
|
||
//else
|
||
//{
|
||
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListEdit.aspx?CheckControlCode={0}", codes, "编辑 - ")));
|
||
// return;
|
||
//}
|
||
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 删除
|
||
/// <summary>
|
||
/// 批量删除
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string codes = Grid1.SelectedRowID.Split(',')[0];
|
||
var checks = BLL.CheckControlService.GetCheckControl(codes);
|
||
|
||
BLL.CheckControlApproveService.DeleteCheckControlApprovesByCheckControlCode(codes);
|
||
BLL.CheckControlService.DeleteCheckControl(codes);
|
||
BLL.LogService.AddSys_Log(this.CurrUser, checks.DocCode, codes, BLL.Const.CheckListMenuId, "删除质量巡检记录");
|
||
Grid1.DataBind();
|
||
BindGrid();
|
||
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
|
||
}
|
||
#endregion
|
||
#region 获取按钮权限
|
||
/// <summary>
|
||
/// 获取按钮权限
|
||
/// </summary>
|
||
/// <param name="button"></param>
|
||
/// <returns></returns>
|
||
private void GetButtonPower()
|
||
{
|
||
if (Request.Params["value"] == "0")
|
||
{
|
||
return;
|
||
}
|
||
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.CheckListMenuId);
|
||
if (buttonList.Count() > 0)
|
||
{
|
||
//if (buttonList.Contains(BLL.Const.BtnAdd))
|
||
//{
|
||
// this.btnNew.Hidden = false;
|
||
|
||
//}
|
||
|
||
if (buttonList.Contains(BLL.Const.BtnDelete))
|
||
{
|
||
this.btnMenuDel.Hidden = false;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
/// <summary>
|
||
/// 把状态转换代号为文字形式
|
||
/// </summary>
|
||
/// <param name="state"></param>
|
||
/// <returns></returns>
|
||
protected string ConvertState(object state)
|
||
{
|
||
if (state != null)
|
||
{
|
||
if (state.ToString() == BLL.Const.CheckControl_ReCompile)
|
||
{
|
||
return "重新编制";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_Compile)
|
||
{
|
||
return "编制";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_Audit1)
|
||
{
|
||
return "总包负责人审批";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_Audit2)
|
||
{
|
||
return "分包专业工程师回复";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_Audit3)
|
||
{
|
||
return "分包负责人审批";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_Audit4)
|
||
{
|
||
return "总包专业工程师确认";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_Audit5)
|
||
{
|
||
return "总包负责人确认";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_Complete)
|
||
{
|
||
return "审批完成";
|
||
}
|
||
else if (state.ToString() == BLL.Const.CheckControl_ReCompile2)
|
||
{
|
||
return "分包专业工程师重新回复";
|
||
}
|
||
else
|
||
{
|
||
return "";
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
//<summary>
|
||
//获取办理人姓名
|
||
//</summary>
|
||
//<param name="state"></param>
|
||
//<returns></returns>
|
||
protected string ConvertMan(object CheckControlCode)
|
||
{
|
||
if (CheckControlCode != null)
|
||
{
|
||
Model.Check_CheckControlApprove a = BLL.CheckControlApproveService.GetCheckControlApproveByCheckControlId(CheckControlCode.ToString());
|
||
if (a != null)
|
||
{
|
||
if (a.ApproveMan != null)
|
||
{
|
||
return BLL.UserService.GetUserByUserId(a.ApproveMan).UserName;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return "";
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
||
{
|
||
//if (checkControl.State.Equals("5") || checkControl.State.Equals("6"))
|
||
//{
|
||
// Grid1.Rows[i].RowCssClass = "lightgreen";//未确认
|
||
//}
|
||
//else if (checkControl.State == Const.CheckControl_Complete)
|
||
//{ //闭环
|
||
// Grid1.Rows[i].RowCssClass = "green";
|
||
//}
|
||
////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";
|
||
//}
|
||
}
|
||
|
||
public void btnMenuFine_Click(object sender, EventArgs e)
|
||
{
|
||
string codes = Grid1.SelectedRowID.Split(',')[0];
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("CheckFineListEdit.aspx?CheckControlCode={0}", codes, "查看 - ")));
|
||
}
|
||
|
||
protected void btnMenuView_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string codes = Grid1.SelectedRowID.Split(',')[0];
|
||
var checks = BLL.CheckControlService.GetCheckControl(codes);
|
||
|
||
if (checks != null)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", codes, "查看 - ")));
|
||
}
|
||
}
|
||
protected void btnMenuNotice_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string codes = Grid1.SelectedRowID.Split(',')[0];
|
||
var checks = BLL.CheckControlService.GetCheckControl(codes);
|
||
|
||
if (checks != null)
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
|
||
initTemplatePath = Const.CheckNoticeTemplateUrl;
|
||
uploadfilepath = rootPath + initTemplatePath;
|
||
newUrl = uploadfilepath.Replace(".doc", string.Format("{0}-{1:D4}", code, Grid1.RecordCount - Grid1.PageIndex * Grid1.PageSize - Grid1.SelectedRowIndex) + ".doc");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
Bookmark bookmarkProjectCode = doc.Range.Bookmarks["ProjectCode"];
|
||
|
||
|
||
if (bookmarkProjectCode != null)
|
||
{
|
||
var project = ProjectService.GetProjectByProjectId(checks.ProjectId);
|
||
if (project != null)
|
||
{
|
||
bookmarkProjectCode.Text = project.ProjectCode;
|
||
|
||
}
|
||
}
|
||
Bookmark bookmarkCheckCode = doc.Range.Bookmarks["CheckCode"];
|
||
if (bookmarkCheckCode != null)
|
||
{
|
||
bookmarkCheckCode.Text = checks.DocCode;
|
||
}
|
||
|
||
Bookmark bookmarkSendDate = doc.Range.Bookmarks["SendDate"];
|
||
if (bookmarkSendDate != null)
|
||
{
|
||
if (checks.CheckDate.HasValue)
|
||
{
|
||
bookmarkSendDate.Text = checks.CheckDate.Value.ToString("yyyy年MM月dd日");
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkUnit = doc.Range.Bookmarks["Unit"];
|
||
if (bookmarkUnit != null)
|
||
{
|
||
var unit = UnitService.GetUnitByUnitId(checks.UnitId);
|
||
if (unit != null)
|
||
{
|
||
bookmarkUnit.Text = unit.UnitName;
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkWorkArea = doc.Range.Bookmarks["WorkArea"];
|
||
if (bookmarkWorkArea != null)
|
||
{
|
||
string option = "";
|
||
var unitWork = UnitWorkService.GetUnitWorkByUnitWorkId(checks.UnitWorkId);
|
||
if (unitWork != null)
|
||
{
|
||
bookmarkWorkArea.Text = unitWork.UnitWorkCode + "-" + unitWork.UnitWorkName;
|
||
}
|
||
}
|
||
Bookmark bookmarkProblemType = doc.Range.Bookmarks["ProblemType"];
|
||
if (bookmarkProblemType != null)
|
||
{
|
||
string option = "";
|
||
var questionType = QualityQuestionTypeService.GetQualityQuestionType(checks.QuestionType);
|
||
if (questionType != null)
|
||
{
|
||
bookmarkProblemType.Text = questionType.QualityQuestionType;
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkLimitDate = doc.Range.Bookmarks["LimitDate"];
|
||
if (bookmarkLimitDate != null)
|
||
{
|
||
if (checks.LimitDate.HasValue)
|
||
{
|
||
bookmarkLimitDate.Text = checks.LimitDate.Value.ToString("yyyy年MM月dd日");
|
||
}
|
||
}
|
||
Bookmark bookmarkProblemDes = doc.Range.Bookmarks["ProblemDes"];
|
||
if (bookmarkProblemDes != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(checks.QuestionDef))
|
||
{
|
||
bookmarkProblemDes.Text = checks.QuestionDef;
|
||
}
|
||
}
|
||
Bookmark bookmarkSuggest = doc.Range.Bookmarks["Suggest"];
|
||
if (bookmarkSuggest != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(checks.RectifyOpinion))
|
||
bookmarkSuggest.Text = checks.RectifyOpinion;
|
||
}
|
||
Bookmark bookmarkCheckMan = doc.Range.Bookmarks["CheckMan"];
|
||
if (bookmarkCheckMan != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(checks.CheckMan))
|
||
{
|
||
var sysUser = UserService.GetUserByUserId(checks.CheckMan);
|
||
|
||
bookmarkCheckMan.Text = sysUser.UserName;
|
||
}
|
||
}
|
||
Bookmark bookmarkCheckDate = doc.Range.Bookmarks["CheckDate"];
|
||
if (bookmarkCheckDate != null)
|
||
{
|
||
if (checks.CheckDate.HasValue)
|
||
{
|
||
|
||
bookmarkCheckDate.Text = checks.CheckDate.Value.ToString("yyyy-MM-dd");
|
||
}
|
||
}
|
||
Bookmark bookmarkResponseMan = doc.Range.Bookmarks["ResponseMan"];
|
||
Bookmark bookmarkResponseDate = doc.Range.Bookmarks["ResponseDate"];
|
||
if (bookmarkResponseMan != null)
|
||
{
|
||
var approve = Funs.DB.Check_CheckControlApprove.Where(x => x.CheckControlCode == checks.CheckControlCode && x.ApproveType == BLL.Const.CheckControl_Audit2).FirstOrDefault();
|
||
|
||
if (approve != null)
|
||
{
|
||
var sysUser = UserService.GetUserByUserId(approve.ApproveMan);
|
||
if (sysUser != null)
|
||
{
|
||
bookmarkResponseMan.Text = sysUser.UserName;
|
||
}
|
||
|
||
if (approve.ApproveDate.HasValue)
|
||
{
|
||
|
||
bookmarkResponseDate.Text = approve.ApproveDate.Value.ToString("yyyy年MM月dd日");
|
||
}
|
||
}
|
||
}
|
||
IList<Model.AttachFile> sourlist = AttachFileService.GetBeforeFileList(checks.CheckControlCode, BLL.Const.CheckListMenuId);
|
||
|
||
if (sourlist != null && sourlist.Count > 0)
|
||
{
|
||
int indexPic = 1;
|
||
string AttachUrl = "";
|
||
foreach (var item in sourlist)
|
||
{
|
||
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
|
||
{
|
||
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
||
|
||
}
|
||
|
||
}
|
||
string []pics = AttachUrl.Split(',');
|
||
foreach(string item in pics)
|
||
{ switch (indexPic)
|
||
{
|
||
case 1:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic1");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic2");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic3");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic4");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
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);
|
||
|
||
}
|
||
}
|
||
protected void btnMenuReNotice_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string codes = Grid1.SelectedRowID.Split(',')[0];
|
||
var checks = BLL.CheckControlService.GetCheckControl(codes);
|
||
|
||
if (checks != null)
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
|
||
initTemplatePath = Const.CheckReNoticeTemplateUrl;
|
||
uploadfilepath = rootPath + initTemplatePath;
|
||
newUrl = uploadfilepath.Replace(".doc", string.Format("{0}-{1:D4}", code, Grid1.RecordCount - Grid1.PageIndex * Grid1.PageSize - Grid1.SelectedRowIndex) + ".doc");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
File.Copy(uploadfilepath, newUrl);
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
|
||
|
||
Bookmark bookmarkProjectCode = doc.Range.Bookmarks["ProjectNum"];
|
||
|
||
|
||
if (bookmarkProjectCode != null)
|
||
{
|
||
var project = ProjectService.GetProjectByProjectId(checks.ProjectId);
|
||
if (project != null)
|
||
{
|
||
bookmarkProjectCode.Text = project.ProjectCode;
|
||
|
||
}
|
||
}
|
||
Bookmark bookmarkSendDate = doc.Range.Bookmarks["SendDate"];
|
||
|
||
|
||
if (bookmarkSendDate != null)
|
||
{
|
||
|
||
if (checks.CheckDate.HasValue != null)
|
||
{
|
||
bookmarkSendDate.Text = checks.CheckDate.Value.ToString("yyyy年MM月dd日");
|
||
|
||
}
|
||
}
|
||
Bookmark bookmarkNoticeNum = doc.Range.Bookmarks["NoticeNum"];
|
||
if (bookmarkNoticeNum != null)
|
||
{
|
||
bookmarkNoticeNum.Text = checks.DocCode;
|
||
//bookmarkNoticeNum.Text = string.Format("{0}-{1:D4}", code, Grid1.RecordCount - Grid1.PageIndex * Grid1.PageSize - Grid1.SelectedRowIndex);// checks.DocCode;
|
||
|
||
}
|
||
|
||
|
||
|
||
Bookmark bookmarkUnit = doc.Range.Bookmarks["Unit"];
|
||
if (bookmarkUnit != null)
|
||
{
|
||
var unit = UnitService.GetUnitByUnitId(checks.UnitId);
|
||
if (unit != null)
|
||
{
|
||
bookmarkUnit.Text = unit.UnitName;
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkWorkArea = doc.Range.Bookmarks["UnitWork"];
|
||
if (bookmarkWorkArea != null)
|
||
{
|
||
string option = "";
|
||
var unitWork = UnitWorkService.GetUnitWorkByUnitWorkId(checks.UnitWorkId);
|
||
if (unitWork != null)
|
||
{
|
||
bookmarkWorkArea.Text = unitWork.UnitWorkCode + "-" + unitWork.UnitWorkName;
|
||
}
|
||
}
|
||
Bookmark bookmarkProblemType = doc.Range.Bookmarks["QuestionType"];
|
||
if (bookmarkProblemType != null)
|
||
{
|
||
string option = "";
|
||
var questionType = QualityQuestionTypeService.GetQualityQuestionType(checks.QuestionType);
|
||
if (questionType != null)
|
||
{
|
||
bookmarkProblemType.Text = questionType.QualityQuestionType;
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkChangeDate = doc.Range.Bookmarks["ChangeDate"];
|
||
if (bookmarkChangeDate != null)
|
||
{
|
||
if (checks.LimitDate.HasValue)
|
||
{
|
||
bookmarkChangeDate.Text = checks.LimitDate.Value.ToString("yyyy年MM月dd日");
|
||
}
|
||
}
|
||
Bookmark bookmarkProposeUnit = doc.Range.Bookmarks["ProposeUnit"];
|
||
if (bookmarkProposeUnit != null)
|
||
{
|
||
var unit = UnitService.GetUnitByUnitId(checks.ProposeUnitId);
|
||
if (unit != null)
|
||
{
|
||
bookmarkProposeUnit.Text = unit.UnitName;
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkCheckDate = doc.Range.Bookmarks["CheckDate"];
|
||
|
||
if (bookmarkCheckDate != null)
|
||
{
|
||
|
||
if (checks.CheckDate.HasValue != null)
|
||
{
|
||
bookmarkCheckDate.Text = checks.CheckDate.Value.ToString("yyyy年MM月dd日");
|
||
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkNoticeNum2 = doc.Range.Bookmarks["NoticeNum2"];
|
||
if (bookmarkNoticeNum2 != null)
|
||
{
|
||
bookmarkNoticeNum2.Text = checks.DocCode;
|
||
}
|
||
|
||
|
||
Bookmark bookmarkHandleWay = doc.Range.Bookmarks["HandleWay"];
|
||
if (bookmarkHandleWay != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(checks.HandleWay))
|
||
bookmarkHandleWay.Text = checks.HandleWay;
|
||
}
|
||
Bookmark bookmarkCheckMan = doc.Range.Bookmarks["CheckMan"];
|
||
if (bookmarkCheckMan != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(checks.CheckMan))
|
||
{
|
||
var sysUser = UserService.GetUserByUserId(checks.CheckMan);
|
||
|
||
bookmarkCheckMan.Text = sysUser.UserName;
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkResponseMan = doc.Range.Bookmarks["ResponseMan"];
|
||
Bookmark bookmarkResponseDate = doc.Range.Bookmarks["ResponseDate"];
|
||
if (bookmarkResponseMan != null)
|
||
{
|
||
var approve = Funs.DB.Check_CheckControlApprove.Where(x => x.CheckControlCode == checks.CheckControlCode && x.ApproveType == BLL.Const.CheckControl_Audit2).FirstOrDefault();
|
||
|
||
if (approve != null)
|
||
{
|
||
var sysUser = UserService.GetUserByUserId(approve.ApproveMan);
|
||
if (sysUser != null)
|
||
{
|
||
bookmarkResponseMan.Text = sysUser.UserName;
|
||
}
|
||
|
||
if (approve.ApproveDate.HasValue)
|
||
{
|
||
|
||
bookmarkResponseDate.Text = approve.ApproveDate.Value.ToString("yyyy年MM月dd日");
|
||
}
|
||
}
|
||
}
|
||
|
||
Bookmark bookmarkReCheckMan = doc.Range.Bookmarks["ReCheckMan"];
|
||
Bookmark bookmarkReCheckDate = doc.Range.Bookmarks["ReCheckDate"];
|
||
if (bookmarkResponseMan != null)
|
||
{
|
||
var approve = Funs.DB.Check_CheckControlApprove.Where(x => x.CheckControlCode == checks.CheckControlCode && x.ApproveType == BLL.Const.CheckControl_Audit4).FirstOrDefault();
|
||
|
||
if (approve != null)
|
||
{
|
||
var sysUser = UserService.GetUserByUserId(approve.ApproveMan);
|
||
if (sysUser != null)
|
||
{
|
||
bookmarkReCheckMan.Text = sysUser.UserName;
|
||
}
|
||
|
||
if (approve.ApproveDate.HasValue)
|
||
{
|
||
|
||
bookmarkReCheckDate.Text = approve.ApproveDate.Value.ToString("yyyy年MM月dd日");
|
||
}
|
||
}
|
||
}
|
||
|
||
IList<Model.AttachFile> sourlist = AttachFileService.GetBeforeFileList(checks.CheckControlCode, BLL.Const.CheckListMenuId);
|
||
|
||
if (sourlist != null && sourlist.Count > 0)
|
||
{
|
||
int indexPic = 1;
|
||
string AttachUrl = "";
|
||
foreach (var item in sourlist)
|
||
{
|
||
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
|
||
{
|
||
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
||
|
||
}
|
||
|
||
}
|
||
string[] pics = AttachUrl.Split(',');
|
||
foreach (string item in pics)
|
||
{
|
||
switch (indexPic)
|
||
{
|
||
case 1:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic1");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic2");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic3");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("Pic4");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
IList<Model.AttachFile> reSourlist = AttachFileService.GetBeforeFileList(checks.CheckControlCode+"r", BLL.Const.CheckListMenuId);
|
||
|
||
if (reSourlist != null && reSourlist.Count > 0)
|
||
{
|
||
int indexPic = 1;
|
||
string AttachUrl = "";
|
||
foreach (var item in reSourlist)
|
||
{
|
||
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
|
||
{
|
||
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
||
|
||
}
|
||
|
||
}
|
||
string[] pics = AttachUrl.Split(',');
|
||
foreach (string item in pics)
|
||
{
|
||
switch (indexPic)
|
||
{
|
||
case 1:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("RPic1");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("RPic2");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("RPic3");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
case 4:
|
||
{
|
||
string url = rootPath + item.TrimEnd(',');
|
||
//查找书签
|
||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||
builder.MoveToBookmark("RPic4");
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
System.Drawing.Size JpgSize;
|
||
float Wpx;
|
||
float Hpx;
|
||
UploadAttachmentService.getJpgSize(url, out JpgSize, out Wpx, out Hpx);
|
||
double i = 1;
|
||
i = JpgSize.Width / 220.0;
|
||
if (File.Exists(url))
|
||
{
|
||
builder.InsertImage(url, JpgSize.Width / i, JpgSize.Height / i);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
indexPic++;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
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);
|
||
|
||
}
|
||
}
|
||
|
||
protected void btnMenuReplay_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string codes = Grid1.SelectedRowID.Split(',')[0];
|
||
var checks = BLL.CheckControlService.GetCheckControl(codes);
|
||
|
||
if (checks != null)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", codes, "查看 - ")));
|
||
}
|
||
}
|
||
|
||
protected void btnQuery_Click(object sender, EventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
protected void btnRset_Click(object sender, EventArgs e)
|
||
{
|
||
drpSponsorUnit.SelectedIndex = 0;
|
||
drpCNProfessional.SelectedIndex = 0;
|
||
dpHandelStatus.SelectedIndex = 0;
|
||
drpQuestionType.SelectedIndex = 0;
|
||
drpUnitWork.SelectedIndex = 0;
|
||
txtStartTime.Text = "";
|
||
txtEndTime.Text = "";
|
||
BindGrid();
|
||
}
|
||
|
||
#region Linq获取列表转换焊材DateTable类型
|
||
public DataTable ToDataTable<T>(IEnumerable<T> data)
|
||
{
|
||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(T));
|
||
DataTable table = new DataTable();
|
||
foreach (PropertyDescriptor prop in properties)
|
||
{
|
||
table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
|
||
}
|
||
|
||
foreach (T item in data)
|
||
{
|
||
DataRow row = table.NewRow();
|
||
foreach (PropertyDescriptor prop in properties)
|
||
{
|
||
row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
|
||
}
|
||
table.Rows.Add(row);
|
||
}
|
||
|
||
return table;
|
||
}
|
||
#endregion
|
||
}
|
||
} |