2026-08-10 17:58:55 +08:00
|
|
|
using BLL;
|
|
|
|
|
using System;
|
2026-08-21 15:22:24 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.IO;
|
2026-08-10 17:58:55 +08:00
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingManage
|
|
|
|
|
{
|
|
|
|
|
public partial class WeldAppearanceCheck : PageBase
|
|
|
|
|
{
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2026-08-21 15:22:24 +08:00
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
BindCheckCodes();
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BindCheckCodes()
|
|
|
|
|
{
|
|
|
|
|
foreach (string checkCode in WeldAppearanceCheckService.GetCheckCodes(CurrUser.LoginProjectId))
|
|
|
|
|
{
|
|
|
|
|
ddlCheckCode.Items.Add(new FineUIPro.ListItem(checkCode, checkCode));
|
|
|
|
|
}
|
2026-08-10 17:58:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BindGrid()
|
|
|
|
|
{
|
2026-08-21 15:22:24 +08:00
|
|
|
var result = GetCurrentPageData();
|
2026-08-10 17:58:55 +08:00
|
|
|
Grid1.RecordCount = result.Item2;
|
|
|
|
|
Grid1.DataSource = result.Item1;
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 15:22:24 +08:00
|
|
|
private Tuple<List<Model.WeldAppearanceCheckItem>, int> GetCurrentPageData()
|
|
|
|
|
{
|
|
|
|
|
return WeldAppearanceCheckService.GetList(CurrUser.LoginProjectId,
|
|
|
|
|
(ddlCheckCode.SelectedValue ?? string.Empty).Trim(),
|
|
|
|
|
txtPipelineCode.Text.Trim(), txtWeldJointCode.Text.Trim(), ddlQualified.SelectedValue,
|
|
|
|
|
Grid1.PageIndex, Grid1.PageSize);
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-10 17:58:55 +08:00
|
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); }
|
|
|
|
|
protected void btnQuery_Click(object sender, EventArgs e) { Grid1.PageIndex = 0; BindGrid(); }
|
|
|
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将附件地址转换为列表缩略图。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="photoUrl">以逗号分隔的照片地址。</param>
|
|
|
|
|
/// <returns>照片缩略图HTML。</returns>
|
|
|
|
|
protected string ConvertImageUrlByImage(object photoUrl)
|
|
|
|
|
{
|
|
|
|
|
if (photoUrl == null || string.IsNullOrWhiteSpace(photoUrl.ToString()))
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string html = "<table cellpadding='5' cellspacing='5' style=\"width: 100%\">";
|
|
|
|
|
foreach (string item in photoUrl.ToString().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
|
|
|
|
|
{
|
|
|
|
|
string imageUrl = "../../" + item.Trim().Replace('\\', '/');
|
|
|
|
|
html += "<tr><td align='center'><img class='img' width='100' height='100' src='"
|
|
|
|
|
+ HttpUtility.HtmlAttributeEncode(imageUrl) + "' alt='外观检测照片' /></td></tr>";
|
|
|
|
|
}
|
|
|
|
|
return html + "</table>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (HasPower(Const.BtnAdd)) PageContext.RegisterStartupScript(Window1.GetShowReference("WeldAppearanceCheckEdit.aspx"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void btnEdit_Click(object sender, EventArgs e) { OpenSelectedRecord(); }
|
|
|
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { OpenSelectedRecord(); }
|
|
|
|
|
|
|
|
|
|
protected void btnDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!EnsureSelected() || !HasPower(Const.BtnDelete)) return;
|
|
|
|
|
WeldAppearanceCheckService.Delete(Grid1.SelectedRowID);
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 15:22:24 +08:00
|
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string checkCode = (ddlCheckCode.SelectedValue ?? string.Empty).Trim();
|
|
|
|
|
if (string.IsNullOrEmpty(checkCode))
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("请选择检测编号!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!HasPower(Const.BtnPrint))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var printResult = WeldAppearanceCheckService.GetList(CurrUser.LoginProjectId, checkCode,
|
|
|
|
|
txtPipelineCode.Text.Trim(), txtWeldJointCode.Text.Trim(), ddlQualified.SelectedValue,
|
|
|
|
|
0, int.MaxValue);
|
|
|
|
|
List<Model.WeldAppearanceCheckItem> printItems = printResult.Item1;
|
|
|
|
|
if (printItems.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("当前筛选条件没有可打印的焊口记录!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable reportData = CreateReportData(printItems);
|
|
|
|
|
var parameters = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "ProjectName", ProjectService.GetProjectNameByProjectId(CurrUser.LoginProjectId) },
|
|
|
|
|
{ "CheckCode", checkCode },
|
|
|
|
|
{ "NDTMethod", "RT" },
|
|
|
|
|
// 报检数量使用本次实际打印的焊口总数,不包含版式补齐的空行。
|
|
|
|
|
{ "InspectionCount", printItems.Count.ToString() },
|
|
|
|
|
{ "DetectionRate", string.Empty }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FastReportService.ResetData();
|
|
|
|
|
FastReportService.AddFastreportTable(reportData);
|
|
|
|
|
FastReportService.AddFastreportParameter(parameters);
|
|
|
|
|
|
|
|
|
|
string rootPath = Server.MapPath("~/");
|
|
|
|
|
string initTemplatePath = Const.WeldAppearanceCheckReportTemplateUrl;
|
|
|
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|
|
|
|
{
|
|
|
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(string.Format(
|
|
|
|
|
"~/Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("打印模板不存在!", MessageBoxIcon.Warning);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static DataTable CreateReportData(List<Model.WeldAppearanceCheckItem> items)
|
|
|
|
|
{
|
|
|
|
|
var table = new DataTable("Data");
|
|
|
|
|
table.Columns.Add("RowNumber", typeof(int));
|
|
|
|
|
table.Columns.Add("PipelineCode", typeof(string));
|
|
|
|
|
table.Columns.Add("WeldJointCode", typeof(string));
|
|
|
|
|
table.Columns.Add("WelderCode", typeof(string));
|
|
|
|
|
table.Columns.Add("Specification", typeof(string));
|
|
|
|
|
table.Columns.Add("MaterialCode", typeof(string));
|
|
|
|
|
table.Columns.Add("WeldingLocation", typeof(string));
|
|
|
|
|
table.Columns.Add("WeldingMethodCode", typeof(string));
|
|
|
|
|
table.Columns.Add("WeldingMaterial", typeof(string));
|
|
|
|
|
table.Columns.Add("ItemCode", typeof(string));
|
|
|
|
|
table.Columns.Add("BatchCode", typeof(string));
|
|
|
|
|
table.Columns.Add("Remark", typeof(string));
|
|
|
|
|
|
|
|
|
|
const int regularPageRowCount = 14;
|
|
|
|
|
const int lastPageRowCount = 12;
|
|
|
|
|
int reportRowCount = items.Count <= lastPageRowCount
|
|
|
|
|
? lastPageRowCount
|
|
|
|
|
: lastPageRowCount + (int)Math.Ceiling((items.Count - lastPageRowCount)
|
|
|
|
|
/ (decimal)regularPageRowCount) * regularPageRowCount;
|
|
|
|
|
for (int i = 0; i < reportRowCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i < items.Count)
|
|
|
|
|
{
|
|
|
|
|
Model.WeldAppearanceCheckItem item = items[i];
|
|
|
|
|
// 明细字段严格对应检查表模板;物料代码和炉批号当前业务无来源,保持空白待签填。
|
|
|
|
|
table.Rows.Add(i + 1, item.PipelineCode, item.WeldJointCode, item.WelderCode,
|
|
|
|
|
item.Specification, item.MaterialCode, item.WeldingLocation, item.WeldingMethodCode,
|
|
|
|
|
item.WeldingMaterial, string.Empty, string.Empty, item.Remark);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 普通页显示14行、末页显示12行,不足部分补空行,使签字区紧跟末页数据区。
|
|
|
|
|
table.Rows.Add(i + 1, string.Empty, string.Empty, string.Empty, string.Empty,
|
|
|
|
|
string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
|
|
|
|
|
string.Empty, string.Empty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-10 17:58:55 +08:00
|
|
|
private void OpenSelectedRecord()
|
|
|
|
|
{
|
|
|
|
|
if (!EnsureSelected() || !HasPower(Const.BtnModify)) return;
|
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference("WeldAppearanceCheckEdit.aspx?AppearanceCheckId=" + Grid1.SelectedRowID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool EnsureSelected()
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length > 0) return true;
|
|
|
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool HasPower(string button)
|
|
|
|
|
{
|
|
|
|
|
bool hasPower = CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.PersonId,
|
|
|
|
|
Const.HJGL_WeldAppearanceCheckMenuId, button);
|
|
|
|
|
if (!hasPower) Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
|
|
|
return hasPower;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|