Files
HJGL_DS/HJGL_DS/FineUIPro.Web/JGZL/QualityControlPointInspection.aspx.cs
T

598 lines
25 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Aspose.Words;
namespace FineUIPro.Web.JGZL
{
public partial class QualityControlPointInspection : PageBase
{
#region 定义项
/// <summary>
/// 主键
/// </summary>
private string QualityControlPointInspectionId
{
get
{
return (string)ViewState["QualityControlPointInspectionId"];
}
set
{
ViewState["QualityControlPointInspectionId"] = value;
}
}
/// <summary>
/// 项目Id
/// </summary>
private string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
#region 加载页面
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.drpProjectId.DataTextField = "ProjectCode";
this.drpProjectId.DataValueField = "ProjectId";
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
this.drpProjectId.DataBind();
Funs.FineUIPleaseSelect(this.drpProjectId);
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
this.InitTreeMenu();//加载树
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
this.ProjectId = this.tvControlItem.SelectedNodeID;
//this.BindGrid();
DataInfo();
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void DataInfo()
{
this.QualityControlPointInspectionId = string.Empty;
txtProfessional.Text = string.Empty;
txtConstructionStandards.Text = string.Empty;
txtControlPointName.Text = string.Empty;
txtConTeamGroup.Text = string.Empty;
txtCheckContents.Text = string.Empty;
txtProblems.Text = string.Empty;
txtConclusion.Text = string.Empty;
if (!string.IsNullOrEmpty(this.ProjectId))
{
var report = BLL.QualityControlPointInspectionService.GetQualityControlPointInspectionByProjectId(this.ProjectId);
if (report != null)
{
this.QualityControlPointInspectionId = report.QualityControlPointInspectionId;
this.txtProfessional.Text = report.Professional;
this.txtConstructionStandards.Text = report.ConstructionStandards;
this.txtControlPointName.Text = report.ControlPointName;
this.txtConTeamGroup.Text = report.ConTeamGroup;
this.txtCheckContents.Text = report.CheckContents;
this.txtProblems.Text = report.Problems;
this.txtConclusion.Text = report.Conclusion;
}
else
{
this.txtProfessional.Text = "管道安装工程";
this.txtConstructionStandards.Text = "SH/T3501-2021";
this.txtControlPointName.Text = "管道安装整体质量控制";
this.txtCheckContents.Text = "1、经检查该管道安装下料尺寸精准,切口平整、无毛刺、无裂纹;坡口形式、角度、钝边厚度符合焊接工艺要求,坡口表面清洁无油污、铁锈、杂质,偏差均控制在规范允许范围内;\r\n2、该管道组对间隙、错边量符合规范要求,同轴度达标;严格按照审批通过的焊接工艺施焊,焊工均持证上岗,焊接参数合规,焊缝外观无咬边、气孔、夹渣、未焊透等缺陷;\r\n3、该管道的安装坐标、标高、坡度精准复核,符合设计图纸要求,坡度方向适配介质输送需求,偏差均在规范允许范围内且安装位置无偏移、无错位;\r\n4、该管线的支吊架材质、规格、安装位置、间距符合设计及规范要求,安装牢固、平整,无松动、歪斜;固定支吊架、滑动支吊架类型适配,不妨碍管道热胀冷缩,焊接部位饱满无缺陷;\r\n5、焊缝外观质量验收合格,无各类表面缺陷;按设计及规范要求比例进行RT、UT、MT、PT等无损检测,检测报告完整,不合格焊缝及时返修,返修后重新检测合格;\r\n6、该管道按照设计要求使用水压行强度试验,试验压力及稳压时间达标,无渗漏、无变形、无异常声响;严密性试验压力合规,全线检查无渗漏。";
}
}
}
#endregion
#region 加载树项目
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "项目";
rootNode.ToolTip = "项目";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
{
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
}
foreach (var item in projects)
{
TreeNode rootProjectNode = new TreeNode();//定义根节点
rootProjectNode.Text = item.ProjectCode;
rootProjectNode.NodeID = item.ProjectId;
rootProjectNode.EnableClickEvent = true;
rootProjectNode.Expanded = true;
rootProjectNode.ToolTip = item.ProjectName;
rootProjectNode.CommandName = "项目名称";
rootNode.Nodes.Add(rootProjectNode);
}
}
#endregion
#region 点击TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (this.tvControlItem.SelectedNodeID != "0")
{
this.ProjectId = this.tvControlItem.SelectedNodeID;
DataInfo();
//this.BindGrid();
}
}
#endregion
#region 数据绑定
/// <summary>
/// 数据绑定
/// </summary>
//private void BindGrid()
//{
// //string projectIds = BLL.Base_ProjectService.GetStrOnProjectIds(this.CurrUser.UserId, "1");
// string strSql = @"SELECT * from JGZL_QualityControlPointInspection where 1=1";
// List<SqlParameter> listStr = new List<SqlParameter>();
// if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
// {
// strSql += " AND ProjectId = @ProjectId";
// listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID));
// }
// //else
// //{
// // strSql += " AND CHARINDEX(ProjectId,@ProjectId)>0 ";
// // listStr.Add(new SqlParameter("@ProjectId", projectIds));
// //}
// SqlParameter[] parameter = listStr.ToArray();
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// // 2.获取当前分页数据
// Grid1.RecordCount = tb.Rows.Count;
// //tb = GetFilteredTable(Grid1.FilteredData, tb);
// var table = this.GetPagedDataTable(Grid1, tb);
// Grid1.DataSource = table;
// Grid1.DataBind();
//}
#endregion
#region 分页排序
#region 页索引改变事件
/// <summary>
/// 页索引改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
//{
// BindGrid();
//}
#endregion
#region 排序
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void Grid1_Sort(object sender, GridSortEventArgs e)
//{
// BindGrid();
//}
#endregion
#region 分页选择下拉改变事件
/// <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();
//}
#endregion
#endregion
#region 查询
///<summary>
///查询
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
this.ProjectId = this.drpProjectId.SelectedValue;
this.InitTreeMenu();
this.tvControlItem.SelectedNodeID = this.ProjectId;
DataInfo();
}
/// <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 btnPrint_Click(object sender, EventArgs e)
{
string projectId = this.tvControlItem.SelectedNodeID;
if (projectId != null)
{
//if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID))
//{
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
BLL.Common.FastReportService.ResetData();
//var report = BLL.QualityControlPointInspectionService.GetQualityControlPointInspectionById(this.Grid1.SelectedRowID);
//if (report != null)
//{
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
keyValuePairs.Add("Professional", txtProfessional.Text.Trim());
keyValuePairs.Add("ConstructionStandards", txtConstructionStandards.Text.Trim());
keyValuePairs.Add("ControlPointName", txtControlPointName.Text.Trim());
keyValuePairs.Add("ConTeamGroup", txtConTeamGroup.Text.Trim());
keyValuePairs.Add("CheckContents", txtCheckContents.Text);
keyValuePairs.Add("Problems", txtProblems.Text);
keyValuePairs.Add("Conclusion", txtConclusion.Text);
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
//}
initTemplatePath = "File\\Fastreport\\JGZL\\质量控制点检查记录.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(WindowPrint.GetShowReference(String.Format("../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
//}
//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 btnAdd_Click(object sender, EventArgs e)
//{
// if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
// {
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityControlPointInspectionEdit.aspx?projectId={0}", this.tvControlItem.SelectedNodeID, "新增 - ")));
// }
// else
// {
// Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
// return;
// }
//}
/// <summary>
/// 双击编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
//{
// if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JGZL_QualityControlPointInspectionMenuId, BLL.Const.BtnModify))
// {
// if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
// {
// if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID))
// {
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityControlPointInspectionEdit.aspx?qualityControlPointInspectionId={0}", this.Grid1.SelectedRowID, "编辑 - ")));
// }
// else
// {
// Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
// return;
// }
// }
// else
// {
// Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
// return;
// }
// }
// else
// {
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
// }
//}
/// <summary>
/// 右键编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void btnMenuEdit_Click(object sender, EventArgs e)
//{
// if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JGZL_QualityControlPointInspectionMenuId, BLL.Const.BtnModify))
// {
// if (Grid1.SelectedRowIndexArray.Length == 0)
// {
// Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
// return;
// }
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityControlPointInspectionEdit.aspx?qualityControlPointInspectionId={0}", Grid1.SelectedRowID, "维护 - ")));
// }
// else
// {
// Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
// }
//}
/// <summary>
/// 右键删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void btnMenuDelete_Click(object sender, EventArgs e)
//{
// if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.JGZL_QualityControlPointInspectionMenuId, Const.BtnDelete))
// {
// if (Grid1.SelectedRowIndexArray.Length == 0)
// {
// Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
// return;
// }
// bool isShow = true;
// if (Grid1.SelectedRowIndexArray.Length > 1)
// {
// isShow = false;
// }
// bool isDelete = false;
// foreach (int rowIndex in Grid1.SelectedRowIndexArray)
// {
// string rowID = Grid1.DataKeys[rowIndex][0].ToString();
// if (judgementDelete(rowID, isShow))
// {
// isDelete = true;
// BLL.QualityControlPointInspectionService.DeleteQualityControlPointInspectionById(rowID);
// BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除质量控制点检查记录");
// }
// }
// if (isDelete)
// {
// ShowNotify("删除成功!", MessageBoxIcon.Success);
// }
// this.BindGrid();
// }
// else
// {
// Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
// }
//}
#region 判断是否可删除
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
//private bool judgementDelete(string id, bool isShow)
//{
// string content = string.Empty;
// if (string.IsNullOrEmpty(content))
// {
// return true;
// }
// else
// {
// if (isShow)
// {
// Alert.ShowInTop(content, MessageBoxIcon.Error);
// }
// return false;
// }
//}
#endregion
#endregion
#region 关闭弹出窗口及刷新页面
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void Window1_Close(object sender, WindowCloseEventArgs e)
//{
// this.InitTreeMenu();//加载树
// this.BindGrid();
//}
#endregion
#region 提交按钮
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.JGZL_QualityControlPointInspectionMenuId, Const.BtnSave))
{
Model.JGZL_QualityControlPointInspection newReport = new Model.JGZL_QualityControlPointInspection();
newReport.Professional = this.txtProfessional.Text.Trim();
newReport.ConstructionStandards = this.txtConstructionStandards.Text.Trim();
newReport.ControlPointName = this.txtControlPointName.Text.Trim();
newReport.ConTeamGroup = this.txtConTeamGroup.Text.Trim();
newReport.CheckContents = this.txtCheckContents.Text;
newReport.Problems = txtProblems.Text;
newReport.Conclusion = this.txtConclusion.Text;
if (!string.IsNullOrEmpty(this.QualityControlPointInspectionId))
{
newReport.QualityControlPointInspectionId = this.QualityControlPointInspectionId;
BLL.QualityControlPointInspectionService.UpdateQualityControlPointInspection(newReport);
}
else
{
newReport.ProjectId = this.ProjectId;
newReport.CompileMan = this.CurrUser.UserId;
newReport.CompileDate = DateTime.Now;
newReport.QualityControlPointInspectionId = SQLHelper.GetNewID(typeof(Model.JGZL_QualityControlPointInspection));
this.QualityControlPointInspectionId = newReport.QualityControlPointInspectionId;
BLL.QualityControlPointInspectionService.AddQualityControlPointInspection(newReport);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region 导出按钮
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
string rootPath = Server.MapPath("~/");
string initTemplatePath = string.Empty;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
string filePath = string.Empty;
string projectId = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(projectId))
{
initTemplatePath = Const.JGZL_QualityControlPointInspectionUrl;
uploadfilepath = rootPath + initTemplatePath;
newUrl = uploadfilepath.Replace("质量控制点检查记录导出模板", "质量控制点检查记录");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
Document doc = new Aspose.Words.Document(uploadfilepath);
Bookmark projectName = doc.Range.Bookmarks["ProjectName"];
if (projectName != null)
{
projectName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName;
}
Bookmark professional = doc.Range.Bookmarks["Professional"];
if (professional != null)
{
professional.Text = this.txtProfessional.Text;
}
Bookmark constructionStandards = doc.Range.Bookmarks["ConstructionStandards"];
if (constructionStandards != null)
{
constructionStandards.Text = this.txtConstructionStandards.Text;
}
Bookmark controlPointName = doc.Range.Bookmarks["ControlPointName"];
if (controlPointName != null)
{
controlPointName.Text = this.txtControlPointName.Text;
}
Bookmark conTeamGroup = doc.Range.Bookmarks["ConTeamGroup"];
if (conTeamGroup != null)
{
conTeamGroup.Text = this.txtConTeamGroup.Text;
}
Bookmark checkContents = doc.Range.Bookmarks["CheckContents"];
if (checkContents != null)
{
checkContents.Text = this.txtCheckContents.Text;
}
Bookmark problems = doc.Range.Bookmarks["Problems"];
if (problems != null)
{
problems.Text = this.txtProblems.Text;
}
Bookmark conclusion = doc.Range.Bookmarks["Conclusion"];
if (conclusion != null)
{
conclusion.Text = this.txtConclusion.Text;
}
doc.Save(newUrl);
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
{
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
return;
}
}
#endregion
}
}