746 lines
32 KiB
C#
746 lines
32 KiB
C#
using BLL;
|
|
using FastReport.DevComponents.DotNetBar;
|
|
using Model;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
namespace FineUIPro.Web.JGZL
|
|
{
|
|
public partial class SteelPipeCheckRecord : PageBase
|
|
{
|
|
#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; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 附件路径
|
|
/// </summary>
|
|
public string FullAttachUrl
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["FullAttachUrl"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["FullAttachUrl"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义集合
|
|
/// </summary>
|
|
private static List<Model.JGZL_SteelPipeCheckRecordItem1> items = new List<Model.JGZL_SteelPipeCheckRecordItem1>();
|
|
|
|
#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.ProjectId = this.drpProjectId.SelectedValue;
|
|
|
|
this.InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
#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");
|
|
|
|
// 默认显示选中的项目
|
|
string selectedProjectId = this.drpProjectId.SelectedValue;
|
|
if (!string.IsNullOrEmpty(selectedProjectId) && selectedProjectId != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == selectedProjectId).ToList();
|
|
|
|
// 如果项目存在,则选中该节点
|
|
if (projects.Any())
|
|
{
|
|
this.tvControlItem.SelectedNodeID = selectedProjectId;
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
if (this.tvControlItem.SelectedNodeID != "0")
|
|
{
|
|
DataInfo();
|
|
}
|
|
}
|
|
#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;
|
|
this.DataInfo();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
|
|
private void DataInfo()
|
|
{
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
var report = SteelPipeCheckRecordService.GetSteelPipeReportByProjectId(this.ProjectId);
|
|
if (report != null)
|
|
{
|
|
this.RecordId = report.RecordId;
|
|
this.txtContractCode.Text = report.ContractCode;
|
|
this.txtArrivalDate.Text = string.Format("{0:yyyy-MM-dd}", report.ArrivalDate);
|
|
this.txtExecutionStandard.Text = report.ExecutionStandard;
|
|
this.drpCrack.SelectedValue = report.Crack;
|
|
this.drpSlagInclusion.SelectedValue = report.SlagInclusion;
|
|
this.drpShrinkageHole.SelectedValue = report.ShrinkageHole;
|
|
this.drpHeavyLeather.SelectedValue = report.HeavyLeather;
|
|
this.drpOther.SelectedValue = report.Other;
|
|
//this.imgPicture.ImageUrl = report.Remark;
|
|
BindGrid();
|
|
}
|
|
else
|
|
{
|
|
//默认
|
|
this.RecordId = string.Empty;
|
|
this.txtContractCode.Text = BLL.Base_ProjectService.GetProjectCode(this.ProjectId);
|
|
this.txtArrivalDate.Text = string.Empty;
|
|
this.txtExecutionStandard.Text = "SH/T3501-2021";
|
|
this.drpCrack.SelectedValue = "合格";
|
|
this.drpSlagInclusion.SelectedValue = "合格";
|
|
this.drpShrinkageHole.SelectedValue = "合格";
|
|
this.drpHeavyLeather.SelectedValue = "合格";
|
|
this.drpOther.SelectedValue = "合格";
|
|
//this.imgPicture.ImageUrl = string.Empty;
|
|
|
|
InitGrid1(this.ProjectId);
|
|
}
|
|
BindGrid2();
|
|
}
|
|
}
|
|
|
|
private void InitGrid1(string projectId)
|
|
{
|
|
var reportLists = (from x in Funs.DB.JGZL_SteelPipeCheckRecordItem1
|
|
join y in Funs.DB.JGZL_SteelPipeCheckRecord on x.RecordId equals y.RecordId
|
|
where y.ProjectId == projectId
|
|
select x).ToList();
|
|
if (reportLists.Count > 0)
|
|
{
|
|
var isoLists = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByProjectId(projectId);
|
|
foreach (var item in isoLists)
|
|
{
|
|
var iso = (from x in Funs.DB.JGZL_SteelPipeCheckRecordItem1
|
|
join y in Funs.DB.JGZL_SteelPipeCheckRecord on x.RecordId equals y.RecordId
|
|
join z in Funs.DB.HJGL_BS_Steel on x.Material equals z.STE_Code
|
|
where y.ProjectId == projectId && z.STE_ID == item.STE_ID
|
|
&& x.Specifications == (from j in Funs.DB.HJGL_PW_JointInfo where j.ISO_ID == item.ISO_ID select j.JOT_JointDesc).FirstOrDefault()
|
|
select x).FirstOrDefault();
|
|
if (iso == null)
|
|
{
|
|
Model.JGZL_SteelPipeCheckRecordItem1 newReport = new Model.JGZL_SteelPipeCheckRecordItem1();
|
|
newReport.RecordItemId = SQLHelper.GetNewID();
|
|
newReport.Name = "无缝钢管";
|
|
if (!string.IsNullOrEmpty(item.STE_ID))
|
|
{
|
|
newReport.Material = BLL.HJGL_MaterialService.GetSteelBySteID(item.STE_ID).STE_Code;
|
|
}
|
|
newReport.Specifications = HttpUtility.HtmlDecode((from x in Funs.DB.HJGL_PW_JointInfo where x.ProjectId == projectId && x.ISO_ID == item.ISO_ID select x.JOT_JointDesc).FirstOrDefault());
|
|
reportLists.Add(newReport);
|
|
}
|
|
}
|
|
this.Grid1.DataSource = reportLists;
|
|
this.Grid1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
items.Clear();
|
|
var isoLists = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByProjectId(projectId);
|
|
foreach (var iso in isoLists)
|
|
{
|
|
Model.JGZL_SteelPipeCheckRecordItem1 newReport = new Model.JGZL_SteelPipeCheckRecordItem1();
|
|
newReport.RecordItemId = SQLHelper.GetNewID();
|
|
newReport.Name = "无缝钢管";
|
|
if (!string.IsNullOrEmpty(iso.STE_ID))
|
|
{
|
|
newReport.Material = BLL.HJGL_MaterialService.GetSteelBySteID(iso.STE_ID).STE_Code;
|
|
}
|
|
newReport.Specifications = HttpUtility.HtmlDecode((from x in Funs.DB.HJGL_PW_JointInfo where x.ProjectId == projectId && x.ISO_ID == iso.ISO_ID select x.JOT_JointDesc).FirstOrDefault());
|
|
items.Add(newReport);
|
|
}
|
|
this.Grid1.DataSource = items;
|
|
this.Grid1.DataBind();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT * from JGZL_SteelPipeCheckRecordItem1 where RecordId=@recordId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@recordId", this.RecordId));
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
private void BindGrid2()
|
|
{
|
|
string strSql = @"SELECT * from JGZL_SteelPipeCheckRecordItem2 where RecordId=@recordId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@recordId", this.RecordId));
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
Grid2.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid2, tb);
|
|
Grid2.DataSource = table;
|
|
Grid2.DataBind();
|
|
}
|
|
#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)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
BLL.Common.FastReportService.ResetData();
|
|
|
|
var report = BLL.SteelPipeCheckRecordService.GetSteelPipeReportById(this.RecordId);
|
|
if (report != null)
|
|
{
|
|
DataTable dtMainData = new DataTable();
|
|
dtMainData.TableName = "MData";
|
|
dtMainData.Columns.Add("ProjectName");
|
|
dtMainData.Columns.Add("ContractCode");
|
|
dtMainData.Columns.Add("ArrivalDate");
|
|
dtMainData.Columns.Add("ExecutionStandard");
|
|
dtMainData.Columns.Add("Crack");
|
|
dtMainData.Columns.Add("SlagInclusion");
|
|
dtMainData.Columns.Add("ShrinkageHole");
|
|
dtMainData.Columns.Add("HeavyLeather");
|
|
dtMainData.Columns.Add("Other");
|
|
//dtMainData.Columns.Add("ImageUrl");
|
|
|
|
var newMainData = dtMainData.NewRow();
|
|
newMainData["ProjectName"] = BLL.Base_ProjectService.GetProjectByProjectId(this.ProjectId).ProjectName;
|
|
newMainData["ContractCode"] = report.ContractCode;
|
|
string arrivalDate = report.ArrivalDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.ArrivalDate) : "";
|
|
newMainData["ArrivalDate"] = arrivalDate;
|
|
newMainData["ExecutionStandard"] = report.ExecutionStandard;
|
|
newMainData["Crack"] = report.Crack;
|
|
newMainData["SlagInclusion"] = report.SlagInclusion;
|
|
newMainData["ShrinkageHole"] = report.ShrinkageHole;
|
|
newMainData["HeavyLeather"] = report.HeavyLeather;
|
|
newMainData["Other"] = report.Other;
|
|
//if (!string.IsNullOrEmpty(report.Remark))
|
|
//{
|
|
// newMainData["ImageUrl"] = Funs.RootPath + report.Remark.Substring(report.Remark.IndexOf('/'));
|
|
//}
|
|
dtMainData.Rows.Add(newMainData);
|
|
|
|
BLL.Common.FastReportService.AddFastreportTable(dtMainData);
|
|
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
//keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
|
|
//keyValuePairs.Add("ContractCode", report.ContractCode);
|
|
//keyValuePairs.Add("ArrivalDate", string.Format("{0:yyyy.MM.dd}", report.ArrivalDate));
|
|
//keyValuePairs.Add("ExecutionStandard", report.ExecutionStandard);
|
|
//keyValuePairs.Add("Crack", report.Crack);
|
|
//keyValuePairs.Add("SlagInclusion", report.SlagInclusion);
|
|
//keyValuePairs.Add("ShrinkageHole", report.ShrinkageHole);
|
|
//keyValuePairs.Add("HeavyLeather", report.HeavyLeather);
|
|
//keyValuePairs.Add("Other", report.Other);
|
|
//keyValuePairs.Add("Remark", report.Remark);
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
|
|
////加载图片
|
|
//var imageUrl = (from x in Funs.DB.AttachFile where x.ToKeyId == report.RecordId && x.MenuId == BLL.Const.JGZL_SteelPipeCheckRecordMenuId select x).FirstOrDefault();
|
|
//if (imageUrl != null)
|
|
//{
|
|
// DataTable imagedt = new DataTable();
|
|
// imagedt.TableName = "ImageData";
|
|
// imagedt.Columns.Add("ImageUrl");
|
|
// var newRowsImage = imagedt.NewRow();
|
|
// newRowsImage["ImageUrl"] = Funs.RootPath + imageUrl.AttachUrl;
|
|
// imagedt.Rows.Add(newRowsImage);
|
|
// BLL.Common.FastReportService.AddFastreportTable(imagedt);
|
|
//}
|
|
|
|
//明细表1
|
|
string strSql = @"SELECT * from JGZL_SteelPipeCheckRecordItem1 where RecordId=@recordId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@recordId", this.RecordId));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
DataTable dt = new DataTable();
|
|
dt.TableName = "Data";
|
|
dt.Columns.Add("Name");
|
|
dt.Columns.Add("Material");
|
|
dt.Columns.Add("Specifications");
|
|
dt.Columns.Add("Quantity");
|
|
dt.Columns.Add("MaterialCertificateCode");
|
|
dt.Columns.Add("HeatCode");
|
|
dt.Columns.Add("MaterialCertificateSelfNumber");
|
|
|
|
DataRow[] rows = tb.DefaultView.ToTable().Select();
|
|
foreach (var row in rows)
|
|
{
|
|
var newRows = dt.NewRow();
|
|
newRows["Name"] = row["Name"].ToString();
|
|
newRows["Material"] = row["Material"].ToString();
|
|
newRows["Specifications"] = row["Specifications"].ToString();
|
|
newRows["Quantity"] = row["Quantity"].ToString();
|
|
newRows["MaterialCertificateCode"] = row["MaterialCertificateCode"].ToString();
|
|
newRows["HeatCode"] = row["HeatCode"].ToString();
|
|
newRows["MaterialCertificateSelfNumber"] = row["MaterialCertificateSelfNumber"].ToString();
|
|
|
|
dt.Rows.Add(newRows);
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
|
|
|
//明细表2
|
|
string strSql2 = @"SELECT * from JGZL_SteelPipeCheckRecordItem2 where RecordId=@recordId ";
|
|
List<SqlParameter> listStr2 = new List<SqlParameter>();
|
|
listStr2.Add(new SqlParameter("@recordId", this.RecordId));
|
|
SqlParameter[] parameter2 = listStr2.ToArray();
|
|
DataTable tb2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
|
|
|
DataTable dt2 = new DataTable();
|
|
dt2.TableName = "ItemData";
|
|
dt2.Columns.Add("Num");
|
|
dt2.Columns.Add("Part1");
|
|
dt2.Columns.Add("Part2");
|
|
dt2.Columns.Add("Part3");
|
|
dt2.Columns.Add("Part4");
|
|
dt2.Columns.Add("InnerDiameter");
|
|
dt2.Columns.Add("OuterDiameter");
|
|
dt2.Columns.Add("Lengths");
|
|
|
|
DataRow[] rows2 = tb2.DefaultView.ToTable().Select();
|
|
int i = 0;
|
|
foreach (var row in rows2)
|
|
{
|
|
var newRows = dt2.NewRow();
|
|
newRows["Num"] = (i + 1).ToString();
|
|
newRows["Part1"] = row["Part1"].ToString();
|
|
newRows["Part2"] = row["Part2"].ToString();
|
|
newRows["Part3"] = row["Part3"].ToString();
|
|
newRows["Part4"] = row["Part4"].ToString();
|
|
newRows["InnerDiameter"] = row["InnerDiameter"].ToString();
|
|
newRows["OuterDiameter"] = row["OuterDiameter"].ToString();
|
|
newRows["Lengths"] = row["Lengths"].ToString();
|
|
|
|
dt2.Rows.Add(newRows);
|
|
i++;
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportTable(dt2);
|
|
|
|
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))
|
|
{
|
|
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
|
|
{
|
|
{ "RecordItemId", Guid.NewGuid() },
|
|
{ "Name", "无缝钢管"},
|
|
{ "Material", "" },
|
|
{ "Specifications", "" },
|
|
{ "Quantity", "" },
|
|
{ "MaterialCertificateCode", "" },
|
|
{ "HeatCode", "" },
|
|
{ "MaterialCertificateSelfNumber", "" },
|
|
{
|
|
"Delete3",
|
|
String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>",
|
|
GetDeleteScriptGrid1(), IconHelper.GetResolvedIconUrl(Icon.Delete))
|
|
}
|
|
};
|
|
list.Add(defaultObj);
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
protected void Grid1_PreDataBound(object sender, EventArgs e)
|
|
{
|
|
// 设置LinkButtonField的点击客户端事件
|
|
LinkButtonField deleteField = Grid1.FindColumn("Delete3") as LinkButtonField;
|
|
deleteField.OnClientClick = GetDeleteScriptGrid1();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除提示
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetDeleteScriptGrid1()
|
|
{
|
|
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question,
|
|
Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
|
}
|
|
|
|
|
|
protected void btnAddItem2_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
JArray teamGroupData = Grid2.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
|
|
{
|
|
{ "RecordItemId", Guid.NewGuid() },
|
|
{ "Part1", ""},
|
|
{ "Part2", "" },
|
|
{ "Part3", "" },
|
|
{ "Part4", "" },
|
|
{ "InnerDiameter", "" },
|
|
{ "OuterDiameter", "" },
|
|
{ "Lengths", "" },
|
|
{
|
|
"Delete2",
|
|
String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>",
|
|
GetDeleteScriptGrid2(), IconHelper.GetResolvedIconUrl(Icon.Delete))
|
|
}
|
|
};
|
|
list.Add(defaultObj);
|
|
Grid2.DataSource = list;
|
|
Grid2.DataBind();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
protected void Grid2_PreDataBound(object sender, EventArgs e)
|
|
{
|
|
// 设置LinkButtonField的点击客户端事件
|
|
LinkButtonField deleteField = Grid2.FindColumn("Delete2") as LinkButtonField;
|
|
deleteField.OnClientClick = GetDeleteScriptGrid2();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除提示
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetDeleteScriptGrid2()
|
|
{
|
|
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question,
|
|
Grid2.GetDeleteSelectedRowsReference(), String.Empty);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 上传
|
|
/// <summary>
|
|
/// 上传
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
//protected void filePicture_FileSelected(object sender, EventArgs e)
|
|
//{
|
|
// if (filePicture.HasFile)
|
|
// {
|
|
// string fileName = filePicture.ShortFileName;
|
|
// if (!ValidateFileType(fileName))
|
|
// {
|
|
// ShowNotify("无效的文件类型!");
|
|
// return;
|
|
// }
|
|
// fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
|
|
// fileName = DateTime.Now.Ticks.ToString() + "_" + fileName;
|
|
// filePicture.SaveAs(Server.MapPath("~/upload/" + fileName));
|
|
// imgPicture.ImageUrl = "~/upload/" + fileName;
|
|
// // 清空文件上传组件
|
|
// filePicture.Reset();
|
|
// }
|
|
//}
|
|
#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_SteelPipeCheckRecordMenuId, Const.BtnSave))
|
|
{
|
|
Model.JGZL_SteelPipeCheckRecord newReport = new JGZL_SteelPipeCheckRecord();
|
|
newReport.ContractCode = this.txtContractCode.Text.Trim();
|
|
newReport.ArrivalDate = Funs.GetNewDateTime(this.txtArrivalDate.Text);
|
|
newReport.ExecutionStandard = this.txtExecutionStandard.Text;
|
|
newReport.Crack = this.drpCrack.SelectedValue;
|
|
newReport.SlagInclusion = this.drpSlagInclusion.SelectedValue;
|
|
newReport.ShrinkageHole= this.drpShrinkageHole.SelectedValue;
|
|
newReport.HeavyLeather = this.drpHeavyLeather.SelectedValue;
|
|
newReport.Other = this.drpOther.SelectedValue;
|
|
//newReport.Remark = imgPicture.ImageUrl;//图片
|
|
if (!string.IsNullOrEmpty(this.RecordId))
|
|
{
|
|
//var r = BLL.SteelPipeCheckRecordService.GetSteelPipeReportById(this.RecordId);
|
|
//if (r != null)
|
|
//{
|
|
// if (!string.IsNullOrEmpty(r.Remark))
|
|
// {
|
|
// string url = r.Remark.Substring(r.Remark.IndexOf('/'));
|
|
// if (File.Exists(Funs.RootPath + url))
|
|
// {
|
|
// //删除被覆盖的图片
|
|
// File.Delete(Funs.RootPath + url);
|
|
// }
|
|
// }
|
|
//}
|
|
newReport.RecordId = this.RecordId;
|
|
BLL.SteelPipeCheckRecordService.UpdateSteelPipeReport(newReport);
|
|
}
|
|
else
|
|
{
|
|
newReport.RecordId = SQLHelper.GetNewID(typeof(Model.JGZL_SteelPipeCheckRecord));
|
|
newReport.ProjectId = this.ProjectId;
|
|
newReport.CompileMan = this.CurrUser.UserId;
|
|
newReport.CompileDate = DateTime.Now;
|
|
this.RecordId = newReport.RecordId;
|
|
BLL.SteelPipeCheckRecordService.AddSteelPipeReport(newReport);
|
|
}
|
|
|
|
|
|
BLL.SteelPipeCheckRecordItem1Service.DeleteSteelPipeItem1ByRecordId(this.RecordId);
|
|
List<Model.JGZL_SteelPipeCheckRecordItem1> lists = new List<JGZL_SteelPipeCheckRecordItem1>();
|
|
JArray teamGroupData = Grid1.GetMergedData();
|
|
foreach (JObject teamGroupRow in teamGroupData)
|
|
{
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
int rowIndex = teamGroupRow.Value<int>("index");
|
|
Model.JGZL_SteelPipeCheckRecordItem1 newDetail = new Model.JGZL_SteelPipeCheckRecordItem1
|
|
{
|
|
RecordItemId = values.Value<string>("RecordItemId"),
|
|
RecordId = this.RecordId,
|
|
Name = values.Value<string>("Name"),
|
|
Material = values.Value<string>("Material"),
|
|
Specifications = HttpUtility.HtmlDecode(values.Value<string>("Specifications")),
|
|
Quantity = values.Value<string>("Quantity"),
|
|
MaterialCertificateCode = values.Value<string>("MaterialCertificateCode"),
|
|
HeatCode = values.Value<string>("HeatCode"),
|
|
MaterialCertificateSelfNumber = values.Value<string>("MaterialCertificateSelfNumber"),
|
|
};
|
|
lists.Add(newDetail);
|
|
}
|
|
try
|
|
{
|
|
if (lists.Count > 0)
|
|
{
|
|
Funs.DB.JGZL_SteelPipeCheckRecordItem1.InsertAllOnSubmit(lists);
|
|
//ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
}
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return;
|
|
}
|
|
|
|
BLL.SteelPipeCheckRecordItem2Service.DeleteSteelPipeItem2ByRecordId(this.RecordId);
|
|
List<Model.JGZL_SteelPipeCheckRecordItem2> lists2 = new List<JGZL_SteelPipeCheckRecordItem2>();
|
|
JArray teamGroupData2 = Grid2.GetMergedData();
|
|
foreach (JObject teamGroupRow in teamGroupData2)
|
|
{
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
int rowIndex = teamGroupRow.Value<int>("index");
|
|
Model.JGZL_SteelPipeCheckRecordItem2 newDetai2 = new Model.JGZL_SteelPipeCheckRecordItem2
|
|
{
|
|
RecordItemId = values.Value<string>("RecordItemId"),
|
|
RecordId = this.RecordId,
|
|
Part1 = values.Value<string>("Part1"),
|
|
Part2 = values.Value<string>("Part2"),
|
|
Part3 = values.Value<string>("Part3"),
|
|
Part4 = values.Value<string>("Part4"),
|
|
InnerDiameter = values.Value<string>("InnerDiameter"),
|
|
OuterDiameter = values.Value<string>("OuterDiameter"),
|
|
Lengths = values.Value<string>("Lengths"),
|
|
};
|
|
lists2.Add(newDetai2);
|
|
}
|
|
try
|
|
{
|
|
if (lists2.Count > 0)
|
|
{
|
|
Funs.DB.JGZL_SteelPipeCheckRecordItem2.InsertAllOnSubmit(lists2);
|
|
|
|
}
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return;
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |