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.DriverSub
{
    public partial class DriverSubContactorEdit
: PageBase
    {
        #region  
        /// 
        /// 主键
        /// 
        public string DriverSubContractorsId
        {
            get
            {
                return (string)ViewState["DriverSubContractorsId"];
            }
            set
            {
                ViewState["DriverSubContractorsId"] = value;
            }
        }
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
                DrpSubcontractingType.DataSource = DropListService.drpDriverSubNameList();
                DrpSubcontractingType.DataTextField = "Text";
                DrpSubcontractingType.DataValueField = "Value";
                DrpSubcontractingType.DataBind();
                this.DriverSubContractorsId = Request.Params["DriverSubContractorsId"];
                if (!string.IsNullOrEmpty(this.DriverSubContractorsId))
                {
                    Model.DriverSub_DriverSubContractors model = BLL.DriversubcontractorsService.GetDriverSub_DriverSubContractorsById(this.DriverSubContractorsId);
                    if (model != null)
                    {
                        this.txtSubUnitName.Text = model.SubUnitName;
                        this.txtEnterpriseNature.Text = model.EnterpriseNature;
                        this.DrpSubcontractingType.SelectedValue = model.SubcontractingType;
                        this.txtCollCropCode.Text = model.CollCropCode;
                        this.txtSafetyProductionLicense.Text = model.SafetyProductionLicense;
                        this.txtQualificationCertificateNumber.Text = model.QualificationCertificateNumber;
                        this.txtQualificationType.Text = model.QualificationType;
                        this.txtQualificationLevel.Text = model.QualificationLevel;
                        this.txtProvince.Text = model.Province;
                        this.txtCity.Text = model.City; 
                    }
                }
            }
        }
        /// 
        /// 保存按钮
        /// 
        /// 
        /// 
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Model.DriverSub_DriverSubContractors table = new Model.DriverSub_DriverSubContractors();
            table.SubUnitName = this.txtSubUnitName.Text;
            table.EnterpriseNature = this.txtEnterpriseNature.Text;
            table.SubcontractingType = this.DrpSubcontractingType.SelectedValue;
            table.CollCropCode = this.txtCollCropCode.Text;
            table.SafetyProductionLicense = this.txtSafetyProductionLicense.Text;
            table.QualificationCertificateNumber = this.txtQualificationCertificateNumber.Text;
            table.QualificationType = this.txtQualificationType.Text;
            table.QualificationLevel = this.txtQualificationLevel.Text;
            table.Province = this.txtProvince.Text;
            table.City = this.txtCity.Text; 
            if (string.IsNullOrEmpty(this.DriverSubContractorsId))
            {
                table.DriverSubContractorsId = SQLHelper.GetNewID(typeof(Model.DriverSub_DriverSubContractors));
                BLL.DriversubcontractorsService.AddDriverSub_DriverSubContractors(table);
            }
            else
            {
                table.DriverSubContractorsId = this.DriverSubContractorsId;
                BLL.DriversubcontractorsService.UpdateDriverSub_DriverSubContractors(table);
            }
            PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
        }
    }
}