using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
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 JuSNS.Model;
using JuSNS.Home;
using JuSNS.UI.Control;
using JuSNS.Common;

namespace JuSNS.Web.home.friend
{
    public partial class req : JuSNS.UI.Page.UserPage
    {
        public int myUid = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            myUid = this.UserID;
            BindData();
        }

        /// <summary>
        /// 分页绑定数据
        /// </summary>
        protected void BindData()
        {
            int ReCount, PgCount;
            int PageIndex = 1;
            if (Request.QueryString["Page"] != null)
                PageIndex = Convert.ToInt32(Request.QueryString["Page"]);
            DataTable dt = UtilPage.GetPage("Friend_Request", PageIndex, PAGESZ, out ReCount, out PgCount, new SqlConditionInfo("@Receiver", UserID, TypeCode.Int32));
            this.RptData.DataSource = dt;
            this.RptData.DataBind();
            if (ReCount > 0)
                this.LtrTitle.Text = "你有 " + ReCount + " 个好友请求";
            else
                this.LtrTitle.Text = "你没有好友请求";
            if (ReCount > PAGESZ)
            {
                this.DivPage.InnerHtml = PageNavigator.Pagination(PageIndex, PgCount, "req.aspx");
            }
            else
            {
                this.DivPage.Visible = false;
            }
        }

        protected string getDesc(object fid)
        {
            string s_desc = string.Empty;
            return s_desc;
        }

        protected string GetHeadPic(object userID)
        {
            return GetHeadImage(Convert.ToInt32(userID.ToString()), 1);
        }

        /// <summary>
        /// 取得会员教育信息
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <returns></returns>
        protected string getSchool(object UserID)
        {
            string s_School = string.Empty;
            string s_Academy = string.Empty;
            string s_DateTime = string.Empty;
            JuSNS.Home.User user = new JuSNS.Home.User();
            UserEducationInfo educinfo = new UserEducationInfo();
            educinfo = user.LastEducInfo(Convert.ToInt32(UserID));
            DictSchoolInfo schoolinfo = new DictSchoolInfo();
            schoolinfo = user.GetSchoolInfo(educinfo.SchoolID);

            if (educinfo.DegreeID >= 3 && educinfo.AcademyID != 0)
            {
                DictAcademyInfo AcademyInfo = new DictAcademyInfo();
                AcademyInfo = user.GetAcademyInfo(educinfo.AcademyID);
                s_Academy = " - " + AcademyInfo.Name;
            }
            else
            {
            }
            if (educinfo.DegreeID > 0)
            {
                if (educinfo.MatriculationYear > 0)
                {
                    s_School = "<div class=\"cpstr\">[" + getDegreeName(educinfo.DegreeID) + "]" +schoolinfo.SchoolName + s_Academy + "<span class=\"time\">(" + educinfo.MatriculationYear.ToString() + "年入学)</span></div>";
                }
                else
                {
                    s_School = "<div class=\"cpstr\">[" + getDegreeName(educinfo.DegreeID) + "]" + schoolinfo.SchoolName + s_Academy +"</div>";
                }
            }
            return s_School;
        }

        /// <summary>
        /// 取得学历类型
        /// </summary>
        /// <param name="DegreeID">编号</param>
        /// <returns></returns>
        protected string getDegreeName(int DegreeID)
        {
            string s_DegreeName = "";
            switch (DegreeID)
            {
                case 1:
                    s_DegreeName = "初中";
                    break;
                case 2:
                    s_DegreeName = "高中";
                    break;
                case 3:
                    s_DegreeName = "大学";
                    break;
                case 4:
                    s_DegreeName = "研究生";
                    break;
                case 5:
                    s_DegreeName = "博士";
                    break;
            }
            return s_DegreeName;
        }
    }
}
