289 lines
11 KiB
C#
289 lines
11 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.YLRQ.ConstructionManagement
|
|
{
|
|
public partial class ReworkTestingMethod : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BridProjectGrid();
|
|
BindGrid();
|
|
BindGrid1();
|
|
}
|
|
}
|
|
|
|
|
|
#region 绑定数据
|
|
|
|
/// <summary>
|
|
/// 绑定项目
|
|
/// </summary>
|
|
public void BridProjectGrid()
|
|
{
|
|
GridProject.DataSource = BLL.Base_ProjectService.GetYlrqProjectListByUserId(this.CurrUser.UserId, "2");
|
|
GridProject.DataBind();
|
|
drpProject.Value = this.CurrUser.LoginProjectId;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
public void BindGrid()
|
|
{
|
|
if (string.IsNullOrEmpty(drpProject.Value))
|
|
{
|
|
Grid1.DataSource = null;
|
|
Grid1.DataBind();
|
|
return;
|
|
}
|
|
|
|
string strSql = @"select a.RepairItemRecordId,a.QualityRatingId,a.WeldingId,c.WeldingCode,a.FilmNum,a.ProjectId,a.RepairMark,b.WME_ID,a.Confirmation,STUFF((SELECT ','+cl.NdtCode FROM PV_ReworkManagementMethod as cl where cl.RepairItemRecordId=a.RepairItemRecordId for xml path('')),1,1,'') as NDT_Codes,STUFF((SELECT ','+cl.NdtId FROM PV_ReworkManagementMethod as cl where cl.RepairItemRecordId=a.RepairItemRecordId for xml path('')),1,1,'') as NDT_Ids,a.ConfirmDate from PV_CH_RepairItemRecord as a left join HJGL_BS_WeldMethod as b on a.WmeId=b.WME_ID left join PV_WeldInformation as c on c.WeldingId=a.WeldingId where 1=1 and a.ProjectId=@ProjectId ";
|
|
//是否录入
|
|
if (rblIsEnter.SelectedValue == "1")
|
|
{
|
|
strSql += " and (select COUNT(1) from PV_ReworkManagementMethod as manage where manage.RepairItemRecordId=a.RepairItemRecordId)=0";
|
|
}
|
|
else
|
|
{
|
|
strSql += " and (select COUNT(1) from PV_ReworkManagementMethod as manage where manage.RepairItemRecordId=a.RepairItemRecordId)>0";
|
|
}
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", drpProject.Value));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
// 2.获取当前分页数据
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
//焊接方法
|
|
DropDownList ddlWMECode = Grid1.FindColumn("WME_ID").FindControl("ddlWMECode") as DropDownList;
|
|
ddlWMECode.DataTextField = "WME_Code";
|
|
ddlWMECode.DataValueField = "WME_ID";
|
|
ddlWMECode.DataSource = Funs.DB.HJGL_BS_WeldMethod;
|
|
ddlWMECode.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定Grid2
|
|
/// </summary>
|
|
public void BindGrid1()
|
|
{
|
|
var list = Funs.DB.PV_TestMethod;
|
|
// 2.获取当前分页数据
|
|
Grid2.RecordCount = list.Count();
|
|
var table = this.GetPagedDataTable(Grid2, list);
|
|
Grid2.DataSource = table;
|
|
Grid2.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定Grid3
|
|
/// </summary>
|
|
public void BindGrid2(string weldingId)
|
|
{
|
|
//获取当前焊缝信息
|
|
var ndtIds = Funs.DB.PV_ReworkManagementMethod.Where(p => p.RepairItemRecordId == weldingId).Select(p => p.NdtId);
|
|
if (ndtIds.Count() > 0)
|
|
{
|
|
var list = Funs.DB.PV_TestMethod.Where(p => ndtIds.Contains(p.Ndt_Id));
|
|
if (list.Count() > 0)
|
|
{
|
|
// 2.获取当前分页数据
|
|
Grid3.RecordCount = list.Count();
|
|
var table = this.GetPagedDataTable(Grid3, list);
|
|
Grid3.DataSource = table;
|
|
Grid3.DataBind();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 施工号下拉框
|
|
/// </summary>
|
|
protected void drpProject_TextChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出框执行
|
|
/// </summary>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否录入
|
|
/// </summary>
|
|
protected void rblIsEnter_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单元格操作
|
|
/// </summary>
|
|
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|
{
|
|
CheckBoxField Confirmation = Grid1.FindColumn("Confirmation") as CheckBoxField;
|
|
RenderField WME_ID = Grid1.FindColumn("WME_ID") as RenderField;
|
|
RenderField NDT_Ids = Grid1.FindColumn("NDT_Ids") as RenderField;
|
|
if (Confirmation.GetCheckedState(e.RowIndex))
|
|
{
|
|
e.CellCssClasses[WME_ID.ColumnIndex] = "f-grid-cell-uneditable";
|
|
e.CellCssClasses[NDT_Ids.ColumnIndex] = "f-grid-cell-uneditable";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击行事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID))
|
|
{
|
|
BindGrid2(this.Grid1.SelectedRowID);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页选择下拉改变事件
|
|
/// </summary>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 按钮操作
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PV_ReworkTestingMethod, Const.BtnSubmit))
|
|
{
|
|
Dictionary<int, Dictionary<string, object>> modifiedDict = Grid1.GetModifiedDict();
|
|
//获取所有的焊接方法
|
|
foreach (int rowIndex in modifiedDict.Keys)
|
|
{
|
|
List<PV_ReworkManagementMethod> mentMets = new List<PV_ReworkManagementMethod>();
|
|
var repairItemRecordId = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var weldingId = Grid1.DataKeys[rowIndex][1].ToString();
|
|
var repairItemModel = Funs.DB.PV_CH_RepairItemRecord.FirstOrDefault(p => p.RepairItemRecordId == repairItemRecordId);
|
|
if (repairItemModel == null) continue;
|
|
if (repairItemModel.Confirmation == 1)
|
|
{
|
|
BindGrid();
|
|
ShowNotify($"返修底片{repairItemModel.FilmNum}已确认委托,无法修改!");
|
|
return;
|
|
}
|
|
var testMethods = Funs.DB.PV_TestMethod;
|
|
|
|
//删除所有的焊缝方法
|
|
var deleteMangMet = Funs.DB.PV_ReworkManagementMethod.Where(p => p.RepairItemRecordId == repairItemModel.RepairItemRecordId).ToList();
|
|
Funs.DB.PV_ReworkManagementMethod.DeleteAllOnSubmit(deleteMangMet);
|
|
Funs.DB.SubmitChanges();
|
|
//检测方法
|
|
if (modifiedDict[rowIndex].ContainsKey("NDT_Ids"))
|
|
{
|
|
int i = 0;
|
|
foreach (var itemId in modifiedDict[rowIndex]["NDT_Ids"].ToString().Split(','))
|
|
{
|
|
var itemTestMethods = testMethods.FirstOrDefault(p => p.Ndt_Id == itemId);
|
|
mentMets.Add(new PV_ReworkManagementMethod()
|
|
{
|
|
ReworkId = Guid.NewGuid().ToString(),
|
|
NdtId = itemId,
|
|
NdtCode = itemTestMethods != null ? itemTestMethods.Ndt_NdtCode : string.Empty,
|
|
WeldingId = repairItemModel.WeldingId,
|
|
RepairItemRecordId = repairItemModel.RepairItemRecordId,
|
|
CreateId = CurrUser.UserId,
|
|
CreateTime = DateTime.Now
|
|
});
|
|
i++;
|
|
}
|
|
}
|
|
//焊接方法
|
|
if (modifiedDict[rowIndex].ContainsKey("WME_ID"))
|
|
{
|
|
repairItemModel.WmeId = modifiedDict[rowIndex]["WME_ID"].ToString();
|
|
}
|
|
Funs.DB.PV_ReworkManagementMethod.InsertAllOnSubmit(mentMets);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
BindGrid();
|
|
ShowNotify("操作成功!");
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 检测方法下拉框
|
|
/// </summary>
|
|
protected void ddlNDTCodes_TextChanged(object sender, EventArgs e)
|
|
{
|
|
var ndtIds = ddlNDTCodes.Values;
|
|
if (ndtIds.Length > 0)
|
|
{
|
|
var nowId = ndtIds.Last();
|
|
var pvNdts = Funs.DB.PV_TestMethod.Where(p => ndtIds.Contains(p.Ndt_Id)).ToList();
|
|
if (pvNdts.Count() > 0)
|
|
{
|
|
var nowNdt = pvNdts.FirstOrDefault(p => p.Ndt_Id == nowId);
|
|
if (pvNdts.Count(p => p.Ndt_NdtCode == nowNdt.Ndt_NdtCode) > 1)
|
|
{
|
|
var xtNdtIds = pvNdts.Where(p => p.Ndt_NdtCode == nowNdt.Ndt_NdtCode && p.Ndt_Id != nowId).Select(p => p.Ndt_Id);
|
|
pvNdts.RemoveAll(p => xtNdtIds.Contains(p.Ndt_Id));
|
|
ddlNDTCodes.Values = pvNdts.ConvertAll(p => p.Ndt_Id).ToArray();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |