ChengDa_English/SGGL/FineUIPro.Web/HJGL/TrustManage/TrustManageSet.aspx.cs

295 lines
15 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 Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.TrustManage
{
public partial class TrustManageSet : PageBase
{
#region
/// <summary>
/// 点口主键
/// </summary>
public string PW_PointID
{
get
{
return (string)ViewState["PW_PointID"];
}
set
{
ViewState["PW_PointID"] = value;
}
}
public static string prefixCode;
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
//委托单位
var unit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
if (unit == null || unit.UnitType == BLL.Const.ProjectUnitType_1)
{
BLL.UnitService.InitUnitNameByUnitTypeDropDownList(this.drpCH_TrustUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
}
else
{
BLL.UnitService.InitSubUnitNameListDownList(this.drpCH_TrustUnit, this.CurrUser.LoginProjectId, this.CurrUser.UnitId, true);
}
BLL.Base_DetectionRateService.InitDetectionRateDropDownList(this.drpCH_NDTRate, true);//探伤比例
BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(this.drpCH_NDTMethod, true);//检测方法
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpCH_CheckUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_5, true);//检测单位
if (this.drpCH_CheckUnit.Items.Count > 0)
{
this.drpCH_CheckUnit.SelectedIndex = 1;
}
//合格等级
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);
this.drpCH_AcceptGrade.SelectedValue = "2";
BLL.Base_WeldingMethodService.InitWeldingMethodDropDownList(this.drpCH_WeldMethod, true);//焊接方法
BLL.Base_GrooveTypeService.InitGrooveTypeDropDownList(this.drpCH_SlopeType, true);//坡口类型
this.txtCH_TrustDate.Text = String.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
this.txtCH_TableDate.Text = String.Format("{0:yyyy-MM-dd}", System.DateTime.Now);
this.PW_PointID = Request.Params["PW_PointID"];
var bo_Point = BLL.PointManageService.GetPointByPointID(this.PW_PointID); ////获取点口信息
if (bo_Point != null)
{
this.drpCH_TrustUnit.SelectedValue = bo_Point.UnitId;
var jointInfos = BLL.PW_JointInfoService.GetDistinctViewJointInfosByPointID(this.PW_PointID);
var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == jointInfos[0].JOT_ID);
var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_ID == join.ISO_ID);
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;
switch (iso.ISO_NDTClass)
{
case "":
this.drpCH_AcceptGrade.SelectedValue = "1"; break;
case "Ⅱ":
this.drpCH_AcceptGrade.SelectedValue = "2"; break;
case "Ⅲ":
this.drpCH_AcceptGrade.SelectedValue = "3"; break;
case "Ⅳ":
this.drpCH_AcceptGrade.SelectedValue = "4"; break;
case "":
this.drpCH_AcceptGrade.SelectedValue = "5"; break;
}
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);
}
}
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;
switch (iso.ISO_NDTClass)
{
case "":
this.drpCH_AcceptGrade.SelectedValue = "1"; break;
case "Ⅱ":
this.drpCH_AcceptGrade.SelectedValue = "2"; break;
case "Ⅲ":
this.drpCH_AcceptGrade.SelectedValue = "3"; break;
case "Ⅳ":
this.drpCH_AcceptGrade.SelectedValue = "4"; break;
case "":
this.drpCH_AcceptGrade.SelectedValue = "5"; break;
}
var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
if (trustUnit != 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);
}
}
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.drpCH_NDTRate.SelectedValue==BLL.Const._Null||string.IsNullOrEmpty(this.drpCH_NDTRate.SelectedValue))
{
Alert.ShowInTop("请选择探伤比例!", MessageBoxIcon.Warning);
return;
}
if (this.drpCH_TrustUnit.SelectedValue==BLL.Const._Null||string.IsNullOrEmpty(this.drpCH_TrustUnit.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;
}
var jointInfos = BLL.PW_JointInfoService.GetDistinctViewJointInfosByPointID(this.PW_PointID); ////获取点口中的焊口信息
var trustOlds = BLL.TrustManageEditService.GetCH_TrustItemByJOT_ID(jointInfos[0].JOT_ID);
if (this.drpCH_CheckUnit.SelectedValue==BLL.Const._Null||string.IsNullOrEmpty(this.drpCH_CheckUnit.SelectedValue))
{
Alert.ShowInTop("请选择检测单位!", MessageBoxIcon.Warning);
return;
}
Model.CH_Trust trust = new Model.CH_Trust();
trust.ProjectId = this.CurrUser.LoginProjectId;
trust.CH_RequestDate = System.DateTime.Now;
trust.CH_TrustCode = this.txtCH_TrustCode.Text.Trim();
if (this.drpCH_NDTRate.SelectedValue != BLL.Const._Null&&!string.IsNullOrEmpty(this.drpCH_NDTRate.SelectedValue))
{
trust.CH_NDTRate = this.drpCH_NDTRate.SelectedValue;
}
if (this.drpCH_TrustUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_TrustUnit.SelectedValue))
{
trust.CH_TrustUnit = this.drpCH_TrustUnit.SelectedValue;
}
if (this.drpCH_NDTMethod.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCH_NDTMethod.SelectedValue)) ;
{
trust.CH_NDTMethod = this.drpCH_NDTMethod.SelectedValue;
}
trust.CH_TrustDate = Funs.GetNewDateTime(this.txtCH_TrustDate.Text);
if (this.drpCH_CheckUnit.SelectedValue != BLL.Const._Null&&!string.IsNullOrEmpty(this.drpCH_CheckUnit.SelectedValue))
{
trust.CH_CheckUnit = this.drpCH_CheckUnit.SelectedValue;
}
trust.CH_TableDate = Funs.GetNewDateTime(this.txtCH_TableDate.Text);
if (this.drpCH_AcceptGrade.SelectedValue != BLL.Const._Null&&!string.IsNullOrEmpty(this.drpCH_AcceptGrade.SelectedValue))
{
trust.CH_AcceptGrade = this.drpCH_AcceptGrade.SelectedValue;
trust.CH_NDTCriteria = "NB/T47013-2015(" + this.drpCH_AcceptGrade.SelectedItem.Text + ")";
}
else
{
trust.CH_NDTCriteria = "NB/T47013-2015";
}
if (this.drpCH_WeldMethod.SelectedValue != BLL.Const._Null&&!string.IsNullOrEmpty(this.drpCH_WeldMethod.SelectedValue))
{
trust.CH_WeldMethod = this.drpCH_WeldMethod.SelectedValue;
}
if (this.drpCH_SlopeType.SelectedValue != BLL.Const._Null&&!string.IsNullOrEmpty(this.drpCH_SlopeType.SelectedValue))
{
trust.CH_SlopeType = this.drpCH_SlopeType.SelectedValue;
}
trust.CH_Remark = this.txtCH_Remark.Text.Trim();
trust.CH_TrustType = "1";
trust.CH_Tabler = this.CurrUser.UserId;
var bo_Point = BLL.PointManageService.GetPointByPointID(this.PW_PointID); //获取点口信息
if (bo_Point != null)
{
trust.InstallationId = bo_Point.InstallationId;
}
trust.CH_TrustID = SQLHelper.GetNewID(typeof(Model.CH_Trust));
BLL.TrustManageEditService.AddCH_Trust(trust);
//BLL.LogService.AddLog(this.CurrUser.UserId, "添加委托单信息");
foreach (var item in jointInfos)
{
Model.CH_TrustItem newitem = new CH_TrustItem();
newitem.CH_TrustID = trust.CH_TrustID;
newitem.JOT_ID = item.JOT_ID;
BLL.TrustManageEditService.AddCH_TrustItem(newitem);
var jointInfo = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == newitem.JOT_ID);
jointInfo.JOT_TrustFlag = "01";
Funs.DB.SubmitChanges();
}
ShowNotify("生成成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
protected void needChangeCode(object sender, EventArgs e)
{
var bo_Point = BLL.PointManageService.GetPointByPointID(this.PW_PointID); ////获取点口信息
if (bo_Point != null)
{
var jointInfos = BLL.PW_JointInfoService.GetDistinctViewJointInfosByPointID(this.PW_PointID);
var join = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == jointInfos[0].JOT_ID);
var iso = Funs.DB.PW_IsoInfo.FirstOrDefault(x => x.ISO_ID == jointInfos[0].ISO_ID);
var trustUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == this.drpCH_TrustUnit.SelectedValue);
if (!iso.Is_Standard)
{
//this.drpCH_NDTRate.SelectedValue = join.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);
}
}
else
{
//this.drpCH_NDTRate.SelectedValue = join.DetectionRateId;
////this.drpCH_NDTMethod.SelectedValue = iso.DetectionTypeId;
//this.drpCH_SlopeType.SelectedValue = join.JST_ID;
//this.drpCH_WeldMethod.SelectedValue = join.WME_ID;
var NDTMethod = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeId == this.drpCH_NDTMethod.SelectedValue);
if (trustUnit != 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);
}
}
}
}
}
}