416 lines
21 KiB
C#
416 lines
21 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace FineUIPro.Web.HJGL.CheckManage
|
|
{
|
|
public partial class RepairNotice : PageBase
|
|
{
|
|
#region 定义量
|
|
/// <summary>
|
|
/// 委托明细主键
|
|
/// </summary>
|
|
private string CH_TrustItemID
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["CH_TrustItemID"];
|
|
}
|
|
set
|
|
{
|
|
|
|
ViewState["CH_TrustItemID"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返修ID
|
|
/// </summary>
|
|
private string ToRepairId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ToRepairId"];
|
|
}
|
|
set
|
|
{
|
|
|
|
ViewState["ToRepairId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.CH_TrustItemID = Request.Params["trustItemID"];
|
|
List<Model.HJGL_BO_QualityRating> qualityRatingLists = new List<Model.HJGL_BO_QualityRating>();
|
|
|
|
if (!string.IsNullOrEmpty(CH_TrustItemID))
|
|
{
|
|
var repair = from x in Funs.DB.HJGL_CH_RepairItemRecord where x.TrustItemID == CH_TrustItemID select x;
|
|
if (repair.Count() == 0)
|
|
{
|
|
var trustItem = BLL.HJGL_CH_TrustItemService.GetTrustItemByID(CH_TrustItemID);
|
|
var joint = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(trustItem.JOT_ID);
|
|
var trust = BLL.HJGL_TrustManageEditService.GetCH_TrustByID(trustItem.CH_TrustID);
|
|
|
|
//Model.HJGL_CH_Repair newRepair = new Model.HJGL_CH_Repair();
|
|
//newRepair.CH_RepairID = SQLHelper.GetNewID(typeof(Model.HJGL_CH_Repair));
|
|
//ToRepairId = newRepair.CH_RepairID;
|
|
//newRepair.ProjectId = trust.ProjectId;
|
|
//newRepair.TrustItemID = CH_TrustItemID;
|
|
//newRepair.NDT_ID = trust.CH_NDTMethod;
|
|
//newRepair.JOT_ID = trustItem.JOT_ID;
|
|
//newRepair.RepairTrustDate = DateTime.Now.Date;
|
|
//newRepair.CH_RepairNo = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId", "dbo.HJGL_CH_Repair", "CH_RepairNo", trust.ProjectId, "R-");
|
|
//BLL.HJGL_RepairService.AddCH_Repair(newRepair);
|
|
|
|
string defectNatures = string.Empty;
|
|
qualityRatingLists = BLL.HJGL_BO_QualityRatingService.GetQualityRatingByTrustDetailId(this.CH_TrustItemID);
|
|
foreach (var item in qualityRatingLists)
|
|
{
|
|
if (item.Cack == true)
|
|
{
|
|
defectNatures += "裂纹,";
|
|
}
|
|
if (item.NotFusion == true)
|
|
{
|
|
defectNatures += "未熔合,";
|
|
}
|
|
if (item.NotPenetration == true)
|
|
{
|
|
defectNatures += "未焊透,";
|
|
}
|
|
if (item.StripDefects == true)
|
|
{
|
|
defectNatures += "条状缺陷,";
|
|
}
|
|
if (item.CircularDefects == true)
|
|
{
|
|
defectNatures += "圆形缺陷,";
|
|
}
|
|
if (item.DeepHoleDefects == true)
|
|
{
|
|
defectNatures += "深孔缺陷,";
|
|
}
|
|
if (item.RootsConcave == true)
|
|
{
|
|
defectNatures += "根部内凹,";
|
|
}
|
|
if (item.RootsBiteEdge == true)
|
|
{
|
|
defectNatures += "根部咬边,";
|
|
}
|
|
if (item.PseudoDefects == true)
|
|
{
|
|
defectNatures += "伪缺陷,";
|
|
}
|
|
if (item.IsPass == "不合格")
|
|
{
|
|
if (!string.IsNullOrEmpty(defectNatures))
|
|
{
|
|
defectNatures = defectNatures.Substring(0, defectNatures.LastIndexOf(","));
|
|
}
|
|
//Model.HJGL_CH_RepairItem newRepairItem = new Model.HJGL_CH_RepairItem();
|
|
//newRepairItem.DefectNature = defectNatures;
|
|
//newRepairItem.FilmNum = item.FilmNum;
|
|
//newRepairItem.CH_RepairItemId = SQLHelper.GetNewID(typeof(Model.HJGL_BO_RepairNotice));
|
|
//newRepairItem.CH_RepairID = newRepair.CH_RepairID;
|
|
//newRepairItem.JOT_ID = item.JOT_ID;
|
|
//newRepairItem.States = "3"; // 待拍片
|
|
//BLL.HJGL_RepairItemService.AddCH_RepairItem(newRepairItem);
|
|
//defectNatures = string.Empty;
|
|
|
|
Model.HJGL_CH_RepairItemRecord newRepairItemRecord = new Model.HJGL_CH_RepairItemRecord();
|
|
newRepairItemRecord.RepairItemRecordId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_RepairItemRecord));
|
|
newRepairItemRecord.ProjectId = trust.ProjectId;
|
|
newRepairItemRecord.ISO_ID = joint.ISO_ID;
|
|
newRepairItemRecord.JOT_ID = trustItem.JOT_ID;
|
|
newRepairItemRecord.FilmNum = item.FilmNum;
|
|
newRepairItemRecord.DefectNature = defectNatures;
|
|
newRepairItemRecord.TrustItemID = trustItem.CH_TrustItemID;
|
|
newRepairItemRecord.BatchId = trust.BatchId;
|
|
newRepairItemRecord.RepairMark = "R1";
|
|
newRepairItemRecord.FeedbackDate = DateTime.Now;
|
|
newRepairItemRecord.NDT_ID = trust.CH_NDTMethod;
|
|
newRepairItemRecord.SignMan = this.CurrUser.UserName;
|
|
BLL.HJGL_CH_RepairItemRecordService.AddCH_RepairItemRecord(newRepairItemRecord);
|
|
|
|
defectNatures = string.Empty;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ToRepairId = repair.First().TrustItemID;
|
|
}
|
|
|
|
var repairItem = from x in Funs.DB.HJGL_CH_RepairItemRecord
|
|
join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID
|
|
where x.TrustItemID == CH_TrustItemID
|
|
select new { x.RepairItemRecordId, y.JOT_JointNo, x.FilmNum, x.DefectNature };
|
|
|
|
Grid1.DataSource = repairItem;
|
|
Grid1.DataBind();
|
|
|
|
//BindGrid();//扩透
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 行点击事件
|
|
/// <summary>
|
|
/// Grid行点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string repairItemId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
if (e.CommandName == "attchUrl")
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/RepairNotice&menuId={1}&edit=1", repairItemId, BLL.Const.HJGL_RepairManageEditMenuId)));
|
|
}
|
|
if (e.CommandName == "print")
|
|
{
|
|
var repairItemRecord = BLL.HJGL_CH_RepairItemRecordService.GetRepairItemRecordById(repairItemId);
|
|
if (repairItemRecord != null)
|
|
{
|
|
//repairItemRecord.SignMan = "";
|
|
repairItemRecord.SignDate = DateTime.Now;
|
|
repairItemRecord.ReceiveMan = this.CurrUser.UserName;
|
|
repairItemRecord.ReceiveDate = DateTime.Now;
|
|
BLL.HJGL_CH_RepairItemRecordService.UpdateCH_RepairItemRecord(repairItemRecord);
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../RepairManage/RepairNoticePrint.aspx?repairItemRecordId={0}", repairItemId, "编辑 - ")));
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
// private void BindGrid()
|
|
// {
|
|
// var trustDetail = BLL.HJGL_TrustManageEditService.GetCH_TrustItemById(CH_TrustItemID);
|
|
// var jotInfo = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(trustDetail.JOT_ID);
|
|
// var trust = BLL.HJGL_TrustManageEditService.GetCH_TrustByID(trustDetail.CH_TrustID);
|
|
// var batchP = Funs.DB.HJGL_BO_BatchDetail.FirstOrDefault(e => e.ToRepairId == ToRepairId);
|
|
|
|
// string strSql = @"SELECT BatchDetail.BatchDetailId,BatchDetail.BatchId,BatchDetail.ISO_ID,
|
|
// BatchDetail.JOT_ID,BatchDetail.NDT,BatchDetail.PointDate,
|
|
// (case when BatchDetail.PointType='2' then 'K' else NULL End) as ExpansionPat,
|
|
// BatchDetail.ConfirmDate,BatchDetail.CheckAddress,BatchDetail.IsVI,
|
|
// BatchDetail.Checker,BatchDetail.Remark,NULL AS FeedbackMan,NULL AS FeedbackDate,
|
|
// Batch.BatchCode,NULL AS CH_TrustDate,Unit.UnitName,IsoInfo.ISO_IsoNo,
|
|
// JointInfo.JOT_JointNo,Project.ProjectCode,Project.ProjectName
|
|
// FROM dbo.HJGL_BO_BatchDetail BatchDetail
|
|
// LEFT JOIN dbo.HJGL_BO_Batch AS Batch ON BatchDetail.BatchId = Batch.BatchId
|
|
// LEFT JOIN dbo.HJGL_PW_JointInfo AS JointInfo ON JointInfo.JOT_ID = BatchDetail.JOT_ID
|
|
// LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = BatchDetail.ISO_ID
|
|
// LEFT JOIN dbo.Base_Unit AS Unit ON Unit.UnitId = IsoInfo.BSU_ID
|
|
// LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId = Batch.ProjectId
|
|
// WHERE (BatchDetail.BatchId=@BatchId and JointInfo.JOT_CellWelder=@CellWelder and PointType is null)";
|
|
// List<SqlParameter> listStr = new List<SqlParameter>();
|
|
// listStr.Add(new SqlParameter("@BatchId", trust.BatchId)); // 同批次
|
|
// listStr.Add(new SqlParameter("@CellWelder", jotInfo.JOT_CellWelder)); // 同焊工
|
|
// if (batchP != null) // 已选了扩透口
|
|
// {
|
|
// strSql = strSql + " OR BatchDetail.ToRepairId=@ToRepairId";
|
|
// listStr.Add(new SqlParameter("@ToRepairId", ToRepairId));
|
|
// }
|
|
// SqlParameter[] parameter = listStr.ToArray();
|
|
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// // 2.获取当前分页数据
|
|
// //var table = this.GetPagedDataTable(Grid2, tb1);
|
|
// Grid2.RecordCount = tb.Rows.Count;
|
|
// tb = GetFilteredTable(Grid2.FilteredData, tb);
|
|
// var table = this.GetPagedDataTable(Grid2, tb);
|
|
// Grid2.DataSource = table;
|
|
// Grid2.DataBind();
|
|
// }
|
|
#endregion
|
|
|
|
//protected void Grid2_RowCommand(object sender, GridCommandEventArgs e)
|
|
//{
|
|
// if (e.CommandName == "CheckBox1")
|
|
// {
|
|
// string batchDetailId = Grid2.DataKeys[e.RowIndex][0].ToString();
|
|
// Model.HJGL_BO_BatchDetail detail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId);
|
|
// var trustDetail = BLL.HJGL_TrustManageEditService.GetCH_TrustItemById(CH_TrustItemID);
|
|
// var trust = BLL.HJGL_TrustManageEditService.GetCH_TrustByID(trustDetail.CH_TrustID);
|
|
// CheckBoxField checkField = (CheckBoxField)Grid2.FindColumn(e.ColumnIndex);
|
|
// bool checkState = checkField.GetCheckedState(e.RowIndex);
|
|
// if (checkState == true)
|
|
// {
|
|
|
|
// detail.NDT = trust.CH_NDTMethod;
|
|
// detail.PointType = "2";
|
|
// detail.PointDate = DateTime.Now.Date;
|
|
// detail.ToRepairId = this.ToRepairId;
|
|
// }
|
|
// else
|
|
// {
|
|
// detail.NDT = null;
|
|
// detail.PointType = null;
|
|
// detail.PointDate = null;
|
|
// detail.ToRepairId = null;
|
|
// }
|
|
// BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(detail);
|
|
// BindGrid();
|
|
// }
|
|
//}
|
|
|
|
#region Grid绑定事件
|
|
///// <summary>
|
|
///// Grid1绑定事件
|
|
///// </summary>
|
|
///// <param name="sender"></param>
|
|
///// <param name="e"></param>
|
|
//protected void Grid2_RowDataBound(object sender, GridRowEventArgs e)
|
|
//{
|
|
// string batchDetailId = Grid2.DataKeys[e.RowIndex][0].ToString();
|
|
// var trustDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId);
|
|
// System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid2.Rows[e.RowIndex].FindControl("cblNDT"));
|
|
// CheckBoxField checkField = (CheckBoxField)Grid2.FindColumn("CbxSelected");
|
|
|
|
// if (!string.IsNullOrEmpty(trustDetail.ToRepairId))
|
|
// {
|
|
// checkField.SetCheckedState(e.RowIndex, true);
|
|
// }
|
|
|
|
// cblNDT.DataTextField = "NDT_Code";
|
|
// cblNDT.DataValueField = "NDT_ID";
|
|
// cblNDT.DataSource = BLL.HJGL_TestingService.GetNDTTypeNameList();
|
|
// cblNDT.DataBind();
|
|
|
|
// var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId);
|
|
// if (batchDetail != null)
|
|
// {
|
|
// if (!string.IsNullOrEmpty(batchDetail.NDT))
|
|
// {
|
|
// List<string> ndtIds = batchDetail.NDT.Split(',').ToList();
|
|
// foreach (var ndtId in ndtIds)
|
|
// {
|
|
// for (int i = 0; i < cblNDT.Items.Count; i++)
|
|
// {
|
|
// if (cblNDT.Items[i].Value == ndtId)
|
|
// {
|
|
// cblNDT.Items[i].Selected = true;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
/// <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.HJGL_CheckMenuId, Const.BtnSave))
|
|
{
|
|
//CheckBoxField checkField = (CheckBoxField)Grid2.FindColumn("CbxSelected");
|
|
//CheckBoxField checkIsVI = (CheckBoxField)Grid2.FindColumn("IsVI");
|
|
//JArray MergedData = Grid2.GetMergedData();
|
|
//int i = 0;
|
|
//foreach (JObject mergedRow in MergedData)
|
|
//{
|
|
// string batchDetailId = Grid2.DataKeys[i][0].ToString();
|
|
// bool checkState = checkField.GetCheckedState(i);
|
|
|
|
// //修改组批已点口
|
|
// var batchDetail = BLL.HJGL_BO_BatchDetailService.GetBatchDetailById(batchDetailId);
|
|
// if (batchDetail != null)
|
|
// {
|
|
// if (checkState==true)
|
|
// {
|
|
// JObject values = mergedRow.Value<JObject>("values");
|
|
// batchDetail.IsVI = checkIsVI.GetCheckedState(i);
|
|
// if (!string.IsNullOrEmpty(values.Value<string>("ConfirmDate")))
|
|
// {
|
|
// batchDetail.ConfirmDate = values.Value<DateTime>("ConfirmDate");
|
|
// }
|
|
// string remarke = values.Value<string>("Remarke");
|
|
// BLL.HJGL_BO_BatchDetailService.UpdateBatchDetail(batchDetail);
|
|
// BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "扩透焊口!");
|
|
// ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
// }
|
|
// }
|
|
// i++;
|
|
//}
|
|
//// 生成扩透口委托单
|
|
//var trustDetail = BLL.HJGL_CH_TrustItemService.GetTrustItemByID(CH_TrustItemID);
|
|
//var trust = BLL.HJGL_TrustManageEditService.GetCH_TrustByID(trustDetail.CH_TrustID);
|
|
//var ndt = BLL.HJGL_TestingService.GetTestingByTestingId(trust.CH_NDTMethod);
|
|
//var trustItem = from x in Funs.DB.HJGL_CH_TrustItem
|
|
// join y in Funs.DB.HJGL_BO_BatchDetail on x.BatchDetailId equals y.BatchDetailId
|
|
// where y.ToRepairId == ToRepairId
|
|
// select x;
|
|
//var batchDetails = from x in Funs.DB.HJGL_BO_BatchDetail where x.ToRepairId == ToRepairId select x;
|
|
//if (trustItem.Count() == 0) // 判断是否已生成委托单
|
|
//{
|
|
// Model.HJGL_CH_Trust t = new Model.HJGL_CH_Trust();
|
|
// t.BatchId = trust.BatchId;
|
|
// t.CH_TrustID = SQLHelper.GetNewID(typeof(Model.HJGL_CH_Trust));
|
|
// t.CH_TrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId", "dbo.HJGL_CH_Trust", "CH_TrustCode", trust.ProjectId, ndt.NDT_Code + "-K-");
|
|
// t.ISO_ID = trust.ISO_ID;
|
|
// t.CH_NDTMethod = trust.CH_NDTMethod;
|
|
// t.CH_TrustType = "2"; //扩透
|
|
// t.CH_TrustDate = DateTime.Now.Date;
|
|
// t.ProjectId = trust.ProjectId;
|
|
// t.InstallationId = trust.InstallationId;
|
|
// BLL.HJGL_TrustManageEditService.AddCH_Trust(t);
|
|
|
|
// // 增加明细
|
|
// foreach (var q in batchDetails)
|
|
// {
|
|
// Model.HJGL_CH_TrustItem item = new Model.HJGL_CH_TrustItem();
|
|
// item.CH_TrustID = t.CH_TrustID;
|
|
// item.JOT_ID = q.JOT_ID;
|
|
// item.BatchDetailId = q.BatchDetailId;
|
|
// item.States = "1"; // 生成委托单时状态为等检测
|
|
// BLL.HJGL_TrustManageEditService.AddCH_TrustItem(item);
|
|
// }
|
|
//}
|
|
var trustItem = BLL.HJGL_CH_TrustItemService.GetTrustItemByID(CH_TrustItemID);
|
|
if (trustItem != null)
|
|
{
|
|
trustItem.ReportNoticeDate = DateTime.Now;
|
|
BLL.HJGL_CH_TrustItemService.UpdateTrustItem(trustItem);
|
|
}
|
|
Alert.ShowInTop("保存成功!", MessageBoxIcon.Warning);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(Request.Params["strList"])
|
|
+ ActiveWindow.GetHidePostBackReference());
|
|
//PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} |