using BLL; using Microsoft.JScript; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.WelderManage { public partial class WelderTestInfoEdit : PageBase { private string Id = string.Empty; private string welderId=string.Empty; protected void Page_Load(object sender, EventArgs e) { this.welderId = Request.Params["WelderId"]; this.Id= Request.Params["id"]; if (!IsPostBack) { this.BindDrpInit(); this.GetWelderInfo(); if(!string.IsNullOrEmpty(this.Id)) this.GetTestInfo(); } } public void GetTestInfo() { var result=Funs.DB.Welder_TestInfo.FirstOrDefault(t=>t.Id==this.Id); if (result == null) { ShowNotify("请不要非法操作",MessageBoxIcon.Error); return; } drpIsPass.SelectedValue = result.IsPass.ToString(); drpMaterialType.SelectedValueArray=result.MaterialId.Split(','); drpWeldMethod.SelectedValue = result.WeldMethodId.ToString(); txtCheckDate.Text = result.CreatedDate.Value.ToString("yyyy-MM-dd"); txtRemark.Text = result.Remark.ToString(); } private void GetWelderInfo() { var result = Funs.DB.Welder_Welder.FirstOrDefault(t => t.WelderId == this.welderId); if(result == null) { return; } lbWedlerName.Text= result.WelderName; lbWedlerCode.Text= result.WelderCode; } private void BindDrpInit() { var methodList = Funs.DB.Base_WeldingMethod.OrderBy(t=>t.WeldingMethodCode).ToList(); drpWeldMethod.DataSource= methodList; drpWeldMethod.DataTextField = "WeldingMethodCode"; drpWeldMethod.DataValueField = "WeldingMethodId"; drpWeldMethod.DataBind(); drpWeldMethod.Items.Insert(0, new ListItem("请选择", "")); this.drpMaterialType.DataTextField = "Text"; this.drpMaterialType.DataValueField = "Value"; this.drpMaterialType.DataSource = BLL.DropListService.MaterialTypeList(); this.drpMaterialType.DataBind(); Funs.FineUIPleaseSelect(this.drpMaterialType); } protected void btnSave_Click(object sender, EventArgs e) { var result = SaveData(); if (result.Item1) { ShowNotify("保存成功", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { ShowNotify(result.Item2, MessageBoxIcon.Error); } } (bool,string) SaveData() { try { var input = new Model.Welder_TestInfo(); input.CreatedDate = System.Convert.ToDateTime(txtCheckDate.Text); input.ProjectId = "0"; input.WeldMethodId = drpWeldMethod.SelectedValue; if (drpMaterialType.SelectedValue != Const._Null) { input.MaterialId = string.Join(",", drpMaterialType.SelectedValueArray); } input.Remark = txtRemark.Text.Trim(); input.IsPass = drpIsPass.SelectedValue == "是" ? true : false; if (string.IsNullOrEmpty(this.Id)) { input.WelderId = this.welderId; BLL.WelderTestService.Add(input); } else { input.Id = this.Id; BLL.WelderTestService.Edit(input); } return (true, "保存成功"); } catch (Exception ex) { BLL.ErrLogInfo.WriteLog(ex, "保存焊工考试结果失败"); return (false, ex.Message); } } } }