ChengDa_English/SGGL/FineUIPro.Web/HJGL/RepairManage/RepairManageEdit.aspx.cs

1129 lines
54 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.RepairManage
{
public partial class RepairManageEdit : PageBase
{
#region
/// <summary>
/// 委托主键
/// </summary>
public string CH_TrustID
{
get
{
return (string)ViewState["CH_TrustID"];
}
set
{
ViewState["CH_TrustID"] = value;
}
}
/// <summary>
/// 查询视图集合
/// </summary>
private static List<Model.View_CH_TrustItem> trustItems = new List<Model.View_CH_TrustItem>();
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//施工单位、装置
//if (BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId) == null || BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId).UnitTypeId == BLL.Const.ProjectUnitType_1 || BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId).UnitTypeId == BLL.Const.ProjectUnitType_5)
//{
// BLL.UnitService.InitUnitNameByUnitTypeDropDownList(this.drpCH_TrustUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
// BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, true);
//}
//else
//{
// BLL.UnitService.InitSubUnitNameDownList(this.drpCH_TrustUnit, this.CurrUser.LoginProjectId, this.CurrUser.UnitId, true);
// BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.CurrUser.UnitId, true);
//}
var pUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2);
if (pUnit != null)
{
this.drpCH_TrustUnit.DataTextField = "UnitName";
this.drpCH_TrustUnit.DataValueField = "UnitId";
this.drpCH_TrustUnit.DataSource = pUnit;
this.drpCH_TrustUnit.DataBind();
this.drpCH_TrustUnit.SelectedValue = this.CurrUser.UnitId;
if(CurrUser.UnitId!=Const.UnitId_CD && CurrUser.UserId != Const.hfnbdId)
{
this.drpCH_TrustUnit.Enabled = false;
}
BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true);
this.drpInstallationId.SelectedIndex = 0;
}
BLL.Base_DetectionRateService.InitDetectionRateDropDownList(this.drpCH_NDTRate, true);//探伤比例
BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(this.drpCH_NDTMethod, true);//检测方法
BLL.UserService.InitUserDropDownList(this.drpCH_TrustMan, this.CurrUser.LoginProjectId, true);//委托人
//合格等级
this.drpCH_AcceptGrade.DataTextField = "Text";
this.drpCH_AcceptGrade.DataValueField = "Value";
this.drpCH_AcceptGrade.DataSource = BLL.DropListService.HJGL_GetAcceptGradeList();
this.drpCH_AcceptGrade.DataBind();
Funs.FineUIPleaseSelect(this.drpCH_AcceptGrade);
BLL.UserService.InitUserDropDownList(this.drpCH_Tabler, this.CurrUser.LoginProjectId, true);//制单人
BLL.Base_GrooveTypeService.InitGrooveTypeDropDownList(this.drpCH_SlopeType, true);//坡口类型
BLL.Base_WeldingMethodService.InitWeldingMethodDropDownList(this.drpCH_WeldMethod, true);//焊接方法
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpCH_CheckUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_5, true);//检测单位
this.txtReportDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
this.txtCH_TrustDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.drpCH_TrustMan.SelectedValue = this.CurrUser.UserId;
this.drpCH_Tabler.SelectedValue = this.CurrUser.UserId;
this.txtCH_NDTCriteria.Text = "NB/T47013-2015";
this.txtCH_RequestDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.InitTreeMenu();
}
}
#endregion
#region --
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
if (!string.IsNullOrEmpty(this.txtReportDate.Text.Trim()))
{
DateTime? startTime = Funs.GetNewDateTime(this.txtReportDate.Text.Trim());
DateTime? endTime = startTime.HasValue ? startTime.Value.AddMonths(1) : System.DateTime.Now;
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "单位-装置-月份";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.Base_Unit> units = null;
var unit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
if (unit == null || unit.UnitType == BLL.Const.ProjectUnitType_1 || unit.UnitType == BLL.Const.ProjectUnitType_3)
{
if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId))
{
units = (from x in Funs.DB.Base_Unit
join y in Funs.DB.ProjectData_WorkArea on x.UnitId equals y.UnitId
where (x.UnitId == this.CurrUser.UnitId || y.SupervisorUnitId == this.CurrUser.UnitId) && y.ProjectId == this.CurrUser.LoginProjectId
select x).Distinct().ToList();
}
else
{
units = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, "2");
}
}
else
{
units = (from x in Funs.DB.Base_Unit where x.UnitId == this.CurrUser.UnitId select x).ToList();
}
List<Model.CH_Trust> trustLists = new List<Model.CH_Trust>(); ///委托单
if (!this.txtReportDate.Hidden)
{
trustLists = (from x in Funs.DB.CH_Trust
where x.CH_TrustType == "2" && x.ProjectId == this.CurrUser.LoginProjectId && x.CH_TrustDate >= startTime && x.CH_TrustDate < endTime
select x).ToList();
}
else
{
trustLists = (from x in Funs.DB.CH_Trust
where x.CH_TrustType == "2" && x.ProjectId == this.CurrUser.LoginProjectId && x.CH_TrustCode.Contains(this.txtSearchCode.Text.Trim())
select x).ToList();
}
if (units != null)
{
foreach (var item in units)
{
TreeNode rootUnitNode = new TreeNode();//定义根节点
rootUnitNode.Text = item.UnitName;
rootUnitNode.NodeID = item.UnitId;
rootUnitNode.Expanded = true;
rootUnitNode.ToolTip = "施工单位";
rootNode.Nodes.Add(rootUnitNode);
var checkList = trustLists.Where(x => x.CH_TrustUnit == item.UnitId).ToList();
this.BindNodes(rootUnitNode, checkList);
}
}
else
{
Alert.ShowInTop("请先增加施工单位!", MessageBoxIcon.Warning);
return;
}
}
else
{
Alert.ShowInTop("请选择委托月份!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.CH_Trust> trustLists)
{
if (node.ToolTip == "施工单位")
{
var installId = (from x in trustLists select x.InstallationId).Distinct();
if (installId.Count() > 0)
{
var install = from x in Funs.DB.Project_Installation where installId.Contains(x.InstallationId) orderby x.InstallationCode select x;
foreach (var q in install)
{
TreeNode newNode = new TreeNode();
newNode.Text = q.InstallationName;
newNode.NodeID = q.InstallationId + "|" + node.NodeID; ;
newNode.ToolTip = "装置";
newNode.Expanded = true;
node.Nodes.Add(newNode);
this.BindNodes(newNode, trustLists);
}
}
}
else if (node.ToolTip == "装置")
{
string installationId = Funs.GetStrListByStr(node.NodeID, '|')[0];
var pointListMonth = (from x in trustLists
where x.InstallationId == installationId && x.CH_TrustUnit == node.ParentNode.NodeID
select string.Format("{0:yyyy-MM}", x.CH_TrustDate)).Distinct();
foreach (var item in pointListMonth)
{
TreeNode newNode = new TreeNode();
newNode.Text = item;
newNode.NodeID = item + "|" + node.NodeID; ;
newNode.ToolTip = "月份";
node.Nodes.Add(newNode);
this.BindNodes(newNode, trustLists);
}
}
else if (node.ToolTip == "月份")
{
string installationId = Funs.GetStrListByStr(node.ParentNode.NodeID, '|')[0];
var days = (from x in trustLists
where x.InstallationId == installationId && x.CH_TrustUnit == node.ParentNode.ParentNode.NodeID
orderby x.CH_TrustDate descending
select x.CH_TrustDate).Distinct();
foreach (var item in days)
{
TreeNode newNode = new TreeNode();
newNode.Text = string.Format("{0:yyyy-MM-dd}", item);
newNode.NodeID = item.ToString() + "|" + node.NodeID; ;
newNode.ToolTip = "日期";
node.Nodes.Add(newNode);
this.BindNodes(newNode, trustLists);
}
}
else if (node.ToolTip == "日期")
{
string installationId = Funs.GetStrListByStr(node.ParentNode.ParentNode.NodeID, '|')[0];
var dReports = from x in trustLists
where x.InstallationId == installationId && x.CH_TrustUnit == node.ParentNode.ParentNode.ParentNode.NodeID
&& x.CH_TrustDate == Funs.GetNewDateTime(node.Text)
orderby x.CH_TrustCode descending
select x;
foreach (var item in dReports)
{
TreeNode newNode = new TreeNode();
if (!string.IsNullOrEmpty(item.CH_TrustCode))
{
newNode.Text = item.CH_TrustCode;
}
else
{
newNode.Text = "未知";
}
if (!item.CH_AuditDate.HasValue || string.IsNullOrEmpty(item.CH_AuditMan))
{
newNode.Text = "<font color='#FF7575'>" + newNode.Text + "</font>";
node.Text = "<font color='#FF7575'>" + node.Text + "</font>";
node.ParentNode.Text = "<font color='#FF7575'>" + node.ParentNode.Text + "</font>";
}
newNode.NodeID = item.CH_TrustID;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
#endregion
#region Tree
/// <summary>
/// 按日期、单号查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ckFind_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ckFind.SelectedValue == "0")
{
this.txtReportDate.Hidden = false;
this.txtSearchCode.Hidden = true;
if (string.IsNullOrEmpty(this.txtReportDate.Text))
{
this.txtReportDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
}
}
else
{
this.txtReportDate.Hidden = true;
this.txtSearchCode.Hidden = false;
}
this.InitTreeMenu();
}
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#endregion
#region
/// <summary>
/// 点击树节点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
trustItems = new List<Model.View_CH_TrustItem>();
this.CH_TrustID = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(this.CH_TrustID))
{
Model.CH_Trust trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID);
if (trust != null)
{
this.txtCH_TrustCode.Text = trust.CH_TrustCode;
if (!string.IsNullOrEmpty(trust.CH_TrustUnit))
{
this.drpCH_TrustUnit.SelectedValue = trust.CH_TrustUnit;
}
if (!string.IsNullOrEmpty(trust.InstallationId))
{
BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true);
this.drpInstallationId.SelectedValue = trust.InstallationId;
}
this.txtCH_TrustDate.Text = trust.CH_TrustDate.HasValue ? string.Format("{0:yyyy-MM-dd}", trust.CH_TrustDate) : "";
this.txtCH_Press.Text = trust.CH_Press;
if (!string.IsNullOrEmpty(trust.CH_NDTRate))
{
this.drpCH_NDTRate.SelectedValue = trust.CH_NDTRate;
}
this.txtCH_WorkNo.Text = trust.CH_WorkNo;
if (!string.IsNullOrEmpty(trust.CH_NDTMethod))
{
this.drpCH_NDTMethod.SelectedValue = trust.CH_NDTMethod;
}
if (!string.IsNullOrEmpty(trust.CH_TrustMan))
{
this.drpCH_TrustMan.SelectedValue = trust.CH_TrustMan;
}
this.txtCH_ItemName.Text = trust.CH_ItemName;
if (!string.IsNullOrEmpty(trust.CH_AcceptGrade))
{
this.drpCH_AcceptGrade.SelectedValue = trust.CH_AcceptGrade;
}
if (!string.IsNullOrEmpty(trust.CH_Tabler))
{
this.drpCH_Tabler.SelectedValue = trust.CH_Tabler;
}
if (!string.IsNullOrEmpty(trust.CH_SlopeType))
{
this.drpCH_SlopeType.SelectedValue = trust.CH_SlopeType;
}
this.txtCH_NDTCriteria.Text = trust.CH_NDTCriteria;
if (!string.IsNullOrEmpty(trust.CH_WeldMethod))
{
this.drpCH_WeldMethod.SelectedValue = trust.CH_WeldMethod;
}
this.txtCH_ServiceTemp.Text = trust.CH_ServiceTemp;
if (!string.IsNullOrEmpty(trust.CH_CheckUnit))
{
this.drpCH_CheckUnit.SelectedValue = trust.CH_CheckUnit;
}
this.txtCH_RequestDate.Text = trust.CH_RequestDate.HasValue ? string.Format("{0:yyyy-MM-dd}", trust.CH_RequestDate) : "";
this.txtRemark.Text = trust.CH_Remark;
trustItems = BLL.TrustManageEditService.GetTrustItemViewByTrustId(this.CH_TrustID);
if (trustItems.Count > 0)
{
this.Grid1.DataSource = trustItems;
this.Grid1.DataBind();
}
}
}
else
{
this.CH_TrustID = string.Empty;
}
}
#endregion
#region
/// <summary>
/// 增加按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAdd_Click(object sender, EventArgs e)
{
if (this.GetButtonPower(BLL.Const.BtnAdd))
{
this.CH_TrustID = string.Empty;
this.txtCH_TrustCode.Text = string.Empty;
//this.drpCH_TrustUnit.SelectedIndex = 0;
this.drpInstallationId.SelectedIndex = 0;
this.txtCH_TrustDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.txtCH_Press.Text = string.Empty;
this.drpCH_NDTRate.SelectedIndex = 0;
this.txtCH_WorkNo.Text = string.Empty;
this.drpCH_NDTMethod.SelectedIndex = 0;
this.drpCH_TrustMan.SelectedValue = this.CurrUser.UserId;
this.txtCH_ItemName.Text = string.Empty;
this.drpCH_AcceptGrade.SelectedIndex = 0;
this.drpCH_Tabler.SelectedValue = this.CurrUser.UserId;
this.drpCH_SlopeType.SelectedIndex = 0;
this.txtCH_NDTCriteria.Text = "NB/T47013-2015";
this.drpCH_WeldMethod.SelectedIndex = 0;
this.txtCH_ServiceTemp.Text = string.Empty;
this.drpCH_CheckUnit.SelectedIndex = 0;
this.txtCH_RequestDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.txtRemark.Text = string.Empty;
trustItems.Clear();
trustItems = new List<Model.View_CH_TrustItem>();
this.Grid1.DataSource = trustItems;
this.Grid1.DataBind();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region 线
/// <summary>
/// 查找按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, EventArgs e)
{
if (GetButtonPower(BLL.Const.BtnSave))
{
if (this.drpCH_TrustUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue))
{
Alert.ShowInTop("请选择委托单位!", MessageBoxIcon.Warning);
return;
}
else if (this.drpInstallationId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallationId.SelectedValue))
{
Alert.ShowInTop("请选择装置名称!", MessageBoxIcon.Warning);
return;
}
else
{
string window = String.Format("ShowRepairSearch.aspx?unitId={0}&&installationId={1}&&ch_TrustID={2}", this.drpCH_TrustUnit.SelectedValue, this.drpInstallationId.SelectedValue, this.CH_TrustID, "编辑 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdJOTID.ClientID)
+ Window1.GetShowReference(window));
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 删除按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click(object sender, EventArgs e)
{
if (this.GetButtonPower(BLL.Const.BtnDelete))
{
this.CH_TrustID = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(this.CH_TrustID))
{
var trust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID);
if (trust != null && !trust.CH_AuditDate.HasValue)
{
BLL.TrustManageEditService.DeleteCH_TrustItemByCH_TrustID(CH_TrustID);
BLL.TrustManageEditService.DeleteCH_TrustByCH_TrustID(CH_TrustID);
if (trustItems.Count > 0)
{
foreach (var j in trustItems)
{
BLL.TrustManageEditService.UpdateJOT_TrustFlag(j.JOT_ID, "2");
var ndttype = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod);
if (ndttype.DetectionTypeCode == "RT")
{
BLL.CheckManageService.UpdateCheckIsRepair(j.JOT_ID, CH_TrustID, false, "1");
}
else
{
BLL.CheckManageService.UpdateCheckIsRepair(j.JOT_ID, CH_TrustID, false, "2");
}
}
}
trustItems.Clear();
this.CH_TrustID = null;
this.Grid1.DataSource = null;
this.Grid1.DataBind();
ShowNotify("删除成功!", MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop("此委托单已审核不能删除", MessageBoxIcon.Warning);
return;
}
}
else
{
Alert.ShowInTop("请选择要删除的委托单!", MessageBoxIcon.Warning);
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.GetButtonPower(BLL.Const.BtnSave))
{
if (trustItems.Count <= 0)
{
Alert.ShowInTop("委托单信息不能为空!", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtCH_TrustCode.Text))
{
Alert.ShowInTop("请选择委托单号!", MessageBoxIcon.Warning);
return;
}
if (this.drpCH_NDTRate.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_NDTRate.SelectedValue))
{
Alert.ShowInTop("请选择探伤比例!", MessageBoxIcon.Warning);
return;
}
if (this.drpCH_NDTMethod.SelectedValue == BLL.Const._Null ||string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue))
{
Alert.ShowInTop("请选择检测方法!", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtCH_TrustCode.Text))
{
Alert.ShowInTop("请输入委托单号!", MessageBoxIcon.Warning);
return;
}
if (this.drpCH_CheckUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpCH_CheckUnit.SelectedValue))
{
Alert.ShowInTop("请选择检测单位!", MessageBoxIcon.Warning);
return;
}
string isoId = null;
//7表示无损委托单对应管线True表示只对应一条管线
var sysSet = BLL.Project_SysSetService.GetSysSetBySetId("7", this.CurrUser.LoginProjectId);
if (sysSet != null)
{
var isoNum = (from x in trustItems select x.ISO_IsoNo).Distinct();
if (isoNum.Count() > 1)
{
Alert.ShowInTop("一个委托单只对应一条管线!");
return;
}
else
{
isoId = BLL.PW_JointInfoService.GetJointInfoByJotID(trustItems.FirstOrDefault().JOT_ID).ISO_ID;
}
}
Model.CH_Trust trust = new Model.CH_Trust();
trust.ProjectId = this.CurrUser.LoginProjectId;
trust.CH_TrustCode = this.txtCH_TrustCode.Text.Trim();
if (this.drpCH_TrustUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue))
{
trust.CH_TrustUnit = this.drpCH_TrustUnit.SelectedValue;
}
if (this.drpInstallationId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpInstallationId.SelectedValue))
{
trust.InstallationId = this.drpInstallationId.SelectedValue;
}
trust.CH_TrustDate = Funs.GetNewDateTime(this.txtCH_TrustDate.Text.Trim());
trust.CH_Press = this.txtCH_Press.Text.Trim();
if (this.drpCH_NDTRate.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_NDTRate.SelectedValue))
{
trust.CH_NDTRate = this.drpCH_NDTRate.SelectedValue;
}
trust.CH_WorkNo = this.txtCH_WorkNo.Text.Trim();
if (this.drpCH_NDTMethod.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue))
{
trust.CH_NDTMethod = this.drpCH_NDTMethod.SelectedValue;
}
if (this.drpCH_TrustMan.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_TrustMan.SelectedValue))
{
trust.CH_TrustMan = this.drpCH_TrustMan.SelectedValue;
}
trust.CH_ItemName = this.txtCH_ItemName.Text.Trim();
if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_AcceptGrade.SelectedValue))
{
trust.CH_AcceptGrade = this.drpCH_AcceptGrade.SelectedValue;
}
if (this.drpCH_Tabler.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_Tabler.SelectedValue))
{
trust.CH_Tabler = this.drpCH_Tabler.SelectedValue;
}
if (this.drpCH_SlopeType.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_SlopeType.SelectedValue))
{
trust.CH_SlopeType = this.drpCH_SlopeType.SelectedValue;
}
trust.CH_NDTCriteria = this.txtCH_NDTCriteria.Text.Trim();
if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_WeldMethod.SelectedValue))
{
trust.CH_WeldMethod = this.drpCH_WeldMethod.SelectedValue;
}
trust.CH_ServiceTemp = this.txtCH_ServiceTemp.Text.Trim();
if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_CheckUnit.SelectedValue))
{
trust.CH_CheckUnit = this.drpCH_CheckUnit.SelectedValue;
}
trust.CH_RequestDate = Funs.GetNewDateTime(this.txtCH_RequestDate.Text);
trust.CH_Remark = this.txtRemark.Text.Trim();
trust.CH_TrustType = "2";
trust.ToIso_Id = isoId;
var updatetrust = BLL.TrustManageEditService.GetCH_TrustByID(CH_TrustID);
if (updatetrust != null && updatetrust.CH_AuditDate.HasValue)
{
Alert.ShowInTop("此条委托单已审核不能修改!", MessageBoxIcon.Warning);
return;
}
if (updatetrust != null && !string.IsNullOrEmpty(CH_TrustID))
{
trust.CH_TrustID = CH_TrustID;
BLL.TrustManageEditService.UpdateCH_Trust(trust);
BLL.TrustManageEditService.DeleteCH_TrustItemByCH_TrustID(CH_TrustID);
//BLL.LogService.AddLog(this.CurrUser.UserId, "修改委托单信息");
if (trustItems.Count > 0)
{
foreach (var j in trustItems)
{
BLL.TrustManageEditService.UpdateJOT_TrustFlag(j.JOT_ID, "2");
}
}
}
else
{
trust.CH_TrustID = SQLHelper.GetNewID(typeof(Model.CH_Trust));
this.CH_TrustID = trust.CH_TrustID;
BLL.TrustManageEditService.AddCH_Trust(trust);
//BLL.LogService.AddLog(this.CurrUser.UserId, "添加委托单信息");
}
foreach (var item in trustItems)
{
Model.CH_TrustItem newitem = new Model.CH_TrustItem();
newitem.CH_TrustID = this.CH_TrustID;
newitem.JOT_ID = item.JOT_ID;
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>("JOT_ID").ToString();
if (rowID == item.JOT_ID)
{
item.CH_Remark = values.Value<string>("CH_Remark");
newitem.CH_Remark = item.CH_Remark;
}
}
BLL.TrustManageEditService.AddCH_TrustItem(newitem);
//更新焊口委托情况
BLL.TrustManageEditService.UpdateJOT_TrustFlag(item.JOT_ID, "1");
////更新焊口 是否扩透 切除口
var jotitem = BLL.PW_JointInfoService.GetJointInfoByJotID(item.JOT_ID);
for (int i = 0; i < Grid1.Rows.Count; i++)
{
string id = Grid1.Rows[i].RowID;
if (item.JOT_ID == id)
{
CheckBoxField jointStatus = (CheckBoxField)Grid1.FindColumn("JOT_JointStatus");
bool s = jointStatus.GetCheckedState(i);
if (s)
{
jotitem.JOT_JointStatus = "104";
}
else
{
jotitem.JOT_JointStatus = "101";
}
}
else
{
jotitem.JOT_JointStatus = "102";
}
}
//更新焊口加R
BLL.PW_JointInfoService.UpdateJointPoint(jotitem);
//BLL.RepairService.UpdateNewJointNo(item.JOT_ID, "R");
var ndttype = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(trust.CH_NDTMethod);
if (ndttype.DetectionTypeCode == "RT")
{
BLL.CheckManageService.UpdateCheckIsRepair(item.JOT_ID, this.CH_TrustID, true, "1");
}
else
{
BLL.CheckManageService.UpdateCheckIsRepair(item.JOT_ID, this.CH_TrustID, true, "2");
}
}
trustItems.Clear();
ShowNotify("保存成功!", MessageBoxIcon.Success);
InitTreeMenu();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 关闭弹出窗体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
trustItems = new List<Model.View_CH_TrustItem>();
List<string> infos = Funs.GetStrListByStr(hdJOTID.Text, ',');
if (string.IsNullOrEmpty(CH_TrustID ))
{
foreach (var item in infos)
{
var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(item, this.CurrUser.LoginProjectId);
if (info != null)
{
trustItems.Add(info);
}
}
}
else
{
foreach (var jotid in infos)
{
var item = BLL.TrustManageEditService.GetCH_TrustItemByJOT_ID(jotid);
if (item.Where(y => y.JOT_ID == jotid).Count() == 0)
{
var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(jotid, this.CurrUser.LoginProjectId);
if (info != null)
{
trustItems.Add(info);
}
}
}
}
if (trustItems.Count > 0)
{
this.Grid1.DataSource = trustItems;
this.Grid1.DataBind();
var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == trustItems[0].JOT_ID);
var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_IsoNo == trustItems[0].ISO_IsoNo);
var trustUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_TrustUnit.SelectedValue);
if (!iso.Is_Standard)
{
this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId;
this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId;
this.drpCH_SlopeType.SelectedValue = join.JST_ID;
this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId);
var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
if (trustUnit != null && workArea != null && NDTMethod != null)
{
string code = "CD-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + NDTMethod.DetectionTypeCode + "-";
this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K";
}
}
else
{
this.drpCH_NDTRate.SelectedValue = join.DetectionRateId;
this.drpCH_NDTMethod.SelectedValue = join.DetectionTypeId;
this.drpCH_SlopeType.SelectedValue = join.JST_ID;
this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId);
var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
if (trustUnit != null && workArea != null && NDTMethod != null)
{
string code = trustUnit.UnitCode + "-" + iso.ISO_IsoNo + "-" + NDTMethod.DetectionTypeCode + "-";
this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K";
}
}
}
}
#endregion
#region
/// <summary>
/// 右键删除焊口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (this.GetButtonPower(BLL.Const.BtnDelete))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID);
if (trust != null && trust.CH_AuditDate.HasValue)
{
Alert.ShowInTop("此委托单已审核不能删除!", MessageBoxIcon.Warning);
return;
}
else
{
var item = trustItems.FirstOrDefault(x => x.JOT_ID == rowID);
if (item != null)
{
BLL.TrustManageEditService.UpdateJOT_TrustFlag(rowID, "2");
trustItems.RemoveAt(rowIndex);
}
}
}
Grid1.DataSource = trustItems;
Grid1.DataBind();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region DropDownList下拉选择事件
/// <summary>
/// 合格等级下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpCH_AcceptGrade_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_AcceptGrade.SelectedValue))
{
txtCH_NDTCriteria.Text = "NB/T47013-2015" + "(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
}
else
{
txtCH_NDTCriteria.Text = "NB/T47013-2015";
}
}
/// <summary>
/// 委托单位下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpCH_TrustUnit_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpInstallationId.Items.Clear();
if (!string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue) && this.drpCH_TrustUnit.SelectedValue != BLL.Const._Null)
{
//if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId))
//{
// BLL.Project_InstallationService.InitInstallationBySupervisorUnitIdListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, this.CurrUser.UnitId, true);
// this.drpInstallationId.SelectedIndex = 0;
//}
//else
//{
// BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true);
// this.drpInstallationId.SelectedIndex = 0;
//}
BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpCH_TrustUnit.SelectedValue, true);
this.drpInstallationId.SelectedIndex = 0;
//加载委托单号
string prefixCode = string.Empty;
var epcUnitCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_CD);
// var trustUnitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpCH_TrustUnit.SelectedValue);
// prefixCode = "RK-" + epcUnitCode + "-" + trustUnitCode + "-";
//this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, prefixCode);
needChangeCode(sender,e);
}
else
{
Funs.FineUIPleaseSelect(this.drpInstallationId);
}
}
/// <summary>
/// 装置下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpInstallationId_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.drpInstallationId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpInstallationId.SelectedValue))
{
//string prefixCode = string.Empty;
//string areaCode = string.Empty;
//var workarea = BLL.WorkAreaService.GetWorkAreaByProjectIdAndInstalltionIdAndUnitId(this.CurrUser.LoginProjectId, this.drpInstallationId.SelectedValue, this.drpCH_TrustUnit.SelectedValue);
//if (workarea != null)
//{
// areaCode = workarea.WorkAreaCode;
//}
//var epcUnitCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_CD);
//var trustUnitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpCH_TrustUnit.SelectedValue);
//prefixCode = "RK-" + epcUnitCode + "-" + trustUnitCode + "-" + areaCode + "-";
//this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, prefixCode);
}
}
/// <summary>
/// 检测方法下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpCH_NDTMethod_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.drpCH_NDTMethod.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue))
{
//string prefixCode = string.Empty;
//string areaCode = string.Empty;
//string unitCode = string.Empty;
//string ndttCode = string.Empty;
//var workarea = BLL.WorkAreaService.GetWorkAreaByProjectIdAndInstalltionIdAndUnitId(this.CurrUser.LoginProjectId, this.drpInstallationId.SelectedValue, this.drpCH_TrustUnit.SelectedValue);
//if (workarea != null)
//{
// areaCode = workarea.WorkAreaCode;
//}
//var epcUnitCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_CD);
//var trustUnitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpCH_TrustUnit.SelectedValue);
//var ndtt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(this.drpCH_NDTMethod.SelectedValue);
//if (ndtt != null)
//{
// ndttCode = ndtt.DetectionTypeCode;
//}
// prefixCode = "RK-" + epcUnitCode + "-" + trustUnitCode + "-" + areaCode + "-" + ndttCode + "-";
// this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, prefixCode);
}
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private bool GetButtonPower(string button)
{
return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_RepairManageMenuId, button);
}
#endregion
#region Grid行绑定事件
/// <summary>
/// Grid行绑定事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
foreach (var item in trustItems)
{
if (item.JOT_JointStatus == "100" || item.JOT_JointStatus == "102")
{
if (item.JOT_ID == e.RowID)
{
CheckBoxField s = Grid1.FindColumn("JOT_JointStatus") as CheckBoxField;
e.CellCssClasses[s.ColumnIndex] = "hidethis";
}
}
}
}
#endregion
#region
/// <summary>
/// 打印按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
if (this.tvControlItem.SelectedNode == null || string.IsNullOrEmpty(this.tvControlItem.SelectedNode.NodeID))
{
Alert.ShowInParent("请选择要打印单据!", MessageBoxIcon.Warning);
return;
}
string reportId = this.tvControlItem.SelectedNode.NodeID;
var q = BLL.TrustManageEditService.GetCH_TrustByID(reportId);
if (q != null)
{
string varValue = string.Empty;
//var projectName = BLL.ProjectService.GetProjectNameByProjectId(this.CurrUser.LoginProjectId);
//var installationName = BLL.Project_InstallationService.GetInstallationByInstallationId(q.InstallationId).InstallationName;
//var unitName = BLL.UnitService.GetUnitNameByUnitId(q.UnitId);
//varValue = installationName + "|" + unitName + "|" + projectName + "|" + q.PW_PointDate.Value.ToString("yyyy-MM-dd") + "|" + q.PW_PointNo;
if (!string.IsNullOrEmpty(varValue))
{
varValue = Microsoft.JScript.GlobalObject.escape(varValue.Replace("/", ","));
}
if (BLL.Project_SysSetService.IsAuto("3", this.CurrUser.LoginProjectId) == true) //3表示无损委托
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReportId, reportId, varValue, this.CurrUser.LoginProjectId)));
}
else if (BLL.Project_SysSetService.IsAuto("3", this.CurrUser.LoginProjectId) == false)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReport2Id, reportId, varValue, this.CurrUser.LoginProjectId)));
}
else if (BLL.Project_SysSetService.IsAuto("3", this.CurrUser.LoginProjectId) == null)
{
var p = BLL.Project_SysSetService.GetSysSetBySetId("3", this.CurrUser.LoginProjectId);
if (p.SetValue == "3")
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReport3Id, reportId, varValue, this.CurrUser.LoginProjectId)));
}
else // 4表示为神化委托单
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.TrustReport4Id, reportId, varValue, this.CurrUser.LoginProjectId)));
}
}
}
else
{
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
return;
}
}
#endregion
protected void needChangeCode(object sender, EventArgs e)
{
var trust = BLL.TrustManageEditService.GetCH_TrustByID(this.CH_TrustID);
if (trust == null)
{
trustItems = new List<Model.View_CH_TrustItem>();
List<string> infos = Funs.GetStrListByStr(hdJOTID.Text, ',');
if (string.IsNullOrEmpty(CH_TrustID))
{
foreach (var item in infos)
{
var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(item, this.CurrUser.LoginProjectId);
if (info != null)
{
trustItems.Add(info);
}
}
}
else
{
foreach (var jotid in infos)
{
var item = BLL.TrustManageEditService.GetCH_TrustItemByJOT_ID(jotid);
if (item.Where(y => y.JOT_ID == jotid).Count() == 0)
{
var info = BLL.TrustManageEditService.GetView_CH_TrustItemByJotID(jotid, this.CurrUser.LoginProjectId);
if (info != null)
{
trustItems.Add(info);
}
}
}
}
if (trustItems.Count > 0)
{
var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == trustItems[0].JOT_ID);
var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_IsoNo == trustItems[0].ISO_IsoNo);
var trustUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_TrustUnit.SelectedValue);
if (!iso.Is_Standard)
{
//this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId;
//this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId;
//this.drpCH_SlopeType.SelectedValue = join.JST_ID;
//this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId);
var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
if (trustUnit != null && workArea != null && NDTMethod != null)
{
string code = "CD-" + trustUnit.UnitCode + "-" + workArea.WorkAreaCode + "-" + NDTMethod.DetectionTypeCode + "-";
this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K";
}
}
else
{
//this.drpCH_NDTRate.SelectedValue = iso.DetectionRateId;
//this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId;
//this.drpCH_SlopeType.SelectedValue = join.JST_ID;
//this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.WorkAreaId == iso.WorkAreaId);
var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
if (trustUnit != null && workArea != null && NDTMethod != null)
{
string code = trustUnit.UnitCode + "-" + iso.ISO_IsoNo + "-" + NDTMethod.DetectionTypeCode + "-";
this.txtCH_TrustCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.CH_Trust", "CH_TrustCode", this.CurrUser.LoginProjectId, code) + "K";
}
}
}
}
}
}
}