ChengDa_English/SGGL/FineUIPro.Web/HJGL/TestPackageManage/TestPackageManageEdit.aspx.cs

775 lines
35 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.TestPackageManage
{
public partial class TestPackageManageEdit : PageBase
{
#region
/// <summary>
/// 试压包主键
/// </summary>
public string PTP_ID
{
get
{
return (string)ViewState["PTP_ID"];
}
set
{
ViewState["PTP_ID"] = value;
}
}
/// <summary>
/// 管线集合
/// </summary>
private static List<Model.PW_IsoInfo> isoInfos = new List<Model.PW_IsoInfo>();
#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.InitUnitNameByUnitTypeDropDownList(this.drpUnitId, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
// BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, true);
//}
//else
//{
// BLL.UnitService.InitSubUnitNameDownList(this.drpUnitId, 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.drpUnitId.DataTextField = "UnitName";
this.drpUnitId.DataValueField = "UnitId";
this.drpUnitId.DataSource = pUnit;
this.drpUnitId.DataBind();
this.drpUnitId.SelectedValue = this.CurrUser.UnitId;
if (CurrUser.UnitId != Const.UnitId_CD && CurrUser.UserId != Const.hfnbdId)
{
this.drpUnitId.Enabled = false;
}
BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnitId.SelectedValue, true);
this.drpInstallationId.SelectedIndex = 0;
}
BLL.UserService.InitUserDropDownList(this.drpPTP_Modifier, this.CurrUser.LoginProjectId, true);//修改人
BLL.Base_PressureService.InitPressureDropDownList(this.drpPTP_TestType, true);//试验类型
BLL.UserService.InitUserDropDownList(this.drpPTP_Tabler, this.CurrUser.LoginProjectId, true);//建档人
this.txtReportDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
this.txtPTP_TableDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.drpPTP_Tabler.SelectedValue = this.CurrUser.UserId;
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.GetProjectUnitById(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.TP_TestPackage> testPackageLists = new List<Model.TP_TestPackage>(); ///试压包
if (!this.txtReportDate.Hidden)
{
testPackageLists = (from x in Funs.DB.TP_TestPackage
where x.ProjectId == this.CurrUser.LoginProjectId && x.PTP_TableDate >= startTime && x.PTP_TableDate < endTime
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 lists = testPackageLists.Where(x => x.BSU_ID == item.UnitId).ToList();
this.BindNodes(rootUnitNode, lists);
}
}
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.TP_TestPackage> testPackageLists)
{
if (node.ToolTip == "施工单位")
{
var installId = (from x in testPackageLists 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.InstallationCode + q.InstallationName;
newNode.NodeID = q.InstallationId + "|" + node.NodeID; ;
newNode.ToolTip = "装置";
newNode.Expanded = true;
node.Nodes.Add(newNode);
this.BindNodes(newNode, testPackageLists);
}
}
}
else if (node.ToolTip == "装置")
{
string installationId = Funs.GetStrListByStr(node.NodeID, '|')[0];
var listMonth = (from x in testPackageLists
where x.InstallationId == installationId && x.BSU_ID == node.ParentNode.NodeID
select string.Format("{0:yyyy-MM}", x.PTP_TableDate)).Distinct();
foreach (var item in listMonth)
{
TreeNode newNode = new TreeNode();
newNode.Text = item;
newNode.NodeID = item + "|" + node.NodeID; ;
newNode.ToolTip = "月份";
node.Nodes.Add(newNode);
this.BindNodes(newNode, testPackageLists);
}
}
else if (node.ToolTip == "月份")
{
string installationId = Funs.GetStrListByStr(node.ParentNode.NodeID, '|')[0];
var days = (from x in testPackageLists
where x.InstallationId == installationId && x.BSU_ID == node.ParentNode.ParentNode.NodeID
orderby x.PTP_TableDate descending
select x.PTP_TableDate).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, testPackageLists);
}
}
else if (node.ToolTip == "日期")
{
string installationId = Funs.GetStrListByStr(node.ParentNode.ParentNode.NodeID, '|')[0];
var dReports = from x in testPackageLists
where x.InstallationId == installationId && x.BSU_ID == node.ParentNode.ParentNode.ParentNode.NodeID
&& x.PTP_TableDate == Funs.GetNewDateTime(node.Text)
orderby x.PTP_TestPackageNo descending
select x;
foreach (var item in dReports)
{
TreeNode newNode = new TreeNode();
if (!string.IsNullOrEmpty(item.PTP_TestPackageNo))
{
newNode.Text = item.PTP_TestPackageNo;
}
else
{
newNode.Text = "未知";
}
if (!item.PTP_AduditDate.HasValue || string.IsNullOrEmpty(item.PTP_Auditer))
{
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.PTP_ID;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
#endregion
#region Tree
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)
{
isoInfos = new List<Model.PW_IsoInfo>();
this.PTP_ID = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(this.PTP_ID))
{
var testPackage = BLL.TestPackageManageEditService.GetTP_TestPackageByID(PTP_ID);
if (testPackage != null)
{
if (!string.IsNullOrEmpty(testPackage.BSU_ID))
{
this.drpUnitId.SelectedValue = testPackage.BSU_ID;
}
if (!string.IsNullOrEmpty(testPackage.InstallationId))
{
this.drpInstallationId.SelectedValue = testPackage.InstallationId;
}
this.txtPTP_TightnessTestTime.Text = testPackage.PTP_TightnessTestTime;
this.txtPTP_TestPackageNo.Text = testPackage.PTP_TestPackageNo;
if (!string.IsNullOrEmpty(testPackage.PTP_Modifier))
{
this.drpPTP_Modifier.SelectedValue = testPackage.PTP_Modifier;
}
this.txtPTP_LeakageTestService.Text = testPackage.PTP_LeakageTestService;
this.txtPTP_TestPackageName.Text = testPackage.PTP_TestPackageName;
this.txtPTP_ModifyDate.Text = testPackage.PTP_ModifyDate.HasValue ? string.Format("{0:yyyy-MM-dd}", testPackage.PTP_ModifyDate) : "";
this.txtPTP_LeakageTestPressure.Text = testPackage.PTP_LeakageTestPressure;
this.txtPTP_TestHeat.Text = testPackage.PTP_TestHeat;
this.txtPTP_TestPackageCode.Text = testPackage.PTP_TestPackageCode;
this.txtPTP_TightnessTestTemp.Text = testPackage.PTP_TightnessTestTemp;
this.txtPTP_TestService.Text = testPackage.PTP_TestService;
this.txtPTP_TestAmbientTemp.Text = testPackage.PTP_TestAmbientTemp;
this.txtPTP_VacuumTestService.Text = testPackage.PTP_VacuumTestService;
if (!string.IsNullOrEmpty(testPackage.PTP_TestType))
{
this.drpPTP_TestType.SelectedValue = testPackage.PTP_TestType;
}
this.txtPTP_TestMediumTemp.Text = testPackage.PTP_TestMediumTemp;
this.txtPTP_VacuumTestPressure.Text = testPackage.PTP_VacuumTestPressure;
this.txtPTP_AllowSeepage.Text = testPackage.PTP_AllowSeepage;
this.txtPTP_TestPressure.Text = testPackage.PTP_TestPressure;
this.txtPTP_OperationMedium.Text = testPackage.PTP_OperationMedium;
this.txtPTP_FactSeepage.Text = testPackage.PTP_FactSeepage;
this.txtPTP_TestPressureTemp.Text = testPackage.PTP_TestPressureTemp;
this.txtPTP_PurgingMedium.Text = testPackage.PTP_PurgingMedium;
if (!string.IsNullOrEmpty(testPackage.PTP_Tabler))
{
this.drpPTP_Tabler.SelectedValue = testPackage.PTP_Tabler;
}
this.txtPTP_TestPressureTime.Text = testPackage.PTP_TestPressureTime;
this.txtPTP_CleaningMedium.Text = testPackage.PTP_CleaningMedium;
this.txtPTP_TableDate.Text = testPackage.PTP_TableDate.HasValue ? string.Format("{0:yyyy-MM-dd}", testPackage.PTP_TableDate) : "";
this.txtPTP_TightnessTest.Text = testPackage.PTP_TightnessTest;
this.txtPTP_Remark.Text = testPackage.PTP_Remark;
isoInfos = BLL.TestPackageManageEditService.GetIsoInfosByPTP_ID(PTP_ID);
if (isoInfos.Count > 0)
{
this.Grid1.DataSource = isoInfos;
this.Grid1.DataBind();
}
}
}
else
{
this.PTP_ID = 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))
{
TextEmpty();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
private void TextEmpty()
{
this.PTP_ID = string.Empty;
//this.drpUnitId.SelectedIndex = 0;
this.drpInstallationId.SelectedIndex = 0;
this.txtPTP_TightnessTestTime.Text = string.Empty;
this.txtPTP_TestPackageNo.Text = string.Empty;
this.drpPTP_Modifier.SelectedIndex = 0;
this.txtPTP_LeakageTestService.Text = string.Empty;
this.txtPTP_TestPackageName.Text = string.Empty;
this.txtPTP_ModifyDate.Text = string.Empty;
this.txtPTP_LeakageTestPressure.Text = string.Empty;
this.txtPTP_TestHeat.Text = string.Empty;
this.txtPTP_TestPackageCode.Text = string.Empty;
this.txtPTP_TightnessTestTemp.Text = string.Empty;
this.txtPTP_TestService.Text = string.Empty;
this.txtPTP_TestAmbientTemp.Text = string.Empty;
this.txtPTP_VacuumTestService.Text = string.Empty;
this.drpPTP_TestType.SelectedIndex = 0;
this.txtPTP_TestMediumTemp.Text = string.Empty;
this.txtPTP_VacuumTestPressure.Text = string.Empty;
this.txtPTP_AllowSeepage.Text = string.Empty;
this.txtPTP_TestPressure.Text = string.Empty;
this.txtPTP_OperationMedium.Text = string.Empty;
this.txtPTP_FactSeepage.Text = string.Empty;
this.txtPTP_TestPressureTemp.Text = string.Empty;
this.txtPTP_PurgingMedium.Text = string.Empty;
this.drpPTP_Tabler.SelectedValue = this.CurrUser.UserId;
this.txtPTP_TestPressureTime.Text = string.Empty;
this.txtPTP_CleaningMedium.Text = string.Empty;
this.txtPTP_TableDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.txtPTP_TightnessTest.Text = string.Empty;
this.txtPTP_Remark.Text = string.Empty;
isoInfos.Clear();
isoInfos = new List<Model.PW_IsoInfo>();
this.Grid1.DataSource = isoInfos;
this.Grid1.DataBind();
}
#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.drpUnitId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpUnitId.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("ShowTestPackageSearch.aspx?unitId={0}&&installationId={1}", this.drpUnitId.SelectedValue, this.drpInstallationId.SelectedValue, "编辑 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdIso_Id.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.PTP_ID = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(this.PTP_ID))
{
var test = BLL.TestPackageManageEditService.GetTP_TestPackageByID(PTP_ID);
if (test != null && !test.PTP_AduditDate.HasValue)
{
BLL.TestPackageManageEditService.DeleteTP_IsoListByPTP_ID(PTP_ID);
BLL.TestPackageManageEditService.DeleteTP_TestPackageByTP_TestPackageID(PTP_ID);
ShowNotify("删除成功!", MessageBoxIcon.Success);
TextEmpty();
InitTreeMenu();
}
else
{
Alert.ShowInTop("此试压单已审核不能删除!", MessageBoxIcon.Warning);
}
}
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))
{
foreach (var item in isoInfos)
{
if (item.ISO_IsoNo == null)
{
Alert.ShowInTop("管线号不能为空!", MessageBoxIcon.Warning);
return;
}
}
if (this.drpUnitId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpUnitId.SelectedValue))
{
Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
return;
}
if (this.drpInstallationId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallationId.SelectedValue))
{
Alert.ShowInTop("请选择装置名称!", MessageBoxIcon.Warning);
return;
}
if (this.drpPTP_Tabler.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpPTP_Tabler.SelectedValue))
{
Alert.ShowInTop("请选择建档人!", MessageBoxIcon.Warning);
return;
}
Model.TP_TestPackage testPackage = new Model.TP_TestPackage();
testPackage.ProjectId = this.CurrUser.LoginProjectId;
testPackage.BSU_ID = this.drpUnitId.SelectedValue;
testPackage.InstallationId = this.drpInstallationId.SelectedValue;
testPackage.PTP_TestPackageNo = this.txtPTP_TestPackageNo.Text.Trim();
testPackage.PTP_TestPackageName = this.txtPTP_TestPackageName.Text.Trim();
testPackage.PTP_TestHeat = this.txtPTP_TestHeat.Text.Trim();
testPackage.PTP_TestService = this.txtPTP_TestService.Text.Trim();
if (this.drpPTP_TestType.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpPTP_TestType.SelectedValue))
{
testPackage.PTP_TestType = this.drpPTP_TestType.SelectedValue;
}
testPackage.PTP_Tabler = this.drpPTP_Tabler.SelectedValue;
testPackage.PTP_TableDate = Funs.GetNewDateTime(this.txtPTP_TableDate.Text.Trim());
if (this.drpPTP_Modifier.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpPTP_Modifier.SelectedValue))
{
testPackage.PTP_Modifier = this.drpPTP_Modifier.SelectedValue;
}
testPackage.PTP_ModifyDate = Funs.GetNewDateTime(this.txtPTP_ModifyDate.Text.Trim());
testPackage.PTP_Remark = this.txtPTP_Remark.Text.Trim();
testPackage.PTP_TestPackageCode = this.txtPTP_TestPackageCode.Text.Trim();
testPackage.PTP_TestAmbientTemp = this.txtPTP_TestAmbientTemp.Text.Trim();
testPackage.PTP_TestMediumTemp = this.txtPTP_TestMediumTemp.Text.Trim();
testPackage.PTP_TestPressure = this.txtPTP_TestPressure.Text.Trim();
testPackage.PTP_TestPressureTemp = this.txtPTP_TestPressureTemp.Text.Trim();
testPackage.PTP_TestPressureTime = this.txtPTP_TestPressureTime.Text.Trim();
testPackage.PTP_TightnessTest = this.txtPTP_TightnessTest.Text.Trim();
testPackage.PTP_TightnessTestTemp = this.txtPTP_TightnessTestTemp.Text.Trim();
testPackage.PTP_TightnessTestTime = this.txtPTP_TightnessTestTime.Text.Trim();
testPackage.PTP_LeakageTestService = this.txtPTP_LeakageTestService.Text.Trim();
testPackage.PTP_LeakageTestPressure = this.txtPTP_LeakageTestPressure.Text.Trim();
testPackage.PTP_VacuumTestService = this.txtPTP_VacuumTestService.Text.Trim();
testPackage.PTP_VacuumTestPressure = this.txtPTP_VacuumTestPressure.Text.Trim();
testPackage.PTP_OperationMedium = this.txtPTP_OperationMedium.Text.Trim();
testPackage.PTP_PurgingMedium = this.txtPTP_PurgingMedium.Text.Trim();
testPackage.PTP_CleaningMedium = this.txtPTP_CleaningMedium.Text.Trim();
testPackage.PTP_AllowSeepage = this.txtPTP_AllowSeepage.Text.Trim();
testPackage.PTP_FactSeepage = this.txtPTP_FactSeepage.Text.Trim();
if (!string.IsNullOrEmpty(this.PTP_ID))
{
var updatetestPackage = BLL.TestPackageManageEditService.GetTP_TestPackageByID(this.PTP_ID);
if (updatetestPackage != null)
{
if (updatetestPackage.PTP_AduditDate.HasValue)
{
Alert.ShowInTop("此条试压单已审核不能修改!", MessageBoxIcon.Warning);
return;
}
else
{
testPackage.PTP_ID = PTP_ID;
BLL.TestPackageManageEditService.UpdateTP_TestPackage(testPackage);
BLL.TestPackageManageEditService.DeleteTP_IsoListByPTP_ID(PTP_ID);
//BLL.LogService.AddLog(this.CurrUser.UserId, "修改试压单信息");
}
}
}
else
{
testPackage.PTP_ID = SQLHelper.GetNewID(typeof(Model.TP_TestPackage));
this.PTP_ID = testPackage.PTP_ID;
BLL.TestPackageManageEditService.AddTP_TestPackage(testPackage);
//BLL.LogService.AddLog(this.CurrUser.UserId, "添加试压单信息");
}
foreach (var item in isoInfos)
{
Model.TP_IsoList newitem = new Model.TP_IsoList();
newitem.PTP_ID = this.PTP_ID;
newitem.ISO_ID = item.ISO_ID;
BLL.TestPackageManageEditService.AddTP_IsoList(newitem);
}
isoInfos.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)
{
isoInfos.Clear();
List<string> infos = Funs.GetStrListByStr(hdIso_Id.Text, ',');
if (this.PTP_ID == null)
{
foreach (var item in infos)
{
Model.PW_IsoInfo info = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(item);
isoInfos.Add(info);
}
}
else
{
foreach (var iso in infos)
{
Model.PW_IsoInfo info = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(iso);
if (isoInfos.Where(y => y.ISO_ID == iso).Count() == 0)
{
isoInfos.Add(info);
}
}
}
if (isoInfos.Count > 0)
{
this.Grid1.DataSource = isoInfos;
this.Grid1.DataBind();
}
changeTestPackageCode(sender, e);
}
#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 testPackage = BLL.TestPackageManageEditService.GetTP_TestPackageByID(PTP_ID);
if (testPackage != null && testPackage.PTP_AduditDate.HasValue)
{
Alert.ShowInTop("此试压包已审核不能删除!", MessageBoxIcon.Warning);
return;
}
else
{
var item = isoInfos.FirstOrDefault(x => x.ISO_ID == rowID);
if (item != null)
{
isoInfos.RemoveAt(rowIndex);
}
}
}
Grid1.DataSource = isoInfos;
Grid1.DataBind();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region DropDownList下拉选择事件
/// <summary>
/// 委托单位下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnitId_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpInstallationId.Items.Clear();
if (!string.IsNullOrEmpty(this.drpUnitId.SelectedValue) && this.drpUnitId.SelectedValue != BLL.Const._Null)
{
//if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId))
//{
// BLL.Project_InstallationService.InitInstallationBySupervisorUnitIdListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnitId.SelectedValue, this.CurrUser.UnitId, true);
// this.drpInstallationId.SelectedIndex = 0;
//}
//else
//{
// BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnitId.SelectedValue, true);
// this.drpInstallationId.SelectedIndex = 0;
//}
BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnitId.SelectedValue, true);
this.drpInstallationId.SelectedIndex = 0;
}
else
{
Funs.FineUIPleaseSelect(this.drpInstallationId);
}
changeTestPackageNo(sender, e);
}
#endregion
#region
/// <summary>
/// 介质转换
/// </summary>
/// <param name="ISO_NDTClass"></param>
/// <returns></returns>
protected string ConvertTestMedium(object SER_ID)
{
if (SER_ID != null)
{
return BLL.Base_TestMediumService.GetTestMediumById(SER_ID.ToString()).MediumName;
}
else
{
return "";
}
}
#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_TestPackageManageMenuId, button);
}
#endregion
protected void drpInstallationId_OnSelectedIndexChanged(object sender, EventArgs e)
{
changeTestPackageNo(sender, e);
changeTestPackageCode(sender, e);
}
/// <summary>
/// 试压编号:施工单位+装置区号+SYB+流水号,自动生成。
/// </summary>
protected void changeTestPackageNo(object sender, EventArgs e)
{
/// 施工单位 + 装置区号 + SYB + 流水号
var unit = UnitService.GetUnitByUnitId(this.drpUnitId.SelectedValue);
var install = Project_InstallationService.GetInstallationByInstallationId(drpInstallationId.SelectedValue);
if (install != null && unit != null)
{
string code = unit.UnitCode + "-" + install.InstallationCode + "-SYB-";
txtPTP_TestPackageNo.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.TP_TestPackage", "PTP_TestPackageNo", this.CurrUser.LoginProjectId, code);
}
}
/// <summary>
/// 试压包号:装置区号+管道介质号+试压包流水号
/// </summary>
protected void changeTestPackageCode(object sender, EventArgs e)
{
/// 装置区号+管道介质号+试压包流水号
var install = Project_InstallationService.GetInstallationByInstallationId(drpInstallationId.SelectedValue);
if (install != null && isoInfos.Count > 0)
{
var isoInfo = isoInfos.Where(x => x.TestMediumId != null).FirstOrDefault();
if (isoInfo != null)
{
var testMedium = Funs.DB.Base_TestMedium.Where(x => x.TestMediumId == isoInfo.TestMediumId).FirstOrDefault();
if (testMedium != null)
{
string code = install.InstallationCode + "-" + testMedium.MediumCode + "-";
txtPTP_TestPackageCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.TP_TestPackage", "PTP_TestPackageCode", this.CurrUser.LoginProjectId, code);
}
}
}
}
}
}