/*
'' ============================================================================================
'' 项目名称：风越项目范例ASPX普通三层结构
'' 项目版本：V1.0
'' 项目描述：风越项目范例，用于建立ASPX普通三层结构
'' 文件名称：YongHuXinXi_detail.aspx
'' 文件描述：信息详情文件 （用户信息）
'' 公司名称：中极网盛
'' 开发人员：刘怒
'' 创建日期：2008-12-25 20:23:50
'' 修订日期：2009-03-10 06:05:40
'' 版权信息：Copyright (C) 2008

'' 项目升级时需读取以下生成工具的版权信息
'' 生成工具：风越代码生成器 [FireCode Creator]
'' 当前版本：通用版 V1.8
'' 官方网站：http://www.sino8848.com
'' ============================================================================================
*/

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FypSystem.Common;
using FypSystem.DBManager;

namespace Fyp_3TierCommon.Web
{
    public partial class YongHuXinXi_detail : System.Web.UI.Page
    {
        
        int req_USER_ID; 
        string req_USER_NAME; 

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = WebPage.GetConfig("fypWebName");

            if (!StringExtend.IsEmpty(this.Request.QueryString["USER_ID"]) && !StringExtend.IsEmpty(this.Request.QueryString["USER_NAME"]))
            {
            
                
                
                req_USER_ID = int.Parse(this.Request.QueryString["USER_ID"]);
                

                
                
            
                
                

                
                
                req_USER_NAME = this.Request.QueryString["USER_NAME"];
                
            
            }
            if (StringExtend.IsEmpty(req_USER_ID) || StringExtend.IsEmpty(req_USER_NAME))
            {
                //如找不到指定记录，提示
                FypSystem.Common.WebPage.JsAlert(this, "未指定合法的参数！");
            }
            else if (!this.Page.IsPostBack)
            {
                Initialize();
            }
        }

        /// <summary>
        /// 读取数据库指定记录
        /// </summary>
        /// <returns></returns>
        private Fyp_3TierCommon.Model.Model_USER GetModelData()
        {
            Fyp_3TierCommon.Model.Model_USER model_USER = new Fyp_3TierCommon.BLL.BLL_USER().GetModel(req_USER_ID, req_USER_NAME);

            return model_USER;
        }

        /// <summary>
        /// 导入默认值、数据
        /// </summary>
        private void Initialize()
        {
            Fyp_3TierCommon.Model.Model_USER model_USER = GetModelData();
            if (model_USER != null)
            {
                try
                {
					string strValue;
            
                    strValue = "";
                
                    if (model_USER.USER_ID != null)
    					strValue = model_USER.USER_ID.ToString();
                

                

                    

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_ID_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                    strValue = "";
                
                    if (model_USER.USER_NAME != null)
    					strValue = model_USER.USER_NAME.ToString();
                

                

                    

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_NAME_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                    strValue = "";
                
                    if (model_USER.USER_PWD != null)
    					strValue = model_USER.USER_PWD.ToString();
                

                

                    

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_PWD_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                    strValue = "";
                
                    if (model_USER.USER_EMAIL != null)
    					strValue = model_USER.USER_EMAIL.ToString();
                

                

                    

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_EMAIL_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                    strValue = "";
                
                    if (model_USER.USER_BIRTHDAY != null)
    					strValue = model_USER.USER_BIRTHDAY.ToString();
                

                

                    
                    strValue = RegExp.RegMatch(@"([^\s]+)", strValue, "$1", true);

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_BIRTHDAY_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                    strValue = "";
                
                    if (model_USER.USER_PHOTO != null)
    					strValue = model_USER.USER_PHOTO.ToString();
                

                

                    

                    

                    

                    

                    

                    

                    

                    

                    
                        
                    if (strValue.Length > 0)
                        strValue = "<img src='" + strValue + "'>";
                        
                    

                    
					

                    
                    this.lab_USER_PHOTO_Show.Text = strValue;
                    
            
                    strValue = "";
                

                

                    

                    

                    

                    
                    if (FypSystem.Common.StringExtend.IsEmpty(strValue))
                        this.btn_USER_PHOTOS2_file.Visible = false;
                    //else
                        //strValue = "";
                    

                    

                    

                    

                    

                    
                        
                    

                    
					

                    
                    this.lab_USER_PHOTOS2_Show.Text = strValue;
                    
            
                    strValue = "";
                
                    if (model_USER.USER_NATION != null)
    					strValue = model_USER.USER_NATION.ToString();
                

                
                    if (strValue.Length > 0)
                    {
                        Fyp_3TierCommon.Model.Model_NATION model_NATION = new Fyp_3TierCommon.BLL.BLL_NATION().GetModel(model_USER.USER_NATION);
                        if (model_NATION != null && model_NATION.NATION_NAME != null)
                            strValue = model_NATION.NATION_NAME.ToString();
                    }
                

                    

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_NATION_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                    strValue = "";
                
                    if (model_USER.USER_COUNTRY != null)
    					strValue = model_USER.USER_COUNTRY.ToString();
                

                
                    if (strValue.Length > 0)
                    {
                        Fyp_3TierCommon.Model.Model_COUNTRY model_COUNTRY = new Fyp_3TierCommon.BLL.BLL_COUNTRY().GetModel(model_USER.USER_COUNTRY);
                        if (model_COUNTRY != null && model_COUNTRY.COUNTRY_CN != null)
                            strValue = model_COUNTRY.COUNTRY_CN.ToString();
                    }
                

                    

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_COUNTRY_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                    strValue = "";
                
                    if (model_USER.USER_PROVINCE != null)
    					strValue = model_USER.USER_PROVINCE.ToString();
                

                
                    if (strValue.Length > 0)
                    {
                        Fyp_3TierCommon.Model.Model_PROVINCE model_PROVINCE = new Fyp_3TierCommon.BLL.BLL_PROVINCE().GetModel(model_USER.USER_PROVINCE);
                        if (model_PROVINCE != null && model_PROVINCE.PROVINCE_CN != null)
                            strValue = model_PROVINCE.PROVINCE_CN.ToString();
                    }
                

                    

                    

                    

                    

                    

                    

                    

                    

                    

                    
					
                    this.lab_USER_PROVINCE_Show.Text = WebString.HtmlEncodeExtend(strValue);
                    

                    
            
                }
                catch (System.Exception err)
                {
                    FypSystem.Common.WebPage.JsAlert(this, err.Message);
                }
            }
            else
            {
                //找不到指定记录时
                FypSystem.Common.WebPage.JsAlert(this, "未找到指定记录！");
            }
        }

        
        
        protected void btn_USER_PHOTOS2_file_Click(object sender, EventArgs e)
        {
            DownLoadFile("USER_PHOTOS2" + req_USER_ID + "_" + req_USER_NAME, "USER_PHOTOS2");
        }
        
        

        
        //下载文件
        private void DownLoadFile(string strFileName, string strFieldName)
        {
            Fyp_3TierCommon.Model.Model_USER model_USER = GetModelData();
            if (model_USER != null)
            {
                strFileName = this.Server.UrlPathEncode(strFileName);
                FypSystem.Common.FileSys fileSys = new FileSys();
            
                
                if (strFieldName == "USER_PHOTOS2")
                    fileSys.DownloadFileInDB(strFileName, (byte[])model_USER.USER_PHOTOS2);
                
            
            }
        }
        
    }
}