622 lines
31 KiB
C#
622 lines
31 KiB
C#
using BLL;
|
||
using Model;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace FineUIPro.Web.YLRQ
|
||
{
|
||
public partial class HotProessTrustEdit : PageBase
|
||
{
|
||
/// <summary>
|
||
/// 热处理委托主键
|
||
/// </summary>
|
||
public string HotProessTrustId { get { return (string)ViewState["HotProessTrustId"]; } set { ViewState["HotProessTrustId"] = value; } }
|
||
|
||
/// <summary>
|
||
/// 项目主键
|
||
/// </summary>
|
||
public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } }
|
||
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.HotProessTrustId = Request.Params["HotProessTrustId"];
|
||
this.ProjectId = Request.Params["ProjectId"];
|
||
var trust = Funs.DB.PV_CH_HotProessTrust.FirstOrDefault(p => p.HotProessTrustId == this.HotProessTrustId);
|
||
if (trust != null) this.ProjectId = trust.ProjectId;
|
||
var pUnit = BLL.Base_UnitService.GetUnitsByProjectUnitType(this.ProjectId, BLL.Const.UnitType_4);
|
||
if (pUnit != null)
|
||
{
|
||
this.drpUnit.DataTextField = "UnitName";
|
||
this.drpUnit.DataValueField = "UnitId";
|
||
this.drpUnit.DataSource = pUnit;
|
||
this.drpUnit.DataBind();
|
||
}
|
||
///委托人
|
||
this.drpTrustMan.DataTextField = "UserName";
|
||
this.drpTrustMan.DataValueField = "UserId";
|
||
this.drpTrustMan.DataSource = Funs.DB.View_Common_Project_UserList.Where(p => p.ProjectId == this.ProjectId);
|
||
this.drpTrustMan.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpTrustMan);
|
||
this.drpTrustMan.SelectedValue = this.CurrUser.UserId;
|
||
this.PageInfoLoad(); ///加载页面
|
||
|
||
|
||
List<PV_View_CH_HotProessTrustItem> lists = Funs.DB.PV_View_CH_HotProessTrustItem.Where(x => x.ProjectId == this.ProjectId && x.HotProessTrustId == this.HotProessTrustId).ToList();
|
||
this.BindGrid(lists); //初始化页面
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载页面输入提交信息
|
||
/// <summary>
|
||
/// 加载页面输入提交信息
|
||
/// </summary>
|
||
private void PageInfoLoad()
|
||
{
|
||
var trust = Funs.DB.PV_CH_HotProessTrust.FirstOrDefault(e => e.HotProessTrustId == this.HotProessTrustId);
|
||
if (trust != null)
|
||
{
|
||
this.ProjectId = trust.ProjectId;
|
||
this.txtProjectName.Text = trust.ProjectName;
|
||
this.txtHotProessTrustCode.Text = trust.HotProessTrustCode;
|
||
if (!string.IsNullOrEmpty(trust.TrustUnitId))
|
||
{
|
||
this.drpUnit.SelectedValue = trust.TrustUnitId;
|
||
}
|
||
this.txtConstructionNo.Text = trust.ConstructionNo;
|
||
if (!string.IsNullOrEmpty(trust.TrstManId))
|
||
{
|
||
this.drpTrustMan.SelectedValue = trust.TrstManId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
this.SimpleForm1.Reset(); ///重置所有字段
|
||
//委托单号自动生成,规则:施工号-日期(1127)-两位流水
|
||
this.txtHotProessTrustCode.Text = SQLHelper.RunProcNewIdByProjectId("SpGetNewCode2ByProjectIdNoR", "dbo.PV_CH_HotProessTrust", "HotProessTrustCode", this.ProjectId, Base_ProjectService.GetProjectCode(this.ProjectId) + "-" + string.Format("{0:MMdd}", DateTime.Now) + "-");
|
||
Base_Project project = BLL.Base_ProjectService.GetProjectByProjectId(this.ProjectId);
|
||
if (project != null)
|
||
{
|
||
this.txtProjectName.Text = project.ProjectName;
|
||
this.txtConstructionNo.Text = project.ProjectCode;
|
||
}
|
||
if (this.CurrUser.UserId != Const.GlyId)
|
||
{
|
||
this.drpTrustMan.SelectedValue = this.CurrUser.UserId;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 数据绑定
|
||
/// <summary>
|
||
/// 数据绑定
|
||
/// </summary>
|
||
private void BindGrid(List<PV_View_CH_HotProessTrustItem> lists)
|
||
{
|
||
DataTable tb = this.LINQToDataTable(lists);
|
||
// 2.获取当前分页数据
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
var totalItems = Funs.DB.PV_CH_HotProessTrustItem.Where(p => p.ProjectId == this.ProjectId);
|
||
for (int i = 0; i < this.Grid1.Rows.Count; i++)
|
||
{
|
||
System.Web.UI.WebControls.CheckBoxList cblProessTypes = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblProessTypes"));
|
||
string hotId = this.Grid1.Rows[i].DataKeys[0].ToString();
|
||
string hotProessTrustItemId = this.Grid1.Rows[i].DataKeys[1].ToString();
|
||
List<PV_CH_HotProessTrustItem> items = (from x in totalItems where x.HotId == hotId && x.HotProessTrustId != this.HotProessTrustId select x).ToList();
|
||
//已处理的热处理类型集合
|
||
List<string> list = new List<string>();
|
||
foreach (var item in items)
|
||
{
|
||
//获取结果反馈信息
|
||
if (!string.IsNullOrEmpty(item.ProessTypes))
|
||
{
|
||
var hotProessResult = (from x in Funs.DB.PV_CH_HotProessResult where x.HotId == item.HotId && x.ProessTypes == item.ProessTypes && x.HotProessTrustId == item.HotProessTrustId select x).FirstOrDefault();
|
||
if (hotProessResult != null && (hotProessResult.IsOK == true || hotProessResult.IsOK == null)) //反馈记录合格或尚未进行反馈均视为已处理类型
|
||
{
|
||
string[] strs = item.ProessTypes.Split('|');
|
||
foreach (var str in strs)
|
||
{
|
||
if (!string.IsNullOrEmpty(str))
|
||
{
|
||
list.Add(str);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var joint = Funs.DB.PV_View_HotWeldInformation.FirstOrDefault(e => e.HotId == hotId);
|
||
cblProessTypes.DataSource = HJGL_CH_HotProessTrustService.GetWeldNeedProessTypes(joint.HeatTreatmentType, list, this.HotProessTrustId, hotId, hotProessTrustItemId);
|
||
cblProessTypes.DataBind();
|
||
for (int j = 0; j < cblProessTypes.Items.Count; j++)
|
||
{
|
||
if (string.IsNullOrEmpty(joint.DReportID)) //焊前只可选预热和加氢
|
||
{
|
||
if (cblProessTypes.Items[j].Text == "后热" || cblProessTypes.Items[j].Text == "消应力热处理" || cblProessTypes.Items[j].Text == "稳定化处理")
|
||
{
|
||
cblProessTypes.Items[j].Enabled = false;
|
||
}
|
||
}
|
||
else //焊后只可选后热、消应力处理和稳定化处理
|
||
{
|
||
if (cblProessTypes.Items[j].Text == "预热" || cblProessTypes.Items[j].Text == "消氢")
|
||
{
|
||
cblProessTypes.Items[j].Enabled = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
//修改记录
|
||
if (!string.IsNullOrEmpty(this.HotProessTrustId))
|
||
{
|
||
List<string> list2 = new List<string>();
|
||
var items2 = (from x in totalItems where x.HotId == hotId && x.HotProessTrustItemId == hotProessTrustItemId select x).FirstOrDefault();
|
||
if (items2 != null)
|
||
{
|
||
//获取已处理的热处理类型
|
||
if (!string.IsNullOrEmpty(items2.ProessTypes))
|
||
{
|
||
string[] strs = items2.ProessTypes.Split('|');
|
||
foreach (var str in strs)
|
||
{
|
||
if (!string.IsNullOrEmpty(str))
|
||
{
|
||
list2.Add(str);
|
||
}
|
||
}
|
||
}
|
||
for (int j = 0; j < cblProessTypes.Items.Count; j++)
|
||
{
|
||
foreach (var item in list2)
|
||
{
|
||
if (HJGL_CH_HotProessTrustService.GetProessTypesId(cblProessTypes.Items[j].Value) == item)
|
||
{
|
||
cblProessTypes.Items[j].Selected = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
string weldingId = Grid1.DataKeys[i][2].ToString();
|
||
int repairNum = int.Parse(Grid1.DataKeys[i][3].ToString());
|
||
var pageTrustItemIds = lists.ConvertAll(p => p.HotProessTrustItemId);
|
||
List<PV_View_CH_HotProessTrustItem> existTrustItems = Funs.DB.PV_View_CH_HotProessTrustItem.Where(p => pageTrustItemIds.Contains(p.HotProessTrustItemId) && p.WeldingId == weldingId && p.RepairNum == repairNum).ToList();
|
||
if (existTrustItems.Count > 0)
|
||
{
|
||
list = existTrustItems.ConvertAll(p => p.ProessTypes);
|
||
}
|
||
//var noExtrust = pageTrustItemIds.Except(existTrustItems.ConvertAll(p => p.HotProessTrustItemId)).ToList();
|
||
//if (noExtrust.Count > 0)
|
||
//{
|
||
//}
|
||
|
||
List<string> allProessTypelist = joint.HeatTreatmentType.Split('|').ToList();
|
||
allProessTypelist.RemoveAll(p => list.Contains(p));
|
||
|
||
System.Web.UI.WebControls.ListItem[] item = new System.Web.UI.WebControls.ListItem[allProessTypelist.Count()];
|
||
for (int k = 0; k < allProessTypelist.Count; k++)
|
||
{
|
||
item[k] = new System.Web.UI.WebControls.ListItem(HJGL_CH_HotProessTrustService.GetProessTypesName(allProessTypelist[k]), allProessTypelist[k].ToString());
|
||
}
|
||
cblProessTypes.DataSource = item;
|
||
cblProessTypes.DataBind();
|
||
for (int j = 0; j < cblProessTypes.Items.Count; j++)
|
||
{
|
||
if (string.IsNullOrEmpty(joint.DReportID)) //焊前只可选预热和加氢
|
||
{
|
||
if (cblProessTypes.Items[j].Text == "后热" || cblProessTypes.Items[j].Text == "消应力热处理" || cblProessTypes.Items[j].Text == "稳定化处理")
|
||
{
|
||
cblProessTypes.Items[j].Enabled = false;
|
||
}
|
||
}
|
||
else //焊后只可选后热、消应力处理和稳定化处理
|
||
{
|
||
if (cblProessTypes.Items[j].Text == "预热" || cblProessTypes.Items[j].Text == "消氢")
|
||
{
|
||
cblProessTypes.Items[j].Enabled = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 热处理委托 提交事件
|
||
/// <summary>
|
||
/// 编辑热处理委托
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (Funs.DB.PV_CH_HotProessTrust.Count(x => x.HotProessTrustCode == this.txtHotProessTrustCode.Text && x.ProjectId == this.ProjectId && x.HotProessTrustId != this.HotProessTrustId) > 0)
|
||
{
|
||
ShowNotify("委托单号已存在,请重新录入!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
int count = 0;
|
||
for (int i = 0; i < this.Grid1.Rows.Count; i++)
|
||
{
|
||
System.Web.UI.WebControls.CheckBoxList cblProessTypes = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblProessTypes"));
|
||
for (int j = 0; j < cblProessTypes.Items.Count; j++)
|
||
{
|
||
if (cblProessTypes.Items[j].Selected)
|
||
{
|
||
count += 1;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if (count < this.Grid1.Rows.Count)
|
||
{
|
||
ShowNotify("请选择热处理类型!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
PV_CH_HotProessTrust newHotProessTrust = new PV_CH_HotProessTrust();
|
||
if (!string.IsNullOrEmpty(this.HotProessTrustId))
|
||
{
|
||
newHotProessTrust = Funs.DB.PV_CH_HotProessTrust.FirstOrDefault(p => p.HotProessTrustId == this.HotProessTrustId);
|
||
if (newHotProessTrust == null)
|
||
{
|
||
ShowNotify("修改传递数据存在错误!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
newHotProessTrust.ProjectId = this.ProjectId;
|
||
newHotProessTrust.HotProessTrustCode = this.txtHotProessTrustCode.Text.Trim();
|
||
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
||
{
|
||
newHotProessTrust.TrustUnitId = this.drpUnit.SelectedValue;
|
||
}
|
||
newHotProessTrust.ProjectName = this.txtProjectName.Text.Trim();
|
||
newHotProessTrust.ConstructionNo = this.txtConstructionNo.Text.Trim();
|
||
if (this.drpTrustMan.SelectedValue != BLL.Const._Null)
|
||
{
|
||
newHotProessTrust.TrstManId = this.drpTrustMan.SelectedValue;
|
||
}
|
||
if (!string.IsNullOrEmpty(this.HotProessTrustId))
|
||
{
|
||
newHotProessTrust.HotProessTrustId = this.HotProessTrustId;
|
||
Funs.DB.SubmitChanges();
|
||
Sys_LogService.AddLog(BLL.Const.System_4, this.ProjectId, this.CurrUser.UserId, "修改热处理委托信息");
|
||
}
|
||
else
|
||
{
|
||
this.HotProessTrustId = SQLHelper.GetNewID(typeof(PV_CH_HotProessTrust));
|
||
newHotProessTrust.HotProessTrustId = this.HotProessTrustId;
|
||
Funs.DB.PV_CH_HotProessTrust.InsertOnSubmit(newHotProessTrust);
|
||
Funs.DB.SubmitChanges();
|
||
Sys_LogService.AddLog(Const.System_4, this.ProjectId, this.CurrUser.UserId, "添加热处理委托信息");
|
||
}
|
||
//删除委托明细
|
||
var cH_Trust = Funs.DB.PV_CH_HotProessTrustItem.Where(x => x.HotProessTrustId == this.HotProessTrustId);
|
||
if (cH_Trust != null)
|
||
{
|
||
Funs.DB.PV_CH_HotProessTrustItem.DeleteAllOnSubmit(cH_Trust);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
var cH_Result = Funs.DB.PV_CH_HotProessResult.Where(x => x.HotProessTrustId == this.HotProessTrustId);
|
||
if (cH_Trust != null)
|
||
{
|
||
Funs.DB.PV_CH_HotProessResult.DeleteAllOnSubmit(cH_Result);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
this.CollectGridJointInfo();
|
||
ShowNotify("提交成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(newHotProessTrust.HotProessTrustId)
|
||
+ ActiveWindow.GetHidePostBackReference());
|
||
}
|
||
#endregion
|
||
|
||
#region 收集Grid页面信息,提交明细
|
||
/// <summary>
|
||
/// 收集Grid页面信息,提交明细
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private void CollectGridJointInfo()
|
||
{
|
||
JArray mergedData = Grid1.GetMergedData();
|
||
foreach (JObject mergedRow in mergedData)
|
||
{
|
||
string status = mergedRow.Value<string>("status");
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
int rowIndex = mergedRow.Value<int>("index");
|
||
|
||
System.Web.UI.WebControls.CheckBoxList cblProessTypes = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[rowIndex].FindControl("cblProessTypes"));
|
||
string str = string.Empty;
|
||
for (int i = 0; i < cblProessTypes.Items.Count; i++)
|
||
{
|
||
if (cblProessTypes.Items[i].Selected)
|
||
{
|
||
PV_CH_HotProessTrustItem item = new PV_CH_HotProessTrustItem();
|
||
item.HotProessTrustId = this.HotProessTrustId;
|
||
item.ProjectId = this.ProjectId;
|
||
item.HotId = values.Value<string>("HotId").ToString();
|
||
item.ProessTypes = BLL.HJGL_CH_HotProessTrustService.GetProessTypesId(cblProessTypes.Items[i].Value);
|
||
item.TrustDate = Funs.GetNewDateTime(values.Value<string>("TrustDate").ToString());
|
||
item.Remark = values.Value<string>("Remark").ToString();
|
||
if (!string.IsNullOrEmpty(values.Value<string>("TrustType").ToString()))
|
||
{
|
||
item.TrustType = values.Value<int>("TrustType");
|
||
}
|
||
if (!string.IsNullOrEmpty(values.Value<string>("HardTestResultId").ToString()))
|
||
{
|
||
item.HardTestResultId = values.Value<string>("HardTestResultId").ToString();
|
||
}
|
||
if (!string.IsNullOrEmpty(values.Value<string>("HardRepairMark").ToString()))
|
||
{
|
||
item.HardRepairMark = values.Value<string>("HardRepairMark").ToString();
|
||
}
|
||
string trustItemID = values.Value<string>("TrustItemID").ToString();
|
||
if (!string.IsNullOrEmpty(trustItemID))
|
||
{
|
||
item.TrustItemID = trustItemID;
|
||
}
|
||
item.HotProessTrustItemId = SQLHelper.GetNewID(typeof(PV_CH_HotProessTrustItem));
|
||
if (Funs.DB.PV_CH_HotProessTrustItem.Count(x => x.HotId == item.HotId && x.ProessTypes == item.ProessTypes && x.HotProessTrustId == item.HotProessTrustId) == 0)
|
||
{
|
||
Funs.DB.PV_CH_HotProessTrustItem.InsertOnSubmit(item);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
if (item.ProessTypes.Contains("4") || item.ProessTypes.Contains("5")) //需要进入热处理报告的记录
|
||
{
|
||
//回写焊口热处理委托时间
|
||
var hot = Funs.DB.PV_View_HotWeldInformation.FirstOrDefault(p => p.HotId == item.HotId);
|
||
if (hot != null)
|
||
{
|
||
PV_WeldInformation newJointInfo = Funs.DB.PV_WeldInformation.FirstOrDefault(e => e.WeldingId == hot.WeldingId);
|
||
if (newJointInfo != null)
|
||
{
|
||
newJointInfo.IsProess = true;
|
||
newJointInfo.HotReportId = this.HotProessTrustId;
|
||
newJointInfo.HotProessTrustDate = item.TrustDate;
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
//进入热处理结果反馈
|
||
if (Funs.DB.PV_CH_HotProessResult.Count(x => x.HotId == item.HotId && x.ProessTypes == item.ProessTypes && x.HotProessTrustId == this.HotProessTrustId) == 0)
|
||
{
|
||
PV_CH_HotProessResult hotProessResult = new PV_CH_HotProessResult();
|
||
hotProessResult.HotProessResultId = Guid.NewGuid().ToString();
|
||
hotProessResult.ProjectId = this.ProjectId;
|
||
hotProessResult.HotId = item.HotId;
|
||
hotProessResult.HotProessTrustId = this.HotProessTrustId;
|
||
hotProessResult.HotProessTrustItemId = item.HotProessTrustItemId;
|
||
hotProessResult.ProessTypes = item.ProessTypes;
|
||
Funs.DB.PV_CH_HotProessResult.InsertOnSubmit(hotProessResult);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region Grid 关闭弹出窗口事件
|
||
/// <summary>
|
||
/// 关闭弹出窗口
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
List<string> list = Funs.GetStrListByStr(hdItemsString.Text, '|');
|
||
List<PV_View_CH_HotProessTrustItem> lists = GetHotProessTrustAddItem(this.hdItemsString.Text);
|
||
this.BindGrid(lists);
|
||
}
|
||
#endregion
|
||
|
||
#region 右键删除事件
|
||
/// <summary>
|
||
/// 右键删除事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
||
{
|
||
var trust = Funs.DB.PV_CH_HotProessTrust.FirstOrDefault(p => p.HotProessTrustId == this.HotProessTrustId);
|
||
if (trust != null && trust.IsPrint == true)
|
||
{
|
||
ShowNotify("热处理委托已打印,无法删除!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||
{
|
||
List<PV_View_CH_HotProessTrustItem> GetHotProessTrustItem = new List<PV_View_CH_HotProessTrustItem>();
|
||
if (!string.IsNullOrEmpty(this.hdItemsString.Text))
|
||
{
|
||
GetHotProessTrustItem = GetHotProessTrustAddItem(this.hdItemsString.Text);
|
||
}
|
||
else if (string.IsNullOrEmpty(this.hdItemsString.Text) && this.HotProessTrustId != null)
|
||
{
|
||
GetHotProessTrustItem = Funs.DB.PV_View_CH_HotProessTrustItem.Where(p => p.ProjectId == this.ProjectId && p.HotProessTrustId == this.HotProessTrustId).ToList();
|
||
}
|
||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||
{
|
||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||
var item = GetHotProessTrustItem.FirstOrDefault(x => x.HotId == rowID);
|
||
if (item != null)
|
||
{
|
||
//新增记录可直接删除
|
||
if (string.IsNullOrEmpty(this.HotProessTrustId))
|
||
{
|
||
GetHotProessTrustItem.Remove(item);
|
||
this.hdItemsString.Text = this.hdItemsString.Text.Replace(rowID, "");
|
||
}
|
||
else//修改记录时只能删除未处理的热处理记录
|
||
{
|
||
var result = Funs.DB.PV_CH_HotProessResult.FirstOrDefault(x => x.HotProessTrustId == item.HotProessTrustId && x.HotId == item.HotId && item.ProessTypes == x.ProessTypes);
|
||
if (result != null)
|
||
{
|
||
if (result.IsOK == null)
|
||
{
|
||
GetHotProessTrustItem.Remove(item);
|
||
this.hdItemsString.Text = this.hdItemsString.Text.Replace(rowID, "");
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("热处理结果已反馈,无法删除!", MessageBoxIcon.Warning);
|
||
}
|
||
//删除热处理反馈明细
|
||
Funs.DB.PV_CH_HotProessResult.DeleteOnSubmit(result);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
BindGrid(GetHotProessTrustItem);
|
||
ShowNotify("操作完成!", MessageBoxIcon.Success);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 查找未焊接焊口
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void ckSelect_Click(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != BLL.Const._Null)
|
||
{
|
||
string hotids = string.Empty;
|
||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||
{
|
||
string jointNo = Grid1.DataKeys[i][0].ToString();
|
||
string hotProessTrustItemId = Grid1.DataKeys[i][1].ToString();
|
||
string weldingId = Grid1.DataKeys[i][2].ToString();
|
||
string repairNum = Grid1.DataKeys[i][3].ToString();
|
||
|
||
if (!string.IsNullOrEmpty(hotProessTrustItemId))
|
||
{
|
||
jointNo += "," + hotProessTrustItemId;
|
||
hotids += jointNo + "|";
|
||
}
|
||
//if (!string.IsNullOrEmpty(hotProessTrustItemId) && Funs.DB.PV_CH_HotProessTrustItem.Count(p => p.HotProessTrustItemId == hotProessTrustItemId) > 0)
|
||
//{
|
||
// jointNo += "," + hotProessTrustItemId;
|
||
|
||
// //if (!string.IsNullOrEmpty(weldingId))
|
||
// //{
|
||
// // jointNo += "," + weldingId;
|
||
// //}
|
||
// //if (!string.IsNullOrEmpty(repairNum))
|
||
// //{
|
||
// // jointNo += "," + repairNum;
|
||
// //}
|
||
|
||
// hotids += jointNo + "|";
|
||
//}
|
||
}
|
||
|
||
if (hotids != string.Empty)
|
||
{
|
||
hotids = hotids.Substring(0, hotids.Length - 1);
|
||
}
|
||
string strList = this.drpUnit.SelectedValue + "|" + this.HotProessTrustId + "|" + this.ProjectId;
|
||
string window = String.Format("HotProessTrustItemEdit.aspx?strList={0}&hotids={1}", strList, hotids, "编辑 - ");
|
||
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdItemsString.ClientID) + Window1.GetShowReference(window));
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查找后返回集合增加到列表集团中
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<PV_View_CH_HotProessTrustItem> GetHotProessTrustAddItem(string hdItemsString)
|
||
{
|
||
var jointInfos = Funs.DB.PV_View_HotWeldInformation.Where(p => p.ProjectId == this.ProjectId);
|
||
List<PV_View_CH_HotProessTrustItem> returnViewMatch = new List<PV_View_CH_HotProessTrustItem>();
|
||
if (!string.IsNullOrEmpty(hdItemsString))
|
||
{
|
||
List<string> jotIds = Funs.GetStrListByStr(hdItemsString, '|');
|
||
List<string> jotStr = new List<string>();
|
||
foreach (var jotItem in jotIds)
|
||
{
|
||
string[] strs = jotItem.Split(',');
|
||
var jotInfo = jointInfos.FirstOrDefault(x => x.HotId == strs[0]);
|
||
if (jotInfo != null)
|
||
{
|
||
var itemId = SQLHelper.GetNewID(typeof(PV_View_CH_HotProessTrustItem));
|
||
if (strs.Length > 1 && !string.IsNullOrEmpty(strs[1]))
|
||
{
|
||
itemId = strs[1];
|
||
if (Funs.DB.PV_View_CH_HotProessTrustItem.Count(p => p.HotProessTrustItemId == strs[1]) == 0)
|
||
{
|
||
jotStr.Add($"{strs[0]},");
|
||
}
|
||
else
|
||
{
|
||
jotStr.Add($"{strs[0]},{strs[1]}");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (jotStr.Count(p => p == $"{strs[0]},") == 0)
|
||
{
|
||
jotStr.Add($"{strs[0]},");
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
PV_View_CH_HotProessTrustItem newItem = new PV_View_CH_HotProessTrustItem();
|
||
newItem.HotProessTrustItemId = itemId;//SQLHelper.GetNewID(typeof(PV_View_CH_HotProessTrustItem));
|
||
newItem.HotId = jotInfo.HotId;
|
||
newItem.WeldingId = jotInfo.WeldingId;
|
||
newItem.WeldingCode = jotInfo.WeldingCode;
|
||
newItem.JOT_JointNo = jotInfo.JOT_JointNo;
|
||
newItem.JointDesc = jotInfo.JointDesc;
|
||
newItem.STE_Code = jotInfo.STE_Code;
|
||
newItem.RepairFalg = jotInfo.RepairFalg;
|
||
newItem.TrustDate = DateTime.Now;
|
||
newItem.TrustType = jotInfo.TrustType;
|
||
newItem.RepairNum = jotInfo.RepairNum;
|
||
if (strs.Length > 0)
|
||
{
|
||
newItem.HardTestResultId = strs[0];
|
||
}
|
||
if (!string.IsNullOrEmpty(newItem.HardRepairMark))
|
||
{
|
||
newItem.JOT_JointNo = jotInfo.WeldingCode + newItem.HardRepairMark;
|
||
}
|
||
returnViewMatch.Add(newItem);
|
||
}
|
||
}
|
||
}
|
||
|
||
return returnViewMatch;
|
||
}
|
||
|
||
}
|
||
} |