using BLL; using Microsoft.ReportingServices.ReportProcessing.ReportObjectModel; using System; using System.Linq; namespace FineUIPro.Web.WeldingProcess.WeldingManage { public partial class MaterialCoodeEdit : PageBase { #region 定义项 /// /// 主键 /// public string MaterialCoodeId { get { return (string)ViewState["MaterialCoodeId"]; } set { ViewState["MaterialCoodeId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.txtCoode.Focus(); btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.MaterialCoodeId = Request.Params["MaterialCoodeId"]; string flag = Request.Params["flag"]; if (flag == "view") { this.btnSave.Hidden = true; } if (!string.IsNullOrEmpty(this.MaterialCoodeId)) { Model.Base_MaterialCoode Material = BLL.MaterialCoodeService.GetMaterialCoode(this.MaterialCoodeId, this.CurrUser.LoginProjectId); if (Material != null) { this.txtCoode.Text = Material.Coode; this.txtHeartNo.Text = Material.HeartNo; if (Material.Amount.HasValue) { txtAmount.Text = Material.Amount.Value.ToString(); } if (Material.IsUse.HasValue) { this.cbIsUse.Checked = Material.IsUse.Value; } else { this.cbIsUse.Checked=false; } } } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (BLL.MaterialCoodeService.IsExistMaterialCoode(this.CurrUser.LoginProjectId, txtHeartNo.Text.Trim(), txtCoode.Text.Trim(), this.MaterialCoodeId)) { Alert.ShowInTop("此物料码对应的炉批号已存在", MessageBoxIcon.Warning); return; } Model.Base_MaterialCoode newCoode = new Model.Base_MaterialCoode { ProjectId = this.CurrUser.LoginProjectId, Coode = this.txtCoode.Text.Trim(), HeartNo = this.txtHeartNo.Text.Trim(), IsUse = this.cbIsUse.Checked, }; if (this.txtAmount.Text != "") { newCoode.Amount = Convert.ToInt32(this.txtAmount.Text); } else { newCoode.Amount=null; } if (!string.IsNullOrEmpty(this.MaterialCoodeId)) { newCoode.MaterialCoodeId= this.MaterialCoodeId; BLL.MaterialCoodeService.UpdateMaterialCoode(newCoode); BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.MaterialCoodeMenuId, Const.BtnModify, this.MaterialCoodeId); } else { this.MaterialCoodeId = SQLHelper.GetNewID(typeof(Model.Base_MaterialCoode)); newCoode.MaterialCoodeId = this.MaterialCoodeId; BLL.MaterialCoodeService.AddMaterialCoode(newCoode); BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.MaterialCoodeMenuId, Const.BtnAdd, this.MaterialCoodeId); } ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }