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.JDGL.Check
{
    public partial class LowTankCompletionEdit : PageBase
    {
        /// 
        /// id
        /// 
        public string LowTankCompletionId
        {
            get
            {
                return (string)ViewState["LowTankCompletionId"];
            }
            set
            {
                ViewState["LowTankCompletionId"] = value;
            }
        }
        /// 
        /// 项目id
        /// 
        public string ProjectId
        {
            get
            {
                return (string)ViewState["ProjectId"];
            }
            set
            {
                ViewState["ProjectId"] = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
                LowTankCompletionId = Request.Params["LowTankCompletionId"];
                if (!string.IsNullOrEmpty(LowTankCompletionId))
                {
                    Model.JDGL_LowTankCompletion LowTankCompletion = BLL.LowTankCompletionService.GetLowTankCompletionById(LowTankCompletionId);
                    if (LowTankCompletion != null)
                    {
                        this.ProjectId = LowTankCompletion.ProjectId;
                        if (LowTankCompletion.PlanNum != null)
                        {
                            this.txtPlanNum.Text = LowTankCompletion.PlanNum.ToString();
                        }
                        if (LowTankCompletion.RealNum != null)
                        {
                            this.txtRealNum.Text = LowTankCompletion.RealNum.ToString();
                        }
                    }
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SaveData(true);
        }
        private void SaveData(bool bl)
        {
            string LowTankCompletionId = Request.Params["LowTankCompletionId"];
            Model.JDGL_LowTankCompletion LowTankCompletion = new Model.JDGL_LowTankCompletion();
            if (!string.IsNullOrEmpty(this.txtPlanNum.Text.Trim()))
            {
                LowTankCompletion.PlanNum = Convert.ToDecimal(this.txtPlanNum.Text.Trim());
            }
            if (!string.IsNullOrEmpty(this.txtRealNum.Text.Trim()))
            {
                LowTankCompletion.RealNum = Convert.ToDecimal(this.txtRealNum.Text.Trim());
            }
            if (!string.IsNullOrEmpty(LowTankCompletionId))
            {
                LowTankCompletion.LowTankCompletionId = LowTankCompletionId;
                BLL.LowTankCompletionService.UpdateLowTankCompletion(LowTankCompletion);
            }
            else
            {
                LowTankCompletion.LowTankCompletionId = SQLHelper.GetNewID(typeof(Model.JDGL_LowTankCompletion));
                BLL.LowTankCompletionService.AddLowTankCompletion(LowTankCompletion);
            }
            ShowNotify("保存成功!", MessageBoxIcon.Success);
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
    }
}