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

499 lines
20 KiB
C#
Raw Normal View History

2026-01-26 19:34:13 +08:00
using BLL;
2026-03-13 13:17:09 +08:00
using Model;
using Newtonsoft.Json.Linq;
2026-01-26 19:34:13 +08:00
using System;
using System.Collections.Generic;
using System.Data;
2026-03-13 13:17:09 +08:00
using System.Data.SqlClient;
using System.IO;
2026-01-26 19:34:13 +08:00
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.JGZL
{
public partial class PipeFittingInspectionRecord : PageBase
{
2026-03-13 13:17:09 +08:00
#region
/// <summary>
/// 主键
/// </summary>
private string RecordId
{
get
{
return (string)ViewState["RecordId"];
}
set
{
ViewState["RecordId"] = value;
}
}
/// <summary>
/// 项目Id
/// </summary>
private string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
2026-03-17 16:35:36 +08:00
/// <summary>
/// 定义集合
/// </summary>
private static List<Model.JGZL_PipeFittingInspectionRecord> list = new List<JGZL_PipeFittingInspectionRecord>();
2026-03-13 13:17:09 +08:00
#endregion
2026-01-26 19:34:13 +08:00
#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;
2026-03-13 13:17:09 +08:00
this.ProjectId = this.tvControlItem.SelectedNodeID;
2026-01-26 19:34:13 +08:00
this.BindGrid();
}
}
#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")
{
2026-03-13 13:17:09 +08:00
this.ProjectId = this.tvControlItem.SelectedNodeID;
2026-01-26 19:34:13 +08:00
this.BindGrid();
}
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
2026-03-17 16:35:36 +08:00
string strSql = @"SELECT * from JGZL_PipeFittingInspectionRecord where ProjectId=@projectId order by CompileDate ";
2026-01-26 19:34:13 +08:00
List<SqlParameter> listStr = new List<SqlParameter>();
2026-03-13 13:17:09 +08:00
listStr.Add(new SqlParameter("@projectId", this.ProjectId));
2026-01-26 19:34:13 +08:00
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
2026-03-17 16:35:36 +08:00
Grid1.DataBind();
2026-01-26 19:34:13 +08:00
}
#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)
{
2026-03-13 13:17:09 +08:00
this.ProjectId = this.drpProjectId.SelectedValue;
2026-01-26 19:34:13 +08:00
this.InitTreeMenu();
2026-03-13 13:17:09 +08:00
this.tvControlItem.SelectedNodeID = this.ProjectId;
2026-01-26 19:34:13 +08:00
this.BindGrid();
}
/// <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)
{
2026-03-13 13:17:09 +08:00
if (!string.IsNullOrEmpty(this.ProjectId))
2026-01-26 19:34:13 +08:00
{
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
BLL.Common.FastReportService.ResetData();
2026-01-27 16:10:01 +08:00
string strSql = @"SELECT * from JGZL_PipeFittingInspectionRecord where ProjectId = @ProjectId order by CompileDate ";
2026-01-26 19:34:13 +08:00
List<SqlParameter> listStr = new List<SqlParameter>();
2026-03-13 13:17:09 +08:00
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
2026-01-26 19:34:13 +08:00
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
DataTable dt = new DataTable();
dt.TableName = "Data";
2026-01-27 16:10:01 +08:00
dt.Columns.Add("Name");
dt.Columns.Add("ContractNo");
dt.Columns.Add("ArrivalUnit");
dt.Columns.Add("ArrivalNum");
dt.Columns.Add("MaterialCertificateNumber");
dt.Columns.Add("Material");
dt.Columns.Add("Specifications");
dt.Columns.Add("InspectionNum");
dt.Columns.Add("ODVariation");
dt.Columns.Add("IDVariation");
dt.Columns.Add("WallVariation");
dt.Columns.Add("OtherVariation");
dt.Columns.Add("AppearanceQuality");
dt.Columns.Add("Result");
2026-01-26 19:34:13 +08:00
DataRow[] rows = tb.DefaultView.ToTable().Select();
foreach (var row in rows)
{
var newRow = dt.NewRow();
2026-01-27 16:10:01 +08:00
newRow["Name"] = row["Name"].ToString();
newRow["ContractNo"] = row["ContractNo"].ToString();
newRow["ArrivalUnit"] = row["ArrivalUnit"].ToString();
newRow["ArrivalNum"] = row["ArrivalNum"].ToString();
newRow["MaterialCertificateNumber"] = row["MaterialCertificateNumber"].ToString();
newRow["Material"] = row["Material"].ToString();
newRow["Specifications"] = row["Specifications"].ToString();
newRow["InspectionNum"] = row["InspectionNum"].ToString();
newRow["ODVariation"] = row["ODVariation"].ToString();
newRow["IDVariation"] = row["IDVariation"].ToString();
newRow["WallVariation"] = row["WallVariation"].ToString();
newRow["OtherVariation"] = row["OtherVariation"].ToString();
newRow["AppearanceQuality"] = row["AppearanceQuality"].ToString();
newRow["Result"] = row["Result"].ToString();
2026-01-26 19:34:13 +08:00
dt.Rows.Add(newRow);
}
BLL.Common.FastReportService.AddFastreportTable(dt);
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
2026-03-13 13:17:09 +08:00
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(this.ProjectId).ProjectName);
2026-01-26 19:34:13 +08:00
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
2026-01-27 16:10:01 +08:00
initTemplatePath = "File\\Fastreport\\JGZL\\管件宏观检查记录表.frx";
2026-01-26 19:34:13 +08:00
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;
}
}
#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))
{
2026-03-13 13:17:09 +08:00
JArray teamGroupData = Grid1.GetMergedData();
List<JObject> list = new List<JObject>();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
list.Add(values);
}
JObject defaultObj = new JObject
{
2026-03-17 16:35:36 +08:00
{ "RecordId", Guid.NewGuid() },
{ "Name", ""},
{ "ContractNo", "" },
{ "ArrivalUnit", "" },
{ "ArrivalNum", "" },
{ "MaterialCertificateNumber", "" },
{ "Material", "" },
{ "Specifications", "" },
{ "InspectionNum", "" },
{ "ODVariation", "" },
{ "IDVariation", "" },
{ "WallVariation", "" },
{ "OtherVariation", "" },
{ "AppearanceQuality", "" },
{ "Result", "" },
{
"Delete3",
String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>",
GetDeleteScriptGrid1(), IconHelper.GetResolvedIconUrl(Icon.Delete))
}
};
2026-03-13 13:17:09 +08:00
list.Add(defaultObj);
Grid1.DataSource = list;
Grid1.DataBind();
2026-01-26 19:34:13 +08:00
}
else
{
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
return;
}
}
2026-03-13 13:17:09 +08:00
protected void Grid1_PreDataBound(object sender, EventArgs e)
2026-01-26 19:34:13 +08:00
{
2026-03-13 13:17:09 +08:00
// 设置LinkButtonField的点击客户端事件
LinkButtonField deleteField = Grid1.FindColumn("Delete3") as LinkButtonField;
deleteField.OnClientClick = GetDeleteScriptGrid1();
2026-01-26 19:34:13 +08:00
}
/// <summary>
2026-03-13 13:17:09 +08:00
/// 删除提示
2026-01-26 19:34:13 +08:00
/// </summary>
2026-03-13 13:17:09 +08:00
/// <returns></returns>
private string GetDeleteScriptGrid1()
2026-01-26 19:34:13 +08:00
{
2026-03-13 13:17:09 +08:00
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question,
Grid1.GetDeleteSelectedRowsReference(), String.Empty);
2026-01-26 19:34:13 +08:00
}
2026-03-13 13:17:09 +08:00
#endregion
2026-01-26 19:34:13 +08:00
2026-03-13 13:17:09 +08:00
#region
2026-01-26 19:34:13 +08:00
/// <summary>
2026-03-13 13:17:09 +08:00
/// 保存按钮
2026-01-26 19:34:13 +08:00
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2026-03-13 13:17:09 +08:00
protected void btnSave_Click(object sender, EventArgs e)
2026-01-26 19:34:13 +08:00
{
2026-03-13 13:17:09 +08:00
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId,
Const.JGZL_PipeFittingInspectionRecordMenuId, Const.BtnSave))
{
BLL.PipeFittingInspectionRecordService.DeleteListsByProjectId(this.ProjectId);
List<Model.JGZL_PipeFittingInspectionRecord> lists = new List<JGZL_PipeFittingInspectionRecord>();
JArray teamGroupData = Grid1.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
2026-01-26 19:34:13 +08:00
{
2026-03-13 13:17:09 +08:00
JObject values = teamGroupRow.Value<JObject>("values");
int rowIndex = teamGroupRow.Value<int>("index");
Model.JGZL_PipeFittingInspectionRecord newDetail = new Model.JGZL_PipeFittingInspectionRecord
{
RecordId = values.Value<string>("RecordId"),
ProjectId = this.ProjectId,
Name = values.Value<string>("Name"),
ContractNo = values.Value<string>("ContractNo"),
ArrivalUnit = values.Value<string>("ArrivalUnit"),
ArrivalNum = Funs.GetNewInt(values.Value<string>("ArrivalNum")),
MaterialCertificateNumber = values.Value<string>("MaterialCertificateNumber"),
Material = values.Value<string>("Material"),
Specifications = values.Value<string>("Specifications"),
InspectionNum = Funs.GetNewInt(values.Value<string>("InspectionNum")),
ODVariation = values.Value<string>("ODVariation"),
IDVariation = values.Value<string>("IDVariation"),
WallVariation = values.Value<string>("WallVariation"),
OtherVariation = values.Value<string>("OtherVariation"),
AppearanceQuality = values.Value<string>("AppearanceQuality"),
Result = values.Value<string>("Result"),
};
lists.Add(newDetail);
2026-01-26 19:34:13 +08:00
}
2026-03-13 13:17:09 +08:00
try
2026-01-26 19:34:13 +08:00
{
2026-03-13 13:17:09 +08:00
if (lists.Count > 0)
2026-01-26 19:34:13 +08:00
{
2026-03-13 13:17:09 +08:00
Funs.DB.JGZL_PipeFittingInspectionRecord.InsertAllOnSubmit(lists);
ShowNotify("保存成功!", MessageBoxIcon.Success);
2026-03-17 16:35:36 +08:00
this.Grid1.DataSource = lists;
this.Grid1.DataBind();
2026-01-26 19:34:13 +08:00
}
2026-03-13 13:17:09 +08:00
Funs.DB.SubmitChanges();
2026-01-26 19:34:13 +08:00
}
2026-03-13 13:17:09 +08:00
catch (Exception)
2026-01-26 19:34:13 +08:00
{
2026-03-13 13:17:09 +08:00
return;
2026-01-26 19:34:13 +08:00
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
2026-03-13 13:17:09 +08:00
return;
2026-01-26 19:34:13 +08:00
}
}
#endregion
2026-03-16 16:51:55 +08:00
2026-03-17 16:35:36 +08:00
#region
/// <summary>
/// 复制
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2026-03-16 16:51:55 +08:00
protected void btnCopy_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
JArray teamGroupData = Grid1.GetMergedData();
List<JObject> list = new List<JObject>();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
list.Add(values);
}
2026-03-17 16:35:36 +08:00
// 1. 获取选中行索引并校验
2026-03-16 16:51:55 +08:00
int index = Grid1.SelectedRowIndex;
2026-03-17 16:35:36 +08:00
if (index < 0 || index >= Grid1.Rows.Count)
{
Alert.ShowInTop("请选中要复制的数据行!", MessageBoxIcon.Warning);
return;
}
string name = Grid1.Rows[index].Values[1].ToString() ?? "";
string contractNo = Grid1.Rows[index].Values[2].ToString() ?? "";
string arrivalUnit = Grid1.Rows[index].Values[4].ToString() ?? "";
string arrivalNum = Grid1.Rows[index].Values[5].ToString() ?? "";
string materialCertificateNumber = Grid1.Rows[index].Values[6].ToString() ?? "";
string material = Grid1.Rows[index].Values[7].ToString() ?? "";
string specifications = Grid1.Rows[index].Values[8].ToString() ?? "";
string inspectionNum = Grid1.Rows[index].Values[9].ToString() ?? "";
string oDVariation = Grid1.Rows[index].Values[11].ToString() ?? "";
string iDVariation = Grid1.Rows[index].Values[12].ToString() ?? "";
string wallVariation = Grid1.Rows[index].Values[13].ToString() ?? "";
string otherVariation = Grid1.Rows[index].Values[14].ToString() ?? "";
string appearanceQuality = Grid1.Rows[index].Values[15].ToString() ?? "";
string result = Grid1.Rows[index].Values[16].ToString() ?? "";
if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(contractNo) && string.IsNullOrEmpty(arrivalUnit) && string.IsNullOrEmpty(arrivalNum) && string.IsNullOrEmpty(materialCertificateNumber) && string.IsNullOrEmpty(material) && string.IsNullOrEmpty(specifications) && string.IsNullOrEmpty(inspectionNum) && string.IsNullOrEmpty(oDVariation) && string.IsNullOrEmpty(iDVariation) && string.IsNullOrEmpty(wallVariation) && string.IsNullOrEmpty(otherVariation) && string.IsNullOrEmpty(appearanceQuality) && string.IsNullOrEmpty(result))
2026-03-16 16:51:55 +08:00
{
2026-03-17 16:35:36 +08:00
Alert.ShowInTop("请先保存数据!", MessageBoxIcon.Warning);
return;
2026-03-16 16:51:55 +08:00
}
2026-03-17 16:35:36 +08:00
JObject defaultObj = new JObject
{
{ "RecordId", Guid.NewGuid() },
{ "Name",name},
{ "ContractNo",contractNo},
{ "ArrivalUnit",arrivalUnit },
{ "ArrivalNum",arrivalNum },
{ "MaterialCertificateNumber", materialCertificateNumber},
{ "Material",material },
{ "Specifications", specifications },
{ "InspectionNum",inspectionNum },
{ "ODVariation",oDVariation},
{ "IDVariation",iDVariation },
{ "WallVariation",wallVariation },
{ "OtherVariation", otherVariation},
{ "AppearanceQuality", appearanceQuality },
{ "Result",result },
{
"Delete3",
String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>",
GetDeleteScriptGrid1(), IconHelper.GetResolvedIconUrl(Icon.Delete))
}
};
2026-03-16 16:51:55 +08:00
list.Add(defaultObj);
Grid1.DataSource = list;
Grid1.DataBind();
}
else
{
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
return;
}
}
2026-03-17 16:35:36 +08:00
#endregion
2026-01-26 19:34:13 +08:00
}
}