using BLL;
using BLL.CQMS.Comprehensive;
using System;
using System.Linq;
namespace FineUIPro.Web.HJGL.FL
{
    public partial class HJGLDataEdit : PageBase
    {
        #region 定义变量
        /// 
        /// 主键
        /// 
        public string Id
        {
            get
            {
                return (string)ViewState["Id"];
            }
            set
            {
                ViewState["Id"] = value;
            }
        }
        #endregion
        #region 加载
        /// 
        /// 加载页面
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Id = Request.Params["Id"];
                Model.HJGL_FL_Data data = BLL.FLDataService.GetDataById(this.Id);
                if (data != null)
                {
                    this.Id = data.Id;
                    this.txtTotalWeldQuantity.Text = data.TotalWeldQuantity;
                    this.txtTotalCompleted.Text = data.TotalCompleted;
                    this.txtTotalWeldQuantity.Text = data.TotalWeldQuantity;
                    this.txtOneTimeFilmAmount.Text = data.OneTimeFilmAmount;
                    this.txtOneTimeFilmQualifiedAmount.Text = data.OneTimeFilmQualifiedAmount;
                }
            }
        }
        #endregion
        #region 保存
        /// 
        /// 保存按钮
        /// 
        /// 
        /// 
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Model.HJGL_FL_Data data = new Model.HJGL_FL_Data();
            data.ProjectId = this.CurrUser.LoginProjectId;
            data.TotalWeldQuantity = this.txtTotalWeldQuantity.Text.Trim();
            data.TotalCompleted = this.txtTotalCompleted.Text.Trim();
            data.OneTimeFilmAmount = this.txtOneTimeFilmAmount.Text.Trim();
            data.OneTimeFilmQualifiedAmount = this.txtOneTimeFilmQualifiedAmount.Text.Trim();
            data.CompileMan = this.CurrUser.UserId;
            data.CompileDate = DateTime.Now;
            if (string.IsNullOrEmpty(this.Id))
            {
                data.Id = SQLHelper.GetNewID(typeof(Model.Comprehensive_DesignDetails));
                BLL.FLDataService.AddData(data);
            }
            else
            {
                data.Id = this.Id;
                BLL.FLDataService.UpdateData(data);
            }
            ShowNotify("保存成功!", MessageBoxIcon.Success);
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        #endregion
    }
}