SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReportEdit.aspx.cs

1234 lines
56 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
2023-02-20 21:59:35 +08:00
using FineUIPro.Web.HJGL.WeldingManage;
2023-10-27 14:02:52 +08:00
using Microsoft.Office.Interop.Word;
2022-09-05 16:36:31 +08:00
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
2023-02-20 11:12:44 +08:00
using System.Web.UI.DataVisualization.Charting;
2023-11-13 17:46:33 +08:00
using System.Threading.Tasks;
2022-09-05 16:36:31 +08:00
namespace FineUIPro.Web.WeldingProcess.WeldingManage
{
public partial class WeldReportEdit : PageBase
{
#region
/// <summary>
/// 焊接日报主键
/// </summary>
public string WeldingDailyId
{
get
{
return (string)ViewState["WeldingDailyId"];
}
set
{
ViewState["WeldingDailyId"] = value;
}
}
/// <summary>
/// 单位工程
/// </summary>
public string UnitWorkId
{
get
{
return (string)ViewState["UnitWorkId"];
}
set
{
ViewState["UnitWorkId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.WeldingDailyId = Request.Params["WeldingDailyId"];
// 焊口属性
this.drpJointAttribute.DataTextField = "Text";
this.drpJointAttribute.DataValueField = "Value";
this.drpJointAttribute.DataSource = BLL.DropListService.HJGL_JointAttribute();
this.drpJointAttribute.DataBind();
Funs.FineUIPleaseSelect(drpJointAttribute);
this.PageInfoLoad(); // 加载页面
if (!string.IsNullOrEmpty(this.WeldingDailyId))
{
List<Model.SpWeldingDailyItem> GetWeldingDailyItem = BLL.WeldingDailyService.GetWeldingDailyItem(this.WeldingDailyId);
this.BindGrid(GetWeldingDailyItem); // 初始化页面
2023-09-12 16:54:08 +08:00
}
2022-09-05 16:36:31 +08:00
else
{
this.BindGrid(null);
}
this.CalculationAmount();
}
}
#endregion
#region
/// <summary>
/// 超量焊工提示
/// </summary>
private void CalculationAmount()
{
this.lbAmount.Hidden = true;
this.lbAmount.Text = string.Empty;
DateTime? date = Funs.GetNewDateTime(this.txtWeldingDate.Text);
string txtValue = string.Empty;
if (date.HasValue)
{
//var weldJoints = BLL.WeldJointService.GetWeldlinesByWeldingDailyId(this.WeldingDailyId);
//foreach (var item in weldJoints)
//{
// bool cWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.CoverWelderId, date.Value);
// bool bWelder = cWelder;
// if (item.BackingWelderId != item.CoverWelderId)
// {
// bWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.BackingWelderId, date.Value);
// }
// if (cWelder || bWelder)
// {
// if (cWelder)
// {
// var coverWelder = BLL.SitePerson_PersonService.GetSitePersonById(item.CoverWelderId);
// if (coverWelder != null)
// {
// string txt = coverWelder.WelderCode + "";
// if (!txtValue.Contains(txt))
// {
// txtValue += txt;
// }
// }
// }
// if (bWelder)
// {
// var floorWelder = BLL.SitePerson_PersonService.GetSitePersonById(item.BackingWelderId);
// if (floorWelder != null)
// {
// string txt = floorWelder.WelderCode + "";
// if (!txtValue.Contains(txt))
// {
// txtValue += txt;
// }
// }
// }
// }
//}
}
if (!string.IsNullOrEmpty(txtValue))
{
this.lbAmount.Text = txtValue;
this.lbAmount.Hidden = false;
}
}
#endregion
#region
/// <summary>
/// 加载页面输入提交信息
/// </summary>
private void PageInfoLoad()
{
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWork, this.CurrUser.LoginProjectId, true);
var report = BLL.WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(this.WeldingDailyId);
if (report != null)
{
this.txtWeldingDailyCode.Text = report.WeldingDailyCode;
if (!string.IsNullOrEmpty(report.UnitId))
{
this.drpUnit.SelectedValue = report.UnitId;
}
if (!string.IsNullOrEmpty(report.UnitWorkId))
{
this.drpUnitWork.SelectedValue = report.UnitWorkId;
}
this.UnitWorkId = report.UnitWorkId;
this.txtWeldingDate.Text = string.Format("{0:yyyy-MM-dd}", report.WeldingDate);
this.hdTablerId.Text = report.Tabler;
this.txtTabler.Text = Person_PersonsService.GetPersonsNameById(report.Tabler);
this.txtTableDate.Text = string.Format("{0:yyyy-MM-dd}", report.TableDate);
this.txtRemark.Text = report.Remark;
}
else
{
this.UnitWorkId = Request.Params["unitWorkId"];
if (!string.IsNullOrEmpty(UnitWorkId))
{
var w = BLL.UnitWorkService.getUnitWorkByUnitWorkId(UnitWorkId);
drpUnit.SelectedValue = w.UnitId;
this.drpUnitWork.SelectedValue = w.UnitWorkId;
}
this.SimpleForm1.Reset(); ///重置所有字段
this.txtTabler.Text = this.CurrUser.PersonName;
this.hdTablerId.Text = this.CurrUser.PersonId;
//txtWeldingDate.MaxDate = DateTime.Now;
this.txtWeldingDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
this.txtTableDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
2023-11-24 12:20:07 +08:00
string perfix = string.Format("{0:yyyyMMdd}", System.DateTime.Now) + "-" + this.CurrUser.PersonName + "-";
2022-09-05 16:36:31 +08:00
this.txtWeldingDailyCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "dbo.HJGL_WeldingDaily", "WeldingDailyCode", this.CurrUser.LoginProjectId, perfix);
}
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid(List<Model.SpWeldingDailyItem> weldingDailyItem)
{
2023-02-20 11:12:44 +08:00
var task = new List<Model.View_HJGL_WeldingTask>();
2023-02-20 10:49:51 +08:00
var list = from x in Funs.DB.View_HJGL_WeldingTask where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == this.UnitWorkId select x;
2022-09-05 16:36:31 +08:00
if (weldingDailyItem != null)
{
var weldJointIds = (from x in list
2023-03-24 15:57:37 +08:00
where (x.TaskDate.Value.Date <= Convert.ToDateTime(txtWeldingDate.Text)
2023-10-27 14:02:52 +08:00
&& x.WeldingDailyId == null/*|| x.WeldingDailyId == this.WeldingDailyId*/)
2023-03-24 15:57:37 +08:00
select x).ToList();
2023-11-21 20:26:41 +08:00
weldJointIds = weldJointIds.GroupBy(x => x.WeldJointId, (key, group) => group.OrderByDescending(x => x.TaskDate).First()).ToList();
2023-02-20 10:49:51 +08:00
task = weldJointIds;
//foreach (var weldJointId in weldJointIds)
//{
// task.Add(list.FirstOrDefault(x => x.WeldJointId == weldJointId));
//}
2022-09-05 16:36:31 +08:00
if (drpJointAttribute.SelectedValue != Const._Null)
{
2023-11-21 20:26:41 +08:00
task = task.Where(x => x.JointAttribute == drpJointAttribute.SelectedValue).ToList();
2022-09-05 16:36:31 +08:00
}
2023-10-25 23:30:52 +08:00
if (drpUnit.SelectedValue != Const._Null)
{
task = task.Where(x => x.UnitId == drpUnit.SelectedValue).ToList();
}
2022-12-25 15:59:59 +08:00
if (!string.IsNullOrEmpty(this.txtPipelineCode.Text.Trim()))
{
task = task.Where(x => x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim())).ToList();
}
2023-09-12 16:54:08 +08:00
// dt = this.LINQToDataTable(task);
2022-09-05 16:36:31 +08:00
}
else
{
2023-03-24 15:57:37 +08:00
var weldJointIds = (from x in list
2022-09-05 16:36:31 +08:00
where x.UnitWorkId == this.UnitWorkId && x.TaskDate.Value.Date <= Convert.ToDateTime(txtWeldingDate.Text)
2023-11-29 18:02:03 +08:00
&& x.WeldingDailyId == null
2023-03-24 15:57:37 +08:00
select x).ToList();
2023-10-19 10:12:45 +08:00
weldJointIds = weldJointIds.GroupBy(x => x.WeldJointId, (key, group) => group.OrderByDescending(x => x.TaskDate).First()).ToList();
2023-02-20 10:49:51 +08:00
task = weldJointIds;
//foreach (var weldJointId in weldJointIds)
//{
// task.Add(list.FirstOrDefault(x => x.WeldJointId == weldJointId /*&& x.CoverWelderId != null*/));
//}
2022-09-05 16:36:31 +08:00
if (drpJointAttribute.SelectedValue != Const._Null)
{
task = task.Where(x => x.JointAttribute == drpJointAttribute.SelectedValue).ToList();
}
2023-10-25 23:30:52 +08:00
if (drpUnit.SelectedValue != Const._Null)
{
task = task.Where(x => x.UnitId == drpUnit.SelectedValue).ToList();
}
2022-12-25 15:59:59 +08:00
if (!string.IsNullOrEmpty(this.txtPipelineCode.Text.Trim()))
{
task = task.Where(x => x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim())).ToList();
}
2023-02-20 11:12:44 +08:00
//dt = this.LINQToDataTable(task);
2022-09-05 16:36:31 +08:00
}
2023-11-13 17:46:33 +08:00
task = task.OrderBy(x => x.PipelineCode).ThenBy(x => x.WeldJointNum).ToList();
2023-11-21 20:26:41 +08:00
Grid1.RecordCount = task.Count;
2023-02-20 11:12:44 +08:00
Grid1.DataSource = task;
2022-09-05 16:36:31 +08:00
Grid1.DataBind();
2023-01-02 12:21:10 +08:00
//for (int i = 0; i < this.Grid1.Rows.Count; i++)
//{
// var hotProesssItem = Funs.DB.HJGL_HotProess_TrustItem.FirstOrDefault(x => x.WeldJointId == this.Grid1.Rows[i].DataKeys[1].ToString());
// if (hotProesssItem != null) //已生成热处理委托,不能编辑或删除
// {
// // Grid1.Rows[i].RowSelectable = false;
// }
// var pointBatchItem = Funs.DB.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.WeldJointId == this.Grid1.Rows[i].DataKeys[1].ToString() && x.PointState != null);
// if (pointBatchItem != null) //已生成委托,不能编辑或删除
// {
// // Grid1.Rows[i].RowSelectable = false;
// }
//}
2023-10-27 14:02:52 +08:00
//if (weldingDailyItem != null)
//{
// var Dailytask = (from x in Funs.DB.View_HJGL_WeldingTask
// where x.WeldingDailyId == this.WeldingDailyId
// select new
// {
// x.PipelineCode,
// x.WeldTaskId
// }).Distinct().ToList();
// if (!string.IsNullOrEmpty(this.txtPipelineCode.Text.Trim()))
// {
// Dailytask = Dailytask.Where(x => x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim())).ToList();
// }
// var weldTaskIds = Dailytask.Select(x => x.WeldTaskId).ToArray();
// this.Grid1.SelectedRowIDArray = weldTaskIds;
// var a = this.Grid1.SelectedRowIDArray;
//}
2022-09-05 16:36:31 +08:00
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
//List<Model.SpWeldingDailyItem> GetWeldingDailyItem = this.CollectGridJointInfo();
this.BindGrid(null);
}
#endregion
//private static bool canSave; //是否可以保存
public string ConvertPipeArea(object PipeArea)
{
2024-02-26 11:46:22 +08:00
string stateName = string.Empty;
if (PipeArea != null && !string.IsNullOrEmpty(PipeArea.ToString()))
2022-09-05 16:36:31 +08:00
{
2024-02-26 11:46:22 +08:00
string txt = PipelineService.GetPipeArea().FirstOrDefault(x => x.Value == PipeArea.ToString())?.Text;
2022-09-05 16:36:31 +08:00
return txt;
2024-02-26 11:46:22 +08:00
2022-09-05 16:36:31 +08:00
}
2024-02-26 11:46:22 +08:00
return stateName;
2022-09-05 16:36:31 +08:00
}
#region
2023-11-13 17:46:33 +08:00
// 检查用户权限
private bool HasPermission()
{
return CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.HJGL_WeldTaskMenuId, Const.BtnSave);
}
// 获取焊接信息
private List<Model.View_HJGL_WeldJoint> GetWeldJointView()
{
return Funs.DB.View_HJGL_WeldJoint
.Where(x => x.WeldingDailyId == WeldingDailyId)
.OrderBy(x => x.PipelineCode)
.ThenBy(x => x.WeldJointCode)
.ToList();
}
// 创建新的焊接日报
private Model.HJGL_WeldingDaily CreateNewWeldingDaily()
2022-09-05 16:36:31 +08:00
{
2023-10-27 14:02:52 +08:00
Model.HJGL_WeldingDaily newWeldingDaily = new Model.HJGL_WeldingDaily
{
WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim(),
ProjectId = CurrUser.LoginProjectId,
UnitWorkId = this.UnitWorkId,
WeldingDate = Funs.GetNewDateTime(this.txtWeldingDate.Text) ?? DateTime.Now,
Tabler = this.hdTablerId.Text,
TableDate = Funs.GetNewDateTime(this.txtTableDate.Text),
Remark = this.txtRemark.Text.Trim(),
UnitId = this.drpUnit.SelectedValue
};
if (this.drpUnitWork.SelectedValue != BLL.Const._Null)
{
newWeldingDaily.UnitWorkId = this.drpUnitWork.SelectedValue;
}
2023-11-13 17:46:33 +08:00
return newWeldingDaily;
}
//焊工资质判断
private void CheckWelderQualification()
{
2023-10-27 14:02:52 +08:00
#region
2022-09-05 16:36:31 +08:00
2023-10-27 14:02:52 +08:00
//foreach (var item in GetWeldingDailyItem)
//{
// bool canSave = false;
// var jot = BLL.WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
// var joty = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(jot.WeldTypeId);
// string weldType = string.Empty;
// if (joty != null && joty.WeldTypeCode.Contains("B"))
// {
// weldType = "对接焊缝";
// }
// else
// {
// weldType = "角焊缝";
// }
// string floorWelder = item.BackingWelderId;
// string cellWelder = item.CoverWelderId;
// decimal? dia = item.Dia;
// decimal? sch = Funs.GetNewDecimal(item.Thickness.HasValue ? item.Thickness.Value.ToString() : "");
// string wmeCode = string.Empty;
// var wm = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(jot.WeldingMethodId);
// if (wm != null)
// {
// wmeCode = wm.WeldingMethodCode;
// }
// string[] wmeCodes = wmeCode.Split('+');
// //string location = item.JOT_Location;
// string ste = jot.Material1Id;
// string jointAttribute = jot.JointAttribute;
// List<Model.Welder_WelderQualify> floorWelderQualifys = (from x in Funs.DB.Welder_WelderQualify
// where x.WelderId == floorWelder && x.WeldingMethod != null
// && x.MaterialType != null && x.WeldType != null
// && x.ThicknessMax != null && x.SizesMin != null
// select x).ToList();
// List<Model.Welder_WelderQualify> cellWelderQualifys = (from x in Funs.DB.Welder_WelderQualify
// where x.WelderId == cellWelder && x.WeldingMethod != null
// && x.MaterialType != null && x.WeldType != null
// && x.ThicknessMax != null && x.SizesMin != null
// select x).ToList();
// // 打底和盖面同一焊工
// if (floorWelder == cellWelder)
// {
// if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
// {
// if (wmeCodes.Count() <= 1) // 一种焊接方法
// {
// canSave = OneWmeIsOK(floorWelderQualifys, wmeCode, jointAttribute, weldType, ste, dia, sch);
// }
// else // 大于一种焊接方法,如氩电联焊
// {
// canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], jointAttribute, weldType, ste, dia, sch);
// }
// }
// }
// // 打底和盖面焊工不同
// else
// {
// bool isok1 = false;
// bool isok2 = false;
// if (wmeCodes.Count() <= 1) // 一种焊接方法
// {
// if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
// {
// isok1 = OneWmeIsOK(floorWelderQualifys, wmeCode, jointAttribute, weldType, ste, dia, sch);
// }
// if (cellWelderQualifys != null && cellWelderQualifys.Count() > 0)
// {
// isok2 = OneWmeIsOK(cellWelderQualifys, wmeCode, jointAttribute, weldType, ste, dia, sch);
// }
// if (isok1 && isok2)
// {
// canSave = true;
// }
// }
// else
// {
// canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], jointAttribute, weldType, ste, dia, sch);
// }
// }
2022-09-05 16:36:31 +08:00
2023-10-27 14:02:52 +08:00
// if (canSave == false)
// {
// eventArg = eventArg + jot.WeldJointCode + ",";
// }
//}
2022-09-05 16:36:31 +08:00
2023-10-27 14:02:52 +08:00
#endregion
2023-11-13 17:46:33 +08:00
}
2023-10-27 14:02:52 +08:00
2023-11-13 17:46:33 +08:00
/// <summary>
/// 编辑焊接日报
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (!HasPermission())
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
2023-12-01 12:11:50 +08:00
if (this.drpUnit.SelectedValue==BLL.Const._Null)
{
ShowNotify("请选择单位名称!", MessageBoxIcon.Warning);
return;
}
2023-11-13 17:46:33 +08:00
if (BLL.WeldingDailyService.IsExistWeldingDailyCode(this.txtWeldingDailyCode.Text,
!string.IsNullOrEmpty(this.WeldingDailyId) ? this.WeldingDailyId : "", CurrUser.LoginProjectId))
{
ShowNotify("日报编号已存在,请重新录入", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(this.txtWeldingDate.Text) ||
string.IsNullOrEmpty(this.txtWeldingDailyCode.Text.Trim()))
{
ShowNotify("日报告号、焊接日期不能为空", MessageBoxIcon.Warning);
return;
}
// 创建新的焊接日报
var newWeldingDaily = CreateNewWeldingDaily();
// 获取焊接信息
var weldJointView = GetWeldJointView();
string errlog = string.Empty;
string eventArg = string.Empty;
// 焊工资质判断
// CheckWelderQualification(weldJointView);
2023-11-21 20:26:41 +08:00
2023-10-27 14:02:52 +08:00
if (eventArg == string.Empty) //焊工焊接的所有焊口资质都符合要求)
{
if (!string.IsNullOrEmpty(this.WeldingDailyId))
2022-09-05 16:36:31 +08:00
{
2023-10-27 14:02:52 +08:00
newWeldingDaily.WeldingDailyId = this.WeldingDailyId;
BLL.WeldingDailyService.UpdateWeldingDaily(newWeldingDaily);
//BLL.Sys_LogService.AddLog(BLL.Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_WeldReportMenuId, Const.BtnModify, this.WeldingDailyId);
}
else
{
this.WeldingDailyId = SQLHelper.GetNewID(typeof(Model.HJGL_WeldingDaily));
newWeldingDaily.WeldingDailyId = this.WeldingDailyId;
BLL.WeldingDailyService.AddWeldingDaily(newWeldingDaily);
//BLL.Sys_LogService.AddLog(BLL.Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_WeldReportMenuId, Const.BtnAdd, this.WeldingDailyId);
}
foreach (JObject mergedRow in Grid1.GetMergedData())
{
JObject values = mergedRow.Value<JObject>("values");
int i = mergedRow.Value<int>("index");
string rowId = Grid1.Rows[i].RowID;
if (this.Grid1.SelectedRowIDArray.Contains(rowId))
2023-01-02 12:21:10 +08:00
{
2023-10-27 14:02:52 +08:00
var t = BLL.WeldTaskService.GetWeldTaskById(rowId);
var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(t.WeldJointId);
2023-01-02 12:21:10 +08:00
2023-10-27 14:02:52 +08:00
if (newWeldJoint != null)
{
2023-11-21 20:26:41 +08:00
newWeldJoint.JointAttribute = values.Value<string>("JointAttribute");
2023-10-27 14:02:52 +08:00
var coverWelderCode = (from x in Funs.DB.SitePerson_Person
2023-11-21 20:26:41 +08:00
where x.ProjectId == CurrUser.LoginProjectId &&
x.WelderCode == values.Value<string>("CoverWelderCode")
select x).FirstOrDefault();
2023-10-27 14:02:52 +08:00
if (coverWelderCode != null)
{
t.CoverWelderId = coverWelderCode.PersonId;
newWeldJoint.CoverWelderId = coverWelderCode.PersonId;
2024-06-19 18:52:56 +08:00
newWeldJoint.CoverWelderTeamGroupId = coverWelderCode.TeamGroupId;
2023-10-27 14:02:52 +08:00
}
2023-01-02 12:21:10 +08:00
2023-10-27 14:02:52 +08:00
var backingWelderCode = (from x in Funs.DB.SitePerson_Person
2023-11-21 20:26:41 +08:00
where x.ProjectId == CurrUser.LoginProjectId &&
x.WelderCode == values.Value<string>("BackingWelderCode")
select x).FirstOrDefault();
2023-10-27 14:02:52 +08:00
if (backingWelderCode != null)
2023-01-02 12:21:10 +08:00
{
2023-10-27 14:02:52 +08:00
t.BackingWelderId = backingWelderCode.PersonId;
newWeldJoint.BackingWelderId = backingWelderCode.PersonId;
2024-06-19 18:52:56 +08:00
newWeldJoint.BackingWelderTeamGroupId = backingWelderCode.TeamGroupId;
2023-01-02 12:21:10 +08:00
}
2023-10-27 14:02:52 +08:00
WeldTaskService.UpdateWeldTask(t);
WeldJointService.UpdateWeldJoint(newWeldJoint);
//if (!string.IsNullOrEmpty(values.Value<string>("JointAttribute").ToString()))
//{
// newWeldJoint.JointAttribute = values.Value<string>("JointAttribute").ToString();
//}
//BLL.WeldJointService.UpdateWeldJoint(newWeldJoint);
BLL.WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId,
newWeldJoint.JointAttribute, Const.BtnAdd);
2023-01-02 12:21:10 +08:00
}
}
2023-10-27 14:02:52 +08:00
}
2022-09-05 16:36:31 +08:00
2023-10-27 14:02:52 +08:00
// 获取组批条件
var batchC = BLL.Project_SysSetService.GetSysSetBySetId("5", CurrUser.LoginProjectId);
if (batchC != null)
{
string batchCondition = batchC.SetValue;
// 新建日报
if (weldJointView.Count() == 0)
2022-09-05 16:36:31 +08:00
{
2023-10-27 14:02:52 +08:00
foreach (string row in Grid1.SelectedRowIDArray)
2022-09-05 16:36:31 +08:00
{
2023-10-27 14:02:52 +08:00
var t = BLL.WeldTaskService.GetWeldTaskById(row);
2023-11-21 20:26:41 +08:00
var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(t.WeldJointId);
2023-10-27 14:02:52 +08:00
errlog += InsertWeldingDailyItem(t.WeldJointId, t.CoverWelderId, t.BackingWelderId,
2023-11-21 20:26:41 +08:00
newWeldJoint.JointAttribute, newWeldingDaily.WeldingDate, batchCondition, true);
2022-09-05 16:36:31 +08:00
}
2023-10-27 14:02:52 +08:00
}
else
{
for (int i = 0; i < Grid1.Rows.Count; i++)
2022-09-05 16:36:31 +08:00
{
2023-10-27 14:02:52 +08:00
if (Grid1.SelectedRowIDArray.Contains(Grid1.Rows[i].RowID))
2022-09-05 16:36:31 +08:00
{
2023-10-27 14:02:52 +08:00
var t = BLL.WeldTaskService.GetWeldTaskById(Grid1.Rows[i].RowID);
2023-11-21 20:26:41 +08:00
var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(t.WeldJointId);
2023-10-27 14:02:52 +08:00
errlog += InsertWeldingDailyItem(t.WeldJointId, t.CoverWelderId, t.BackingWelderId,
2023-11-21 20:26:41 +08:00
newWeldJoint.JointAttribute, newWeldingDaily.WeldingDate, batchCondition, true);
2023-10-27 14:02:52 +08:00
}
else
{
var t = BLL.WeldTaskService.GetWeldTaskById(Grid1.Rows[i].RowID);
errlog += BLL.WeldingDailyService
.DeleteWeldingDailyItemByweldJointId(t.WeldJointId);
2022-09-05 16:36:31 +08:00
}
}
}
2023-10-27 14:02:52 +08:00
// 日报已存在的情况 暂时
//else
2022-09-05 16:36:31 +08:00
//{
2023-10-27 14:02:52 +08:00
// var weldJoints = from x in weldJointView select x.WeldJointId;
// foreach (var item in GetWeldingDailyItem)
2022-09-05 16:36:31 +08:00
// {
2023-10-27 14:02:52 +08:00
// // 如日报明细存在则只更新焊口信息,如进批条件改变,则只有删除后再重新增加
// if (weldJoints.Contains(item.WeldJointId))
2022-09-05 16:36:31 +08:00
// {
2023-10-27 14:02:52 +08:00
// var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
// newWeldJoint.WeldingDailyId = this.WeldingDailyId;
// newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim();
// newWeldJoint.CoverWelderId = item.CoverWelderId;
// newWeldJoint.BackingWelderId = item.BackingWelderId;
2022-09-05 16:36:31 +08:00
2023-10-27 14:02:52 +08:00
// if (!string.IsNullOrEmpty(item.JointAttribute))
2022-09-05 16:36:31 +08:00
// {
2023-10-27 14:02:52 +08:00
// newWeldJoint.JointAttribute = item.JointAttribute;
2022-09-05 16:36:31 +08:00
// }
2023-10-27 14:02:52 +08:00
// BLL.WeldJointService.UpdateWeldJoint(newWeldJoint);
// //更新焊口号 修改固定焊口号后 +G
// BLL.WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd);
// }
// else
// {
// errlog += InsertWeldingDailyItem(item, newWeldingDaily.WeldingDate, batchCondition, true);
2022-09-05 16:36:31 +08:00
// }
// }
//}
2023-10-27 14:02:52 +08:00
}
else
{
errlog += "请设置项目的组批条件";
}
2022-09-05 16:36:31 +08:00
2023-10-27 14:02:52 +08:00
#region 60
2023-02-20 21:59:35 +08:00
2023-10-27 14:02:52 +08:00
// 焊工每天超过60达因的提示暂不用
//foreach (var item in GetWeldingDailyItem)
//{
// if (!string.IsNullOrEmpty(item.CoverWelderId) && !string.IsNullOrEmpty(item.BackingWelderId))
// {
// bool cWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.CoverWelderId, newWeldingDaily.WeldingDate.Value);
// bool bWelder = cWelder;
// if (item.CoverWelderId != item.BackingWelderId)
// {
// bWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.BackingWelderId, newWeldingDaily.WeldingDate.Value);
// }
// if (cWelder || bWelder)
// {
// if (cWelder)
// {
// var coverWelder = BLL.SitePerson_PersonService.GetSitePersonById(item.CoverWelderId);
// if (coverWelder != null)
// {
// string txt = Resources.Lan.WelderCode + coverWelder.WelderCode + Resources.Lan.WeldingDiameter;
// if (!errlog.Contains(txt))
// {
// errlog += txt;
// }
// }
// }
// if (bWelder)
// {
// var backingWelder = BLL.SitePerson_PersonService.GetSitePersonById(item.BackingWelderId);
// if (backingWelder != null)
// {
// string txt = Resources.Lan.WelderCode + backingWelder.WelderCode + Resources.Lan.WeldingDiameter;
// if (!errlog.Contains(txt))
// {
// errlog += txt;
// }
// }
// }
// }
// }
//}
#endregion
2023-11-13 17:46:33 +08:00
System.Threading.Tasks.Task.Run(() =>
{
ChanggeState();
});
2023-11-21 20:26:41 +08:00
2023-10-27 14:02:52 +08:00
if (string.IsNullOrEmpty(errlog))
{
ShowNotify("保存成功!", MessageBoxIcon.Success);
drpJointAttribute_SelectedIndexChanged(null, null);
BindGrid(null);
//PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
2022-09-05 16:36:31 +08:00
}
else
{
2023-10-27 14:02:52 +08:00
// string okj = ActiveWindow.GetWriteBackValueReference(newWeldReportMain.WeldingDailyId) + ActiveWindow.GetHidePostBackReference();
Alert.ShowInTop("保存成功!" + "焊接明细中" + errlog, "提交结果", MessageBoxIcon.Warning);
drpJointAttribute_SelectedIndexChanged(null, null);
BindGrid(null);
// ShowAlert("焊接明细中" + errlog, MessageBoxIcon.Warning);
2022-09-05 16:36:31 +08:00
}
}
else
{
2023-10-27 14:02:52 +08:00
Alert.ShowInTop("焊工无资质焊接的焊口:" + eventArg, "提交结果", MessageBoxIcon.Warning);
2022-09-05 16:36:31 +08:00
}
}
protected void btnAccept_Click(object sender, EventArgs e)
{
2023-11-30 12:05:13 +08:00
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(txtWeldingDailyCode.Text) + ActiveWindow.GetHidePostBackReference());
}
2022-09-05 16:36:31 +08:00
#endregion
#region
/// <summary>
/// 一种焊接方法资质判断
/// </summary>
/// <param name="welderQualifys"></param>
/// <param name="wmeCode"></param>
/// <param name="jointAttribute"></param>
/// <param name="weldType"></param>
/// <param name="ste"></param>
/// <param name="dia"></param>
/// <param name="sch"></param>
/// <returns></returns>
private bool OneWmeIsOK(List<Model.Welder_WelderQualify> welderQualifys, string wmeCode, string jointAttribute, string weldType, string ste, decimal? dia, decimal? sch)
{
bool isok = false;
var mat = BLL.Base_MaterialService.GetMaterialByMaterialId(ste);
var welderQ = from x in welderQualifys
where wmeCode.Contains(x.WeldingMethod)
&& (mat == null || x.MaterialType.Contains(mat.MetalType ?? ""))
&& x.WeldType.Contains(weldType)
select x;
if (welderQ.Count() > 0)
{
if (jointAttribute == "安装口")
{
welderQ = welderQ.Where(x => x.IsCanWeldG == true);
}
if (welderQ.Count() > 0)
{
if (weldType == "1") // 1-对接焊缝 2-表示角焊缝,当为角焊缝时,管径和壁厚不限制
{
var welderDiaQ = welderQ.Where(x => x.SizesMin <= dia || x.SizesMax == 0);
if (welderDiaQ.Count() > 0)
{
var welderThick = welderDiaQ.Where(x => x.ThicknessMax >= sch || x.ThicknessMax == 0);
// 只要有一个不限为0就通过
if (welderThick.Count() > 0)
{
isok = true;
}
}
}
else
{
isok = true;
}
}
}
return isok;
}
/// <summary>
/// 两种焊接方法资质判断
/// </summary>
/// <param name="floorWelderQualifys"></param>
/// <param name="cellWelderQualifys"></param>
/// <param name="wmeCode1"></param>
/// <param name="wmeCode2"></param>
/// <param name="jointAttribute"></param>
/// <param name="weldType"></param>
/// <param name="ste"></param>
/// <param name="dia"></param>
/// <param name="sch"></param>
/// <returns></returns>
private bool TwoWmeIsOK(List<Model.Welder_WelderQualify> floorWelderQualifys, List<Model.Welder_WelderQualify> cellWelderQualifys, string wmeCode1, string wmeCode2, string jointAttribute, string weldType, string ste, decimal? dia, decimal? sch)
{
bool isok = false;
decimal? fThicknessMax = 0;
decimal? cThicknessMax = 0;
var mat = BLL.Base_MaterialService.GetMaterialByMaterialId(ste);
var floorQ = from x in floorWelderQualifys
where wmeCode1.Contains(x.WeldingMethod)
&& (mat == null || x.MaterialType.Contains(mat.MetalType ?? ""))
&& x.WeldType.Contains(weldType)
// && (dia == null || x.SizesMin<=dia)
select x;
var cellQ = from x in cellWelderQualifys
where wmeCode2.Contains(x.WeldingMethod)
&& (mat == null || x.MaterialType.Contains(mat.MetalType ?? ""))
&& x.WeldType.Contains(weldType)
// && (dia == null || x.SizesMin <= dia)
select x;
if (floorQ.Count() > 0 && cellQ.Count() > 0)
{
if (jointAttribute == "安装口")
{
floorQ = floorQ.Where(x => x.IsCanWeldG == true);
cellQ = cellQ.Where(x => x.IsCanWeldG == true);
}
if (floorQ.Count() > 0 && cellQ.Count() > 0)
{
if (weldType == "1") // 1-对接焊缝 2-表示角焊缝,当为角焊缝时,管径和壁厚不限制
{
var floorDiaQ = floorQ.Where(x => x.SizesMin <= dia || x.SizesMax == 0);
var cellDiaQ = cellQ.Where(x => x.SizesMin <= dia || x.SizesMax == 0);
if (floorDiaQ.Count() > 0 && cellDiaQ.Count() > 0)
{
var fThick = floorDiaQ.Where(x => x.ThicknessMax == 0);
var cThick = cellDiaQ.Where(x => x.ThicknessMax == 0);
// 只要有一个不限为0就通过
if (fThick.Count() > 0 || cThick.Count() > 0)
{
isok = true;
}
else
{
fThicknessMax = floorQ.Max(x => x.ThicknessMax);
cThicknessMax = cellQ.Max(x => x.ThicknessMax);
if ((fThicknessMax + cThicknessMax) >= sch)
{
isok = true;
}
}
}
}
else
{
isok = true;
}
}
}
return isok;
}
#endregion
#region
/// <summary>
/// 日报明细插入(更新焊口信息),组批等
/// </summary>
/// <param name="item"></param>
/// <param name="weldingDailyId"></param>
/// <returns></returns>
private string InsertWeldingDailyItem(string weldJointId, string coverWelderId, string backingWelderId, string jointAttribute, DateTime? weldingDate, string batchCondition, bool isSave)
{
string errlog = string.Empty;
var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(weldJointId);
if (newWeldJoint != null && string.IsNullOrEmpty(newWeldJoint.WeldingDailyId))
{
if (!string.IsNullOrEmpty(coverWelderId) && !string.IsNullOrEmpty(backingWelderId))
{
2023-09-04 11:15:13 +08:00
newWeldJoint.WeldingDailyId = this.WeldingDailyId;
newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim();
newWeldJoint.CoverWelderId = coverWelderId;
newWeldJoint.BackingWelderId = backingWelderId;
2024-06-20 10:13:31 +08:00
newWeldJoint.CoverWelderTeamGroupId = SitePerson_PersonService.GetSitePersonByProjectIdPersonId(this.CurrUser.LoginProjectId,coverWelderId).TeamGroupId;
newWeldJoint.BackingWelderTeamGroupId = SitePerson_PersonService.GetSitePersonByProjectIdPersonId(this.CurrUser.LoginProjectId, backingWelderId).TeamGroupId;
2023-09-04 11:15:13 +08:00
//if (item.WeldingLocationId != Const._Null)
//{
// newWeldJoint.WeldingLocationId = item.WeldingLocationId;
//}
newWeldJoint.JointAttribute = jointAttribute;
BLL.WeldJointService.UpdateWeldJoint(newWeldJoint);
// 更新焊口号 修改固定焊口号后 +G
BLL.WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd);
2022-09-05 16:36:31 +08:00
if (isSave)
{
2023-09-09 16:44:17 +08:00
errlog = PointBatchService.AddBatchByWeldJointId(weldJointId, weldingDate, batchCondition);//自动组批
2022-09-05 16:36:31 +08:00
}
}
else
{
errlog = "焊口" + "【" + newWeldJoint.WeldJointCode + "】" + "未选择焊工";
}
}
return errlog;
}
#endregion
#region Grid页面信息
/// <summary>
/// 收集Grid页面信息
/// </summary>
/// <returns></returns>
private List<Model.SpWeldingDailyItem> CollectGridJointInfo()
{
List<Model.SpWeldingDailyItem> GetWeldingDailyItem = null;
List<Model.SpWeldingDailyItem> getNewWeldReportItem = new List<Model.SpWeldingDailyItem>();
if (!string.IsNullOrEmpty(this.hdItemsString.Text))
{
GetWeldingDailyItem = BLL.WeldingDailyService.GetWeldReportAddItem(this.hdItemsString.Text);
}
else if (string.IsNullOrEmpty(this.hdItemsString.Text) && this.WeldingDailyId != null)
{
GetWeldingDailyItem = BLL.WeldingDailyService.GetWeldingDailyItem(this.WeldingDailyId);
}
JArray mergedData = Grid1.GetMergedData();
foreach (JObject mergedRow in mergedData)
{
string status = mergedRow.Value<string>("status");
JObject values = mergedRow.Value<JObject>("values");
string rowID = values.Value<string>("WeldJointId").ToString();
var item = GetWeldingDailyItem.FirstOrDefault(x => x.WeldJointId == rowID);
if (item != null)
{
var coverWelderCode = (from x in Funs.DB.SitePerson_Person
where x.ProjectId == CurrUser.LoginProjectId && x.WelderCode == values.Value<string>("CoverWelderId")
select x).FirstOrDefault();
if (coverWelderCode != null)
{
item.CoverWelderCode = coverWelderCode.WelderCode;
item.CoverWelderId = coverWelderCode.PersonId;
}
var backingWelderCode = (from x in Funs.DB.SitePerson_Person
where x.ProjectId == CurrUser.LoginProjectId && x.WelderCode == values.Value<string>("BackingWelderId")
select x).FirstOrDefault();
if (backingWelderCode != null)
{
item.BackingWelderCode = backingWelderCode.WelderCode;
item.BackingWelderId = backingWelderCode.PersonId;
}
if (!string.IsNullOrEmpty(values.Value<string>("JointAttribute")))
{
item.JointAttribute = values.Value<string>("JointAttribute").ToString();
}
getNewWeldReportItem.Add(item);
}
}
return getNewWeldReportItem;
}
#endregion
#region Grid
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
List<Model.SpWeldingDailyItem> GetWeldingDailyItem = BLL.WeldingDailyService.GetWeldReportAddItem(this.hdItemsString.Text);
this.BindGrid(GetWeldingDailyItem);
//SetDrpByDrpUnitChange();
//this.hdItemsString.Text = string.Empty;
}
#endregion
#region
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
List<Model.SpWeldingDailyItem> GetWeldingDailyItem = this.CollectGridJointInfo();
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var item = GetWeldingDailyItem.FirstOrDefault(x => x.WeldJointId == rowID);
var p = BLL.PointBatchDetailService.GetBatchDetailByJotId(rowID);
if (item != null && (p == null || (p != null && p.PointState == null)))
{
GetWeldingDailyItem.Remove(item);
// 删除焊口所在批明细信息
if (p != null)
{
BLL.PointBatchDetailService.DeleteBatchDetail(item.WeldJointId);
}
// // 更新焊口信息
var updateWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
if (updateWeldJoint != null)
{
updateWeldJoint.WeldingDailyId = null;
updateWeldJoint.WeldingDailyCode = null;
updateWeldJoint.CoverWelderId = null;
updateWeldJoint.BackingWelderId = null;
2024-06-19 18:52:56 +08:00
updateWeldJoint.CoverWelderTeamGroupId= null;
updateWeldJoint.BackingWelderTeamGroupId = null;
2022-09-05 16:36:31 +08:00
BLL.WeldJointService.UpdateWeldJoint(updateWeldJoint);
}
}
else
{
Alert.ShowInTop("不能删除,已检测并审核!", MessageBoxIcon.Warning);
}
}
BindGrid(GetWeldingDailyItem);
ShowNotify("删除成功!", MessageBoxIcon.Success);
}
}
#endregion
#region
protected void WeldingDateText_OnTextChanged(object sender, EventArgs e)
{
2023-11-24 12:20:07 +08:00
string perfix = string.Format("{0:yyyyMMdd}", Funs.GetNewDateTimeOrNow(this.txtWeldingDate.Text.Trim())) + "-" + this.CurrUser.PersonName + "-";
2023-11-24 11:35:23 +08:00
this.txtWeldingDailyCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "dbo.HJGL_WeldingDaily", "WeldingDailyCode", this.CurrUser.LoginProjectId, perfix);
2022-09-05 16:36:31 +08:00
BindGrid(null);
}
/// <summary>
/// 查找未焊接焊口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ckSelect_Click(object sender, EventArgs e)
{
//string weldJointIds = string.Empty;
//for (int i = 0; i < Grid1.Rows.Count; i++)
//{
// string weldJointId = Grid1.DataKeys[i][0].ToString();
// weldJointIds = weldJointIds + weldJointId + "|";
//}
//if (weldJointIds != string.Empty)
//{
// weldJointIds = weldJointIds.Substring(0, weldJointIds.Length - 1);
//}
string weldJointIds = hdItemsString.Text.Trim();
if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpUnitWork.SelectedValue) && this.drpUnitWork.SelectedValue != BLL.Const._Null)
{
string strList = this.drpUnitWork.SelectedValue + "|" + this.drpUnit.SelectedValue + "|" + this.WeldingDailyId;
string window = String.Format("SelectDailyWeldJoint.aspx?strList={0}&weldJointIds={1}", strList, Server.UrlEncode(weldJointIds), "编辑 - ");
//PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdItemsString.ClientID) + Window1.GetShowReference(window));
}
else
{
Alert.ShowInTop("请选择单位和单位工程", MessageBoxIcon.Warning);
}
}
#endregion
protected void drpJointAttribute_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.WeldingDailyId))
{
2023-11-21 20:26:41 +08:00
List<Model.SpWeldingDailyItem> GetWeldingDailyItem = BLL.WeldingDailyService.GetWeldingDailyItem(this.WeldingDailyId);
2022-09-05 16:36:31 +08:00
this.BindGrid(GetWeldingDailyItem); // 初始化页面
}
else
{
this.BindGrid(null);
}
}
2023-02-20 21:59:35 +08:00
private void ChanggeState()
{
2023-10-27 14:02:52 +08:00
if (!string.IsNullOrEmpty(this.WeldingDailyId) && Grid1.SelectedRowIDArray.Length > 0)
2023-02-20 21:59:35 +08:00
{
2023-10-27 14:02:52 +08:00
foreach (var rowId in Grid1.SelectedRowIDArray)
{
2023-11-21 20:26:41 +08:00
2023-10-27 14:02:52 +08:00
var t = BLL.WeldTaskService.GetWeldTaskById(rowId);
var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(t.WeldJointId);
var daily = BLL.WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(WeldingDailyId);
BLL.HJGL_PipelineComponentjointService.UpdateStateByWeldJointId(newWeldJoint.WeldJointId, (DateTime)daily.WeldingDate);//更改预制口实际时间和状态
PipelineService.UpdataDateByWeldJointId(newWeldJoint.WeldJointId);//更改安装口时间和状态
}
/*List<Model.SpWeldingDailyItem> GetWeldingDailyItem = BLL.WeldingDailyService.GetWeldingDailyItem(this.WeldingDailyId);
2023-02-20 21:59:35 +08:00
foreach (var item in GetWeldingDailyItem)
{
var daily = BLL.WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(WeldingDailyId);
BLL.HJGL_PipelineComponentjointService.UpdateStateByWeldJointId(item.WeldJointId, (DateTime)daily.WeldingDate);//更改预制口实际时间和状态
PipelineService.UpdataDateByWeldJointId(item.WeldJointId);//更改安装口时间和状态
2023-01-02 12:21:10 +08:00
2023-10-27 14:02:52 +08:00
}*/
2023-02-20 21:59:35 +08:00
}
2023-11-21 20:26:41 +08:00
2023-02-20 21:59:35 +08:00
}
2023-01-02 12:21:10 +08:00
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
DataRowView row = e.DataItem as DataRowView;
2023-11-21 20:26:41 +08:00
var id = row["WeldJointId"].ToString();
2023-01-02 12:21:10 +08:00
var hotProesssItem = Funs.DB.HJGL_HotProess_TrustItem.FirstOrDefault(x => x.WeldJointId == id);
if (hotProesssItem != null) //已生成热处理委托,不能编辑或删除
{
2023-11-21 20:26:41 +08:00
e.RowSelectable = false;
2023-01-02 12:21:10 +08:00
// Grid1.DeleteRow(e.RowID);
2023-11-21 20:26:41 +08:00
// Grid1.DeleteRow(e.RowID);
2023-01-02 12:21:10 +08:00
}
var pointBatchItem = Funs.DB.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.WeldJointId == id && x.PointState != null);
if (pointBatchItem != null) //已生成委托,不能编辑或删除
{
2023-11-21 20:26:41 +08:00
e.RowSelectable = false;
// Grid1.DeleteRow(e.RowID);
2023-01-02 12:21:10 +08:00
// Grid1.DeleteRow(e.RowID);
}
2023-11-21 20:26:41 +08:00
//for (int i = 0; i < this.Grid1.Rows.Count; i++)
//{
// var hotProesssItem = Funs.DB.HJGL_HotProess_TrustItem.FirstOrDefault(x => x.WeldJointId == this.Grid1.Rows[i].DataKeys[1].ToString());
// if (hotProesssItem != null) //已生成热处理委托,不能编辑或删除
// {
// Grid1.Rows[i].RowSelectable = false;
// }
// var pointBatchItem = Funs.DB.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.WeldJointId == this.Grid1.Rows[i].DataKeys[1].ToString() && x.PointState != null);
// if (pointBatchItem != null) //已生成委托,不能编辑或删除
// {
// Grid1.Rows[i].RowSelectable = false;
// }
//}
2023-01-02 12:21:10 +08:00
}
2023-02-20 21:59:35 +08:00
#region
/// <summary>
/// 分页选择下拉改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.WeldingDailyId))
{
List<Model.SpWeldingDailyItem> GetWeldingDailyItem = BLL.WeldingDailyService.GetWeldingDailyItem(this.WeldingDailyId);
this.BindGrid(GetWeldingDailyItem); // 初始化页面
}
else
{
this.BindGrid(null);
}
}
#endregion
2023-10-27 17:46:32 +08:00
#region
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSaveWelder_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(drpCanWelder.SelectedValue))
{
string[] selectedRowId = Grid1.SelectedRowIDArray;
for (int i = 0; i < selectedRowId.Count(); i++)
{
string weldTaskId = selectedRowId[i];
2023-11-28 18:32:03 +08:00
var weldTask = BLL.WeldTaskService.GetWeldTaskById(weldTaskId);
if (weldTask != null && string.IsNullOrEmpty(weldTask.CoverWelderId) && string.IsNullOrEmpty(weldTask.BackingWelderId))
{
BLL.WeldTaskService.UpdateWelderTask(weldTaskId, drpCanWelder.SelectedValue);
}
2023-10-27 17:46:32 +08:00
}
this.BindGrid(null);
2023-11-28 17:41:03 +08:00
this.Grid1.SelectedRowIDArray = selectedRowId;
2023-11-21 20:26:41 +08:00
drpCanWelder.Items.Clear();
2023-10-27 17:46:32 +08:00
}
}
protected void btnSelectWelder_Click(object sender, EventArgs e)
{
GetCanWelderDropDownList();
}
/// <summary>
/// 获取能焊焊工下拉列表
/// </summary>
/// <param name="weldingTask"></param>
private void GetCanWelderDropDownList()
{
drpCanWelder.Items.Clear();
string[] selectedRowId = Grid1.SelectedRowIDArray;
List<string> canWelder = null;
var taskList = from x in Funs.DB.HJGL_WeldTask where x.ProjectId == this.CurrUser.LoginProjectId select x;
for (int i = 0; i < selectedRowId.Count(); i++)
{
Model.HJGL_WeldTask task = taskList.FirstOrDefault(x => x.WeldTaskId == selectedRowId[i]);
if (!string.IsNullOrEmpty(task.CanWelderId))
{
List<string> jotCanWelder = task.CanWelderId.Split(',').ToList();
if (i == 0)
{
canWelder = jotCanWelder;
}
else
{
canWelder = canWelder.Intersect(jotCanWelder).ToList();
}
}
else
{
canWelder = null;
break;
}
}
if (canWelder != null)
{
var welder = from x in canWelder
join y in Funs.DB.SitePerson_Person on x equals y.PersonId
select new { WelderId = x, y.WelderCode };
drpCanWelder.DataValueField = "WelderId";
drpCanWelder.DataTextField = "WelderCode";
drpCanWelder.DataSource = welder;
drpCanWelder.DataBind();
}
}
#endregion
2022-09-05 16:36:31 +08:00
}
}