using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.ZHGL.Person
{
    public partial class BranchPersonView : PageBase
    {
        #region 定义项
        /// 
        /// 用户主键
        /// 
        public string CompanyBranchPersonId
        {
            get
            {
                return (string)ViewState["CompanyBranchPersonId"];
            }
            set
            {
                ViewState["CompanyBranchPersonId"] = value;
            }
        }
        /// 
        /// 单位主键
        /// 
        public string UnitId
        {
            get
            {
                return (string)ViewState["UnitId"];
            }
            set
            {
                ViewState["UnitId"] = value;
            }
        }
        #endregion
        /// 
        /// 用户编辑页面
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
                string type = Request.Params["type"];
                BLL.UnitService.InitNoThisAllUnitDownList(this.drpUnit, true);
                this.CompanyBranchPersonId = Request.Params["CompanyBranchPersonId"];
                WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, true);
                if (!string.IsNullOrEmpty(this.CompanyBranchPersonId))
                {
                    var CompanyBranchPerson = BLL.CompanyBranchPersonService.GetCompanyBranchPersonById(this.CompanyBranchPersonId);
                    if (CompanyBranchPerson != null)
                    {
                        this.hdCompanyBranchPersonId.Text = this.CompanyBranchPersonId;
                        if (!string.IsNullOrEmpty(CompanyBranchPerson.UnitId))
                        {
                            this.drpUnit.SelectedValue = CompanyBranchPerson.UnitId;
                        }
                        this.txtPersonName.Text = CompanyBranchPerson.PersonName;
                        if (!string.IsNullOrEmpty(CompanyBranchPerson.Sex))
                        {
                            this.rblSex.SelectedValue = CompanyBranchPerson.Sex;
                        }
                        this.txtIdentityCard.Text = CompanyBranchPerson.IdentityCard;
                        if (!string.IsNullOrEmpty(CompanyBranchPerson.WorkPostId))
                        {
                            this.drpWorkPost.SelectedValue = CompanyBranchPerson.WorkPostId;
                        }
                        this.txtTelephone.Text = CompanyBranchPerson.Telephone;
                        this.txtAddress.Text = CompanyBranchPerson.Address;
                        if (CompanyBranchPerson.IsOnJob == true)
                        {
                            this.rblIsOnJob.SelectedValue = "True";
                        }
                        else
                        {
                            this.rblIsOnJob.SelectedValue = "False";
                        }
                        this.txtRemark.Text = CompanyBranchPerson.Remark;
                    }
                }
            }
        }
        #region 附件上传
        /// 
        /// 上传附件
        /// 
        /// 
        /// 
        protected void btnAttachUrl_Click(object sender, EventArgs e)
        {
            PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/BranchPersonAttachUrl&menuId={1}&type=-1", this.hdCompanyBranchPersonId.Text, BLL.Const.BranchPersonMenuId)));
        }
        #endregion
    }
}