Basf_TCC7/HJGL/FineUIPro.Web/WeldingProcess/CheckManage/RepairNotice.aspx.cs

266 lines
12 KiB
C#
Raw Normal View History

2024-05-08 10:02:08 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using BLL;
2024-10-10 10:35:01 +08:00
using NPOI.SS.Formula.Functions;
2024-05-08 10:02:08 +08:00
namespace FineUIPro.Web.WeldingProcess.CheckManage
{
public partial class RepairNotice : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
string ndeItemId = Request.Params["NDEItemID"];
var q = BLL.Batch_NDEItemService.GetNDEItemViewById(ndeItemId);
txtPipeCode.Text = q.PipelineCode;
txtWeldJointCode.Text = q.WeldJointCode;
txtWelder.Text = q.WelderCode;
txtJudgeGrade.Text = q.JudgeGrade;
txtRepairLocation.Text = q.RepairLocation;
txtCheckDefects.Text = BLL.Base_DefectService.GetDefectNameStrByDefectIdStr(q.CheckDefects);
var repair = BLL.RepairRecordService.GetRepairRecordByNdeItemId(ndeItemId);
if (repair == null)
{
var mark = from x in BLL.Funs.DB.Repair_RepairRecord
where x.WeldJointId == q.WeldJointId && x.DetectionTypeId == q.DetectionTypeId
orderby x.RepairMark descending
select x;
if (mark.Count() == 0)
{
2024-10-10 10:35:01 +08:00
if (q.PassFilm != q.TotalFilm)
{
txtRepairMark.Text = "R1";
}
if (q.Remark.Contains("修磨"))
{
txtRepairMark.Text = "P1";
}
if (q.Remark.Contains("异物"))
{
txtRepairMark.Text = "S1";
}
2024-05-08 10:02:08 +08:00
}
else
{
string m = mark.First().RepairMark;
string first = m.Substring(0, 1);
string last = m.Substring(1, 1);
int n = Convert.ToInt32(last) + 1;
txtRepairMark.Text = first + n.ToString();
}
btnSubmit.Hidden = false;
}
else
{
btnSubmit.Hidden = true;
txtRepairMark.Text = "R1";
if (!string.IsNullOrEmpty(repair.PhotoUrl))
{
imgPhoto.ImageUrl = repair.PhotoUrl;
}
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string ndeItemId = Request.Params["NDEItemID"];
var q = BLL.Batch_NDEItemService.GetNDEItemViewById(ndeItemId);
var repair = BLL.RepairRecordService.GetRepairRecordByNdeItemId(ndeItemId);
Model.Repair_RepairRecord newItem = new Model.Repair_RepairRecord();
2024-10-10 10:35:01 +08:00
string newJointCode = string.Empty;
2024-05-08 10:02:08 +08:00
if (repair == null)
{
2024-10-10 10:35:01 +08:00
if (q.CheckResult != null)
2024-05-08 10:02:08 +08:00
{
2024-10-10 10:35:01 +08:00
newItem.RepairRecordId = SQLHelper.GetNewID(typeof(Model.Repair_RepairRecord));
string code = q.TrustBatchCode;
if (code.Substring(code.Length - 2, 1) == "R")
2024-05-08 10:02:08 +08:00
{
2024-10-10 10:35:01 +08:00
string first = code.Substring(0, code.Length - 1);
string last = code.Substring(code.Length - 1);
int n = Convert.ToInt32(last) + 1;
newItem.RepairRecordCode = first + n.ToString();
newJointCode = q.WeldJointCode.Substring(0, q.WeldJointCode.Length - 2) + "R" + n.ToString();
2024-05-08 10:02:08 +08:00
}
else
{
2024-10-10 10:35:01 +08:00
if (q.CheckResult != "1") // 不合格
2024-06-07 07:28:00 +08:00
{
2024-10-10 10:35:01 +08:00
if (code.Substring(code.Length - 3, 2) == "EX")
{
newItem.RepairRecordCode = q.TrustBatchCode.Substring(0, code.Length - 3) + "-" + "EX1R1";
}
else
{
newItem.RepairRecordCode = q.TrustBatchCode + "R1";
}
if (!q.WeldJointCode.Contains("R1"))
{
newJointCode = q.WeldJointCode + "R1";
}
else
{
newJointCode = q.WeldJointCode;
}
2024-06-07 07:28:00 +08:00
}
2024-10-10 10:35:01 +08:00
else // 合格但有修磨或异物
2024-05-08 10:02:08 +08:00
{
2024-10-10 10:35:01 +08:00
if (q.Remark.Contains("修磨"))
{
newItem.RepairRecordCode = q.TrustBatchCode + "P1";
if (!q.WeldJointCode.Contains("P1"))
{
newJointCode = q.WeldJointCode + "P1";
}
else
{
newJointCode = q.WeldJointCode;
}
}
if (q.Remark.Contains("异物"))
{
newItem.RepairRecordCode = q.TrustBatchCode + "S1";
if (!q.WeldJointCode.Contains("S1"))
{
newJointCode = q.WeldJointCode + "S1";
}
else
{
newJointCode = q.WeldJointCode;
}
}
2024-05-08 10:02:08 +08:00
}
2024-10-10 10:35:01 +08:00
#region
//if (code.Substring(code.Length - 3, 2) == "EX")
//{
// newItem.RepairRecordCode = q.TrustBatchCode.Substring(0, code.Length - 3) + "-" + "EX1R1";
// if (!q.WeldJointCode.Contains("R1"))
// {
// newJointCode = q.WeldJointCode + "R1";
// }
// else
// {
// newJointCode = q.WeldJointCode;
// }
//}
//else
//{
// if (q.Remark.Contains("修磨"))
// {
// newItem.RepairRecordCode = q.TrustBatchCode + "P1";
// if (!q.WeldJointCode.Contains("P1"))
// {
// newJointCode = q.WeldJointCode + "P1";
// }
// else
// {
// newJointCode = q.WeldJointCode;
// }
// }
// else if (q.Remark.Contains("异物"))
// {
// newItem.RepairRecordCode = q.TrustBatchCode + "S1";
// if (!q.WeldJointCode.Contains("S1"))
// {
// newJointCode = q.WeldJointCode + "S1";
// }
// else
// {
// newJointCode = q.WeldJointCode;
// }
// }
// else
// {
// newItem.RepairRecordCode = q.TrustBatchCode + "R1";
// if (!q.WeldJointCode.Contains("R1"))
// {
// newJointCode = q.WeldJointCode + "R1";
// }
// else
// {
// newJointCode = q.WeldJointCode;
// }
// }
//}
#endregion
2024-05-08 10:02:08 +08:00
}
2024-10-10 10:35:01 +08:00
var isExistRepairRecordCode = from x in Funs.DB.Repair_RepairRecord where x.RepairRecordCode == newItem.RepairRecordCode select x;
if (isExistRepairRecordCode.Count() > 0)
{
ShowNotify("该返修号已存在!请修改已存在的返修号", MessageBoxIcon.Warning);
return;
}
newItem.ProjectId = q.ProjectId;
newItem.UnitId = q.UnitId;
newItem.InstallationId = q.InstallationId;
newItem.WorkAreaId = q.WorkAreaId;
newItem.NoticeDate = DateTime.Now;
newItem.NDEItemID = ndeItemId;
newItem.WeldJointId = q.WeldJointId;
newItem.DetectionTypeId = q.DetectionTypeId;
newItem.WelderId = q.BackingWelderId;
newItem.RepairLocation = q.RepairLocation;
newItem.CheckDefects = txtCheckDefects.Text;
newItem.RepairMark = txtRepairMark.Text;
newItem.PhotoUrl = imgPhoto.ImageUrl;
BLL.RepairRecordService.AddRepairRecord(newItem);
// 回写焊口号
var joint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(q.WeldJointId);
joint.WeldJointCode = newJointCode;
joint.OldWeldJointCode = q.WeldJointCode;
Funs.DB.SubmitChanges();
}
else
{
ShowNotify("没有检测结果!不能生成委托单", MessageBoxIcon.Warning);
2024-05-08 10:02:08 +08:00
}
}
else
{
ShowNotify("已生成返修通知单!不能重复生成", MessageBoxIcon.Warning);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
//repair.CheckDefects = txtCheckDefects.Text;
//repair.RepairMark = txtRepairMark.Text;
//repair.PhotoUrl = imgPhoto.ImageUrl;
//BLL.RepairRecordService.UpdateRepairRecord(repair);
}
ShowNotify("生成返修通知单!", MessageBoxIcon.Success);
}
#region
/// <summary>
/// 上传照片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void filePhoto_FileSelected(object sender, EventArgs e)
{
if (filePhoto.HasFile)
{
string fileName = filePhoto.ShortFileName;
if (!ValidateFileType(fileName))
{
ShowNotify("无效的文件类型!");
return;
}
fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
fileName = DateTime.Now.Ticks.ToString() + "_" + fileName;
filePhoto.SaveAs(Server.MapPath("~/upload/" + fileName));
imgPhoto.ImageUrl = "~/upload/" + fileName;
// 清空文件上传组件
filePhoto.Reset();
}
}
#endregion
}
}