SGGL_SGY/SGGL/FineUIPro.Web/HJGL/MaterialManage/WelderMaterial.aspx.cs

354 lines
15 KiB
C#
Raw Permalink Normal View History

2025-02-19 15:58:42 +08:00
using System;
using System.Data;
using BLL;
using System.Linq;
using System.Collections.Generic;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
namespace FineUIPro.Web.HJGL.MaterialManage
{
public partial class WelderMaterial : PageBase
{
#region
/// <summary>
/// RecoveryId
/// </summary>
public string RecoveryId
{
get
{
return (string)ViewState["RecoveryId"];
}
set
{
ViewState["RecoveryId"] = value;
}
}
/// <summary>
/// 焊工id
/// </summary>
public string WED_ID
{
get
{
return (string)ViewState["WED_ID"];
}
set
{
ViewState["WED_ID"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
// 点击 TwinTriggerBox 的搜索按钮
protected void ttbxCode_Trigger2Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(ttbxCode.Text))
{
// 执行搜索动作
var welder = BLL.WelderService.GetWelderByCode(CurrUser.LoginProjectId, ttbxCode.Text);
if (welder != null)
{
WED_ID = welder.WED_ID;
txtIdentityCard.Text = welder.IdentityCard;
txtWelderName.Text = welder.WED_Name;
imgPhoto.ImageUrl = "../../" + welder.AttachUrl;
txtUnit.Text = "";
if (!string.IsNullOrEmpty(welder.WED_Unit))
{
var unit = UnitService.GetUnitByUnitId(welder.WED_Unit);
if (unit != null)
txtUnit.Text = unit.UnitName;
}
txtClass.Text = welder.WED_Class;
if (welder.WED_IfOnGuard.HasValue)
{
if (welder.WED_IfOnGuard.Value == true)
{
txtIfOnGuard.Text = "是";
}
else
{
txtIfOnGuard.Text = "否";
}
}
//装置
this.drpInstallation.DataTextField = "Text";
this.drpInstallation.DataValueField = "Value";
this.drpInstallation.DataSource = BLL.Project_InstallationService.GetInstallationList(welder.ProjectId, welder.WED_Unit);
this.drpInstallation.DataBind();
Funs.FineUIPleaseSelect(this.drpInstallation);
if (this.drpInstallation.Items.Count == 2)
{
this.drpInstallation.SelectedIndex = 1;
}
var items = from x in Funs.DB.BS_WeldMethodItem where x.WED_ID == this.WED_ID select x.WME_ID;
var methods = from m in Funs.DB.Base_WeldingMethod where items.Count()==0|| items.Contains(m.WeldingMethodId) select m ;
this.drpMethods.DataTextField = "WeldingMethodName";
this.drpMethods.DataValueField = "WeldingMethodId";
this.drpMethods.DataSource = methods;
this.drpMethods.DataBind();
Funs.FineUIPleaseSelect(this.drpMethods);
this.drpMethods.SelectedIndex = 0;
var itemsSteel = from x in Funs.DB.BS_WelderItem where x.WED_ID == this.WED_ID select x.STE_ID;
var steel = from x in Funs.DB.BS_Steel where itemsSteel.Count() == 0 || itemsSteel.Contains(x.STE_ID) select x;
this.drpSteel.DataTextField = "STE_Name";
this.drpSteel.DataValueField = "STE_ID";
this.drpSteel.DataSource = steel;
this.drpSteel.DataBind();
Funs.FineUIPleaseSelect(this.drpSteel);
this.drpSteel.SelectedIndex = 0;
}
else
{
txtIdentityCard.Text = "";
txtWelderName.Text = "";
txtUnit.Text = "";
txtUnit.Text = "";
txtClass.Text = "";
txtIfOnGuard.Text = "";
ShowNotify("未找到该焊工!");
}
ttbxCode.ShowTrigger1 = true;
}
else
{
ShowNotify("请输入焊工号!");
}
}
// 点击 TwinTriggerBox 的取消按钮
protected void ttbxCode_Trigger1Click(object sender, EventArgs e)
{
// 执行清空动作
ttbxCode.Text = "";
ttbxCode.ShowTrigger1 = false;
}
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RecoveryId = Request.Params["RecoveryId"];
this.drpEquipment.DataTextField = "Text";
this.drpEquipment.DataValueField = "Value";
this.drpEquipment.DataSource = BLL.DropListService.HJGL_Equipment();
this.drpEquipment.DataBind();
Funs.FineUIPleaseSelect(this.drpEquipment);
this.drpEquipment.SelectedIndex = 0;
string code = ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).ProjectCode + "-HJ-TCC-LL-";
txtCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HJGL_ElectrodeRecovery", "RecoveryCode", this.CurrUser.LoginProjectId, code);
if (this.drpEquipment.Items.Count == 2)
{
this.drpEquipment.SelectedIndex = 1;
}
this.drpSteelType.DataTextField = "Text";
this.drpSteelType.DataValueField = "Value";
this.drpSteelType.DataSource = BLL.DropListService.HJGL_GetSteTypeList();
this.drpSteelType.DataBind();
Funs.FineUIPleaseSelect(this.drpSteelType);
this.drpSteelType.SelectedIndex = 0;
if (!string.IsNullOrEmpty(RecoveryId))
{
var recovery = Funs.DB.HJGL_ElectrodeRecovery.Where(x => x.ElectrodeRecoveryId == RecoveryId).FirstOrDefault();
//txtCode.Text = recovery.RecoveryCode;
//ttbxCode.Text = recovery.WelderCode;
//var welder = WelderService.GetWelderByCode(recovery.ProjectId, recovery.WelderCode);
//WED_ID = welder.WED_ID;
//txtIdentityCard.Text = welder.IdentityCard;
//txtWelderName.Text = welder.WED_Name;
//txtNumber.Text = "" + recovery.RecoveryCount;
//imgPhoto.ImageUrl = "../../" + welder.AttachUrl;
//if (!string.IsNullOrEmpty(welder.WED_Unit))
//{
// var unit = UnitService.GetUnitByUnitId(welder.WED_Unit);
// if (unit != null)
// txtUnit.Text = unit.UnitName;
//}
//txtClass.Text = welder.WED_Class;
//if (welder.WED_IfOnGuard.HasValue)
//{
// if (welder.WED_IfOnGuard.Value == true)
// {
// txtIfOnGuard.Text = "是";
// }
// else
// {
// txtIfOnGuard.Text = "否";
// }
//}
////装置
//this.drpInstallation.DataTextField = "Text";
//this.drpInstallation.DataValueField = "Value";
//this.drpInstallation.DataSource = BLL.Project_InstallationService.GetInstallationList(welder.ProjectId, welder.WED_Unit);
//this.drpInstallation.DataBind();
//Funs.FineUIPleaseSelect(this.drpInstallation);
//if (this.drpInstallation.Items.Count == 2)
//{
// this.drpInstallation.SelectedIndex = 1;
//}
//if (!string.IsNullOrEmpty(recovery.InstallationId))
//{
// this.drpInstallation.SelectedValue = recovery.InstallationId;
//}
var items = from x in Funs.DB.BS_WeldMethodItem where x.WED_ID == this.WED_ID select x.WME_ID;
var methods = from m in Funs.DB.Base_WeldingMethod where items.Count() == 0 || items.Contains(m.WeldingMethodId) select m;
this.drpMethods.DataTextField = "WeldingMethodName";
this.drpMethods.DataValueField = "WeldingMethodId";
this.drpMethods.DataSource = methods;
this.drpMethods.DataBind();
Funs.FineUIPleaseSelect(this.drpMethods);
this.drpMethods.SelectedIndex = 0;
var itemsSteel = from x in Funs.DB.BS_WelderItem where x.WED_ID == this.WED_ID select x.STE_ID;
var steel = from x in Funs.DB.BS_Steel where itemsSteel.Count() == 0 || itemsSteel.Contains(x.STE_ID) select x;
this.drpSteel.DataTextField = "STE_Name";
this.drpSteel.DataValueField = "STE_ID";
this.drpSteel.DataSource = steel;
this.drpSteel.DataBind();
Funs.FineUIPleaseSelect(this.drpSteel);
this.drpSteel.SelectedIndex = 0;
//drpInstallation.SelectedValue = recovery.InstallationId;
//drpSteel.SelectedValue = recovery.STE_ID;
//drpMethods.SelectedValue = recovery.WMD_ID;
//drpSteel.SelectedValue = recovery.STE_ID;
//var consumables1 = BLL.Base_ConsumablesService.GetConsumablesByConsumablesId(recovery.WMT_ID);
//this.txtSteelFormat.Text = consumables1.SteelFormat;
//drpEquipment.SelectedValue = recovery.Equipment;
//this.drpSteelType.SelectedValue = consumables1.SteelType;
//var consumables = from c in Funs.DB.Base_Consumables where c.SteelType == consumables1.SteelType select c;
//this.drpConsumables.DataTextField = "ConsumablesName";
//this.drpConsumables.DataValueField = "ConsumablesId";
//this.drpConsumables.DataSource = consumables;
//this.drpConsumables.DataBind();
//Funs.FineUIPleaseSelect(this.drpConsumables);
//drpConsumables.SelectedValue = recovery.WMT_ID;
}
}
}
protected void drpSteelType_OnSelectedIndexChanged(object sender, EventArgs e)
{
var steelType = drpSteelType.SelectedValue;
var consumables = from c in Funs.DB.Base_Consumables where c.SteelType == steelType select c;
this.drpConsumables.DataTextField = "ConsumablesName";
this.drpConsumables.DataValueField = "ConsumablesId";
this.drpConsumables.DataSource = consumables;
this.drpConsumables.DataBind();
Funs.FineUIPleaseSelect(this.drpConsumables);
drpConsumables.SelectedIndex = 0;
}
protected void drpConsumables_OnSelectedIndexChanged(object sender, EventArgs e)
{
var id = drpConsumables.SelectedValue;
var consumables =( from c in Funs.DB.Base_Consumables where c.ConsumablesId == id select c).FirstOrDefault();
this.txtSteelFormat.Text = consumables.SteelFormat;
}
protected void btn_Save(object sender, EventArgs e)
{
Model.HJGL_ElectrodeRecovery recovery = new Model.HJGL_ElectrodeRecovery();
//if (!string.IsNullOrEmpty(RecoveryId))
//{
// recovery = Funs.DB.HJGL_ElectrodeRecovery.FirstOrDefault(x=>x.RecoveryId== RecoveryId);
//}
//recovery.ProjectId = this.CurrUser.LoginProjectId;
//var welder = BLL.WelderService.GetWelderById(WED_ID);
//recovery.WelderCode = welder.WED_Code;
//recovery.WelderName = welder.WED_Name;
//recovery.WeldIdentityCard = welder.IdentityCard;
//recovery.CompanyId = welder.WED_Unit;
//recovery.RecoveryDate = DateTime.Now;
//recovery.RecoveryCode = this.txtCode.Text;
//recovery.RecoveryCount =short.Parse(this.txtNumber.Text);
//if (drpInstallation.SelectedValue != BLL.Const._Null)
//{
// recovery.InstallationId = drpInstallation.SelectedValue;
//}
//if (drpSteel.SelectedValue != BLL.Const._Null)
//{
// recovery.STE_ID = drpSteel.SelectedValue;
//}
//if (drpMethods.SelectedValue != BLL.Const._Null)
//{
// recovery.WMD_ID = drpMethods.SelectedValue;
//}
////if (drpEquipment.SelectedValue != BLL.Const._Null)
////{
//// recovery.STE_ID = drpEquipment.SelectedValue;
////}
//if (drpEquipment.SelectedValue != BLL.Const._Null)
//{
// recovery.Equipment = drpEquipment.SelectedValue;
//}
//if (drpConsumables.SelectedValue != BLL.Const._Null)
//{
// recovery.WMT_ID = drpConsumables.SelectedValue;
// var consumables = BLL.Base_ConsumablesService.GetConsumablesByConsumablesId(drpConsumables.SelectedValue);
// recovery.Specifications = consumables.SteelFormat;
//}
//if (string.IsNullOrEmpty(RecoveryId))
//{
// recovery.RecoveryId = Guid.NewGuid().ToString();
// Funs.DB.HJGL_ElectrodeRecovery.InsertOnSubmit(recovery);
// Funs.DB.SubmitChanges();
//}
//else
//{
// Funs.DB.SubmitChanges();
//}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}