78 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			78 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Web;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI.WebControls;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.TestRun.Produce
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class InspectTemplateEdit : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 主键
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public string WorkInspectId
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get { return (string)ViewState["WorkInspectId"]; }
							 | 
						|||
| 
								 | 
							
								            set { ViewState["WorkInspectId"] = value; }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                this.WorkInspectId = Request.Params["WorkInspectId"];
							 | 
						|||
| 
								 | 
							
								                PageInit();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 默认绑定
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public void PageInit()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrWhiteSpace(this.WorkInspectId))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var model = Funs.DB.ProduceRun_WorkInspectTemplate.FirstOrDefault(x => x.WorkInspectId == this.WorkInspectId);
							 | 
						|||
| 
								 | 
							
								                txtWorkInspectName.Text = model.WorkInspectName;
							 | 
						|||
| 
								 | 
							
								                txtRemark.Text = model.Remark;
							 | 
						|||
| 
								 | 
							
								                txtSort.Text = model.Sort != null ? model.Sort.ToString() : (Funs.DB.ProduceRun_WorkInspectTemplate.Count() + 1).ToString();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                txtSort.Text = (Funs.DB.ProduceRun_WorkInspectTemplate.Count() + 1).ToString();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 保存
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        protected void btnSave_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            try
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var model = Funs.DB.ProduceRun_WorkInspectTemplate.FirstOrDefault(x => x.WorkInspectId == this.WorkInspectId);
							 | 
						|||
| 
								 | 
							
								                if (model == null) model = new Model.ProduceRun_WorkInspectTemplate();
							 | 
						|||
| 
								 | 
							
								                model.WorkInspectName = txtWorkInspectName.Text;
							 | 
						|||
| 
								 | 
							
								                model.Remark = txtRemark.Text;
							 | 
						|||
| 
								 | 
							
								                model.Sort = int.Parse(txtSort.Text);
							 | 
						|||
| 
								 | 
							
								                if (string.IsNullOrWhiteSpace(this.WorkInspectId))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    model.WorkInspectId = Guid.NewGuid().ToString();
							 | 
						|||
| 
								 | 
							
								                    model.AddUser = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                    model.AddTime = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								                    Funs.DB.ProduceRun_WorkInspectTemplate.InsertOnSubmit(model);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                Funs.DB.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								                ShowNotify("保存成功!", MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								                PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(this.WorkInspectId) + ActiveWindow.GetHidePostBackReference());
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            catch (Exception ex)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ShowNotify(ex.Message, MessageBoxIcon.Error);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |