⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postresume.aspx.cs

📁 用AJAX做的一个在线求职系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
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 JobSiteStarterKit.BOL;

public partial class postresume_aspx : Page
{
    //定义简历类r
    private Resume r;
    protected void Page_Load(object sender, EventArgs e)
    {
        //判断当前用户是否属于jobseeker角色,如果不是,则重定向到NotAuthorized.aspx页面。
        if (!Roles.IsUserInRole(ConfigurationManager.AppSettings["jobseekerrolename"]))
        {
            Response.Redirect("~/customerrorpages/NotAuthorized.aspx");
        }
        //如果不是第一次打开页面。
        if (!Page.IsPostBack)
        {
            //从个性化属性中判断ResumeID属性值不为-1
            if (Profile.JobSeeker.ResumeID != -1)
            {
                //返回一个Resume类的实例
                r = Resume.GetResume(Profile.UserName);
                //使用Resume类的实例为相应的文本框赋值
                txtJobTitle.Text = r.JobTitle;
                txtCity.Text = r.City;
                txtResume.Text = r.ResumeText;
                txtCoveringLetter.Text = r.CoveringLetterText;
            }
            //填充国家选择下拉列表框
            FillCountries();
            //填充教育程度选择下拉列表框
            FillEduLevels();
            //填充经验程度选择下拉列表框
            FillExpLevels();
            //填充工作类型选择下拉列表框
            FillJobTypes();
            //填充省份选择下拉列表框
            FillStates();
        }
    }

    /// <summary>
    /// 填充国家列表到指定的DropDownList
    /// </summary>
    private void FillCountries()
    {
        //使用在Country类中定义的静态方法GetCountries获取包启国家的列表的DataSet,
        //并绑定到ddlCountry这个DropDownList控件。
        ddlCountry.DataSource = Country.GetCountries();
        ddlCountry.DataTextField = "CountryName";
        ddlCountry.DataValueField = "CountryID";
        ddlCountry.DataBind();
        //使用在Country类中定义的静态方法GetCountries获取包启国家的列表的DataSet,
        //并绑定到ddlRelocationCountry这个DropDownList控件。
        ddlRelocationCountry.DataSource = Country.GetCountries();
        ddlRelocationCountry.DataTextField = "CountryName";
        ddlRelocationCountry.DataValueField = "CountryID";
        ddlRelocationCountry.DataBind();
        //如果个性化中的ResumeID不为-1。
        if (Profile.JobSeeker.ResumeID != -1)
        {
            ListItem li;
            li = ddlCountry.Items.FindByValue(r.CountryID.ToString());
            if (li != null)
            {
                ddlCountry.ClearSelection();
                //将DropDownList中的选择项设置为相应的简历中的值
                li.Selected = true;
            }

            li = ddlRelocationCountry.Items.FindByValue(r.RelocationCountryID.ToString());
            if (li != null)
            {
                ddlRelocationCountry.ClearSelection();
                //将DropDownList中的选择项设置为相应的简历中的值
                li.Selected = true;
            }
        }
    }
    /// <summary>
    /// 填充省份列表到指定的DropDownList
    /// </summary>
    private void FillStates()
    {       
        //使用State类的静态方法GetStates获取指定国家的省名称。
        ddlState.DataSource = State.GetStates(int.Parse(ddlCountry.SelectedValue));
        ddlState.DataTextField = "StateName";
        ddlState.DataValueField = "StateID";
        ddlState.DataBind();
        //如果个性化中的ResumeID不为-1。
        if (Profile.JobSeeker.ResumeID != -1)
        {
            ListItem li;
            li = ddlState.Items.FindByValue(r.StateID.ToString());
            if (li != null)
            {
                ddlState.ClearSelection();
                //将DropDownList中的选择项设置为相应的简历中的值
                li.Selected = true;
            }
        }
    }
    /// <summary>
    /// 填充工作类型列表到指定的DropDownList中
    /// </summary>
    private void FillJobTypes()
    {
        //使用JobType类的静态方法GetJobTypes获取工作类型列表。
        ddlJobType.DataSource = JobType.GetJobTypes();
        ddlJobType.DataTextField = "JobTypeName";
        ddlJobType.DataValueField = "JobTypeID";
        ddlJobType.DataBind();
        //如果个性化中的ResumeID不为-1。
        if (Profile.JobSeeker.ResumeID != -1)
        {
            ListItem li;
            li = ddlJobType.Items.FindByValue(r.JobTypeID.ToString());
            if (li != null)
            {
                ddlJobType.ClearSelection();
                //将DropDownList中的选择项设置为相应的简历中的值
                li.Selected = true;
            }
        }
    }
    /// <summary>
    /// 填充教育程度列表到指定的DropDownList中
    /// </summary>
    private void FillEduLevels()
    {
        //使用EducationLevel类的静态方法GetEducationLevels获取教育程度列表。
        ddlEduLevel.DataSource = EducationLevel.GetEducationLevels();
        ddlEduLevel.DataTextField = "EducationLevelName";
        ddlEduLevel.DataValueField = "EducationLevelID";
        ddlEduLevel.DataBind();
        //如果个性化中的ResumeID不为-1。
        if (Profile.JobSeeker.ResumeID != -1)
        {
            ListItem li;
            li = ddlEduLevel.Items.FindByValue(r.EducationLevelID.ToString());
            if (li != null)
            {                
                ddlEduLevel.ClearSelection();
                //将DropDownList中的选择项设置为相应的简历中的值
                li.Selected = true;
            }
        }
    }
    /// <summary>
    /// 填充工作经验列表到指定的DropDownList中
    /// </summary>
    private void FillExpLevels()
    {
        //使用ExperienceLevel类的静态方法GetExperienceLevels获取经验程度列表。
        ddlExpLevel.DataSource = ExperienceLevel.GetExperienceLevels();
        ddlExpLevel.DataTextField = "ExperienceLevelName";
        ddlExpLevel.DataValueField = "ExperienceLevelID";
        ddlExpLevel.DataBind();
        //如果个性化中的ResumeID不为-1。
        if (Profile.JobSeeker.ResumeID != -1)
        {
            ListItem li;
            li = ddlExpLevel.Items.FindByValue(r.ExperienceLevelID.ToString());
            if (li != null)
            {
                ddlExpLevel.ClearSelection();
                //将DropDownList中的选择项设置为相应的简历中的值
                li.Selected = true;
            }
        }
    }


