using System;
using System.Linq;
using BLL;

namespace FineUIPro.Web.common.BaseInfo
{
    public partial class UnitView : PageBase
    {
        #region 加载页面
        /// <summary>
        /// 加载页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnClose.OnClientClick = ActiveWindow.GetHideReference();
                string unitId = Request.Params["UnitId"];

                if (!string.IsNullOrEmpty(unitId))
                {
                    var unit = BLL.Base_UnitService.GetUnit(unitId);
                    if (unit != null)
                    {
                        this.txtUnitCode.Text = unit.UnitCode;
                        this.txtUnitName.Text = unit.UnitName;
                        this.txtCorporate.Text = unit.Corporate;
                        this.txtTelephone.Text = unit.Telephone;
                        this.txtFax.Text = unit.Fax;
                        this.txtAddress.Text = unit.Address;
                        this.txtProjectRange.Text = unit.ProjectRange;
                        if (!string.IsNullOrEmpty(unit.UnitTypeId))
                        {
                            var unitType = (from x in Funs.DB.Base_UnitType where x.UnitTypeId == unit.UnitTypeId select x).FirstOrDefault();
                            if (unitType!=null)
                            {
                                this.txtUnitType.Text = unitType.UnitTypeName;
                            }
                        }
                    }
                }
            }
        }
        #endregion
    }
}