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.WeldingManage { public partial class PmiMaterialAddEdit : PageBase { public string MaterialId { get { return (string)Request.Params["MaterialId"]; } set { Request.Params["MaterialId"] = value; } } #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); BLL.Project_InstallationService.InitInstallationDropDownList(this.ddlInstallationId, this.CurrUser.LoginProjectId, true); Funs.FineUIPleaseSelect(this.ddlAreaId); var MaterialModel = BLL.PMI_MaterialTemplateService.GetPMI_MaterialTemplateId(MaterialId); if (MaterialModel != null) { //初始化页面信息 this.LoadPageInfo(MaterialModel); } } } #endregion #region 初始化页面信息 /// /// 初始化页面信息 /// /// private void LoadPageInfo(PMI_MaterialTemplate pMI_MaterialTemplate) { if (pMI_MaterialTemplate != null) { //主键--MaterialId //专业--Discpline //装置--UnitId //InitUnitIdDropDownList(this.ddlUnitId, true); if (!string.IsNullOrEmpty(pMI_MaterialTemplate.UnitId)) { this.ddlInstallationId.SelectedValue = pMI_MaterialTemplate.UnitId; BLL.WorkAreaService.InitWorkAreaByProjectIdAndInstallationId(this.ddlAreaId, this.CurrUser.LoginProjectId, this.ddlInstallationId.SelectedValue, true); //InitAreaIdDropDownList(ddlAreaId, pMI_MaterialTemplate.UnitId, false); } //工区--AreaId if (!string.IsNullOrEmpty(pMI_MaterialTemplate.AreaId)) { this.ddlAreaId.SelectedValue = pMI_MaterialTemplate.AreaId; } //InitAreaIdDropDownList(this.ddlAreaId, true); //管线--Pipeline this.txtPipeline.Text = pMI_MaterialTemplate.Pipeline; //Item Rule规则--ItemRule this.txtItemRule.Text = pMI_MaterialTemplate.ItemRule; //Commoidy Code(材料代码)--CommoidyCode this.txtCommoidyCode.Text = pMI_MaterialTemplate.CommoidyCode; //Size1-规则型号--Size1 this.txtSize1.Text = pMI_MaterialTemplate.Size1; //Size2- 规则型号--Size2 this.txtSize2.Text = pMI_MaterialTemplate.Size2; //Ident Code--IdentCode this.txtIdentCode.Text = pMI_MaterialTemplate.IdentCode; //设备位号--TagNumber this.txtTagNumber.Text = pMI_MaterialTemplate.TagNumber; //材料名称--IdentName this.txtIdentName.Text = pMI_MaterialTemplate.IdentName; //材料/设备短描述--ShortDescription this.txtShortDescription.Text = pMI_MaterialTemplate.ShortDescription; //数量--Quantity this.txtQuantity.Text = Convert.ToString(pMI_MaterialTemplate.Quantity); //数量单位--UnitNum this.txtUnitNum.Text = pMI_MaterialTemplate.UnitNum; //导向管--PipeRun this.txtPipeRun.Text = pMI_MaterialTemplate.PipeRun; //类型 --Catery this.txtCatery.Text = pMI_MaterialTemplate.Category; //材质--Material this.txtMaterial.Text = pMI_MaterialTemplate.Material; //等级--Spec this.txtSpec.Text = pMI_MaterialTemplate.Spec; //口径 Nominal Diameter--NominalDiameter this.txtNominalDiameter.Text = pMI_MaterialTemplate.NominalDiameter; //壁厚THK.--THK this.txtTHK.Text = pMI_MaterialTemplate.THK; //涂漆涂色--Painting this.txtPainting.Text = pMI_MaterialTemplate.Painting; //重量--WeightNum this.txtWeightNum.Text = Convert.ToString(pMI_MaterialTemplate.WeightNum); //重量单位--WeightUnit this.txtWeightUnit.Text = pMI_MaterialTemplate.WeightUnit; //备注Remark--Remark this.txtRemark.Text = pMI_MaterialTemplate.Remark; //项目Id--ProjectId //总量--QuantitySum this.txtQuantitySum.Text = pMI_MaterialTemplate.QuantitySum; //热处理状态--HotState this.txtHotState.Text = pMI_MaterialTemplate.HotState; //质量文书编号--QuantityFileNum this.txtQuantityFileNum.Text = pMI_MaterialTemplate.QuantityFileNum; //验收标准--AcceptanceCriteria this.txtAcceptanceCriteria.Text = pMI_MaterialTemplate.AcceptanceCriteria; //炉批号--BatchNumber this.txtBatchNumber.Text = pMI_MaterialTemplate.BatchNumber; } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Model.PMI_MaterialTemplate pMI_MaterialTemplate = new Model.PMI_MaterialTemplate(); //主键--MaterialId //专业--Discpline //装置--UnitId if (this.ddlInstallationId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlInstallationId.SelectedValue)) { Alert.ShowInTop("请选择装置!", MessageBoxIcon.Warning); return; } pMI_MaterialTemplate.UnitId = this.ddlInstallationId.SelectedValue; pMI_MaterialTemplate.UnitIdName = this.ddlInstallationId.SelectedText; //工区--AreaId if (this.ddlAreaId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.ddlAreaId.SelectedValue)) { Alert.ShowInTop("请选择工区!", MessageBoxIcon.Warning); return; } pMI_MaterialTemplate.AreaId = this.ddlAreaId.SelectedValue; pMI_MaterialTemplate.AreaIdName = this.ddlAreaId.SelectedText; //管线--Pipeline pMI_MaterialTemplate.Pipeline = this.txtPipeline.Text.Trim(); //Item Rule规则--ItemRule pMI_MaterialTemplate.ItemRule = this.txtItemRule.Text.Trim(); //Commoidy Code(材料代码)--CommoidyCode pMI_MaterialTemplate.CommoidyCode = this.txtCommoidyCode.Text.Trim(); //Size1-规则型号--Size1 pMI_MaterialTemplate.Size1 = this.txtSize1.Text.Trim(); //Size2- 规则型号--Size2 pMI_MaterialTemplate.Size2 = this.txtSize2.Text.Trim(); //Ident Code--IdentCode pMI_MaterialTemplate.IdentCode = this.txtIdentCode.Text.Trim(); //设备位号--TagNumber pMI_MaterialTemplate.TagNumber = this.txtTagNumber.Text; //材料名称--IdentName pMI_MaterialTemplate.IdentName = this.txtIdentName.Text; //材料/设备短描述--ShortDescription pMI_MaterialTemplate.ShortDescription = this.txtShortDescription.Text.Trim(); //数量--Quantity pMI_MaterialTemplate.Quantity = string.IsNullOrEmpty(this.txtQuantity.Text.Trim()) == true ? 0 : Convert.ToDecimal(this.txtQuantity.Text); //数量单位--UnitNum pMI_MaterialTemplate.UnitNum = this.txtUnitNum.Text.Trim(); //导向管--PipeRun pMI_MaterialTemplate.PipeRun = this.txtPipeRun.Text.Trim(); //类型 --Catery pMI_MaterialTemplate.Category = this.txtCatery.Text.Trim(); //材质--Material pMI_MaterialTemplate.Material = this.txtMaterial.Text.Trim(); //等级--Spec pMI_MaterialTemplate.Spec = this.txtSpec.Text.Trim(); //口径 Nominal Diameter--NominalDiameter pMI_MaterialTemplate.NominalDiameter = this.txtNominalDiameter.Text.Trim(); //壁厚THK.--THK pMI_MaterialTemplate.THK = this.txtTHK.Text.Trim(); //涂漆涂色--Painting pMI_MaterialTemplate.Painting = this.txtPainting.Text.Trim(); //重量--WeightNum pMI_MaterialTemplate.WeightNum = string.IsNullOrEmpty(this.txtWeightNum.Text.Trim()) ==true?0:Convert.ToDecimal(this.txtWeightNum.Text.Trim()); //重量单位--WeightUnit pMI_MaterialTemplate.WeightUnit = this.txtWeightUnit.Text.Trim(); //备注Remark--Remark pMI_MaterialTemplate.Remark = this.txtRemark.Text.Trim(); //项目Id--ProjectId pMI_MaterialTemplate.ProjectId = this.CurrUser.LoginProjectId; //总量--QuantitySum pMI_MaterialTemplate.QuantitySum = this.txtQuantitySum.Text.Trim(); //热处理状态--HotState pMI_MaterialTemplate.HotState = this.txtHotState.Text.Trim(); //质量文书编号--QuantityFileNum pMI_MaterialTemplate.QuantityFileNum = this.txtQuantityFileNum.Text.Trim(); //验收标准--AcceptanceCriteria pMI_MaterialTemplate.AcceptanceCriteria = this.txtAcceptanceCriteria.Text.Trim(); //炉批号--BatchNumber pMI_MaterialTemplate.BatchNumber = this.txtBatchNumber.Text.Trim(); if (!string.IsNullOrEmpty(MaterialId)) { pMI_MaterialTemplate.MaterialId = MaterialId; BLL.PMI_MaterialTemplateService.UpdatePMI_MaterialTemplate(pMI_MaterialTemplate); } else { pMI_MaterialTemplate.MaterialId = SQLHelper.GetNewID(typeof(Model.PMI_MaterialTemplate)); pMI_MaterialTemplate.CreateTime = DateTime.Now; BLL.PMI_MaterialTemplateService.AddPMI_MaterialTemplate(pMI_MaterialTemplate); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion //public void InitAreaIdDropDownList(DropDownList dropName,string ddlstringName, bool isShowPlease) //{ // this.ddlAreaId.DataValueField = "UnitId"; // this.ddlAreaId.DataTextField = "UnitName"; // if (isShowPlease||string.IsNullOrEmpty(ddlstringName)) // { // Funs.FineUIPleaseSelect(dropName); // } // else // { // var ddlunitString = ddlstringName; // this.ddlAreaId.DataValueField = "UnitId"; // this.ddlAreaId.DataTextField = "UnitName"; // this.ddlAreaId.DataSource = (from x in Funs.DB.PIM_View_PmiMaterialTemplate where x.ProjectId == this.CurrUser.LoginProjectId && x.InstallationId == ddlunitString select new { x.UnitId, x.UnitName }).Distinct().ToList(); // this.ddlAreaId.DataBind(); // } //} //public void InitUnitIdDropDownList(DropDownList dropName, bool isShowPlease) //{ // dropName.DataValueField = "InstallationId"; // dropName.DataTextField = "InstallationName"; // dropName.DataSource = (from x in Funs.DB.PIM_View_PmiMaterialTemplate where x.ProjectId == this.CurrUser.LoginProjectId select new { x.InstallationId, x.InstallationName }).Distinct().ToList(); // dropName.DataBind(); // if (isShowPlease) // { // Funs.FineUIPleaseSelect(dropName); // } //} protected void drpInstallation_SelectedIndexChanged(object sender, EventArgs e) { this.ddlAreaId.Items.Clear(); if (this.ddlInstallationId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.ddlInstallationId.SelectedValue)) { BLL.WorkAreaService.InitWorkAreaByProjectIdAndInstallationId(this.ddlAreaId, this.CurrUser.LoginProjectId, this.ddlInstallationId.SelectedValue, true); } else { Funs.FineUIPleaseSelect(this.ddlAreaId); } this.ddlAreaId.SelectedIndex = 0; //if (this.drpInstallation.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallation.SelectedValue)) //{ // Funs.FineUIPleaseSelect(this.drpInstallation); //} //else //{ // var ddlunitString = this.drpInstallation.SelectedValue; // this.drpCH_TrustUnit.DataValueField = "UnitId"; // this.drpCH_TrustUnit.DataTextField = "UnitName"; // this.drpCH_TrustUnit.DataSource = (from x in Funs.DB.PIM_View_PmiMaterialTemplate where x.ProjectId == this.CurrUser.LoginProjectId && x.InstallationId == ddlunitString select new { x.UnitId, x.UnitName }).Distinct().ToList(); // this.drpCH_TrustUnit.DataBind(); //} } } }