    protected void btnSave_Click(object sender, EventArgs e)
    {
        //创建Resume类的一个新实例
        Resume r = new Resume();
        //下面的代码从指定的控件中初始化该类属性。
        r.City = txtCity.Text;
        r.CountryID = int.Parse(ddlCountry.SelectedValue);
        r.CoveringLetterText = txtCoveringLetter.Text;
        r.EducationLevelID = int.Parse(ddlEduLevel.SelectedValue);
        r.ExperienceLevelID = int.Parse(ddlExpLevel.SelectedValue);
        r.JobTitle = txtJobTitle.Text;
        r.JobTypeID = int.Parse(ddlJobType.SelectedValue);
        r.RelocationCountryID = int.Parse(ddlRelocationCountry.SelectedValue);
        r.ResumeText = txtResume.Text;
        r.StateID = int.Parse(ddlState.SelectedValue);
        r.UserName = Profile.UserName;
        r.IsSearchable = "Y";
        r.PostedDate = DateTime.Now;
        //如果用户己经填写过简历
        if (Profile.JobSeeker.ResumeID != -1)
        {
            //为Resume类的ResumeID属性赋值
            r.ResumeID = Profile.JobSeeker.ResumeID;
            //更新该简历。
            Resume.Update(r);
        }
        else
        {
            //插入一个新的简历
            int retval=Resume.Insert(r);
            //将个性化设置中的ResumeID属性设为当前简历。
            Profile.JobSeeker.ResumeID = retval;
        }
        lblMsg.Text = "你的简历己经被成功保存!";
    }
    protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        FillStates();
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/default.aspx");
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -