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 WorkoPlus.BOL;
public partial class ApplyJob : System.Web.UI.Page
{
public string PostID
{
get { return ViewState["PostID"].ToString(); }
set { ViewState["PostID"] = value; }
}
public string CompanyEmailAddress
{
get { return ViewState["EmailAddress"].ToString(); }
set { ViewState["EmailAddress"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Title = "WorkSpecial [-- Job Search Engine --]";
PostID = Request.QueryString["id"];
GetData(Convert.ToInt32(PostID));
}
}
private void GetData(int PostID)
{
JobPosting jp = new JobPosting();
jp = JobPosting.GetPosting(PostID);
if (jp.ToString() != null || jp.ToString() != "")
{
Company cmp = Company.GetCompany(jp.CompanyID);
CompanyEmailAddress = cmp.Email;
//ContactPerson = jp.ContactPerson;
if (cmp.ToString() != null || cmp.ToString() != "")
{
lblCompany.Text = cmp.CompanyName; //ds.Tables[0].Rows[0]["CompanyName"];
}
lblContactPerson.Text = jp.ContactPerson;
lblJobTitle.Text = jp.Title;
lblDescription.Text = jp.Description;
string JobTypeName = JobType.GetJobTypeName(jp.JobTypeID);
if (JobTypeName != null || JobTypeName != "")
{
lblJobType.Text = JobTypeName;// ds.Tables[0].Rows[0]["JobTypeName"];
}
lblDepartment.Text = jp.Department;
string ProfIndus = LookUp.GetProfessionalIndustryNameByID(jp.ProfessionalIndustry);
if (ProfIndus != null || ProfIndus != "")
{
lblProfessionalIndustry.Text = ProfIndus;// ds.Tables[0].Rows[0]["Description"];
}
string Education = EducationLevel.GetEducationLevelName(jp.EducationLevelID);
if (Education != null || Education != "")
{
lblEducationLevel.Text = Education;// ds.Tables[0].Rows[0]["EducationLevelName"];
}
lblCity.Text = jp.City;
string state = State.GetStateName(jp.StateID);
if (state != null || state != "")
{
lblState.Text = state;// ds.Tables[0].Rows[0]["StateName"];
}
string country = Country.GetCountryName(jp.CountryID);
if (country != null || country != "")
{
lblCountry.Text = country;// ds.Tables[0].Rows[0]["CountryName"];
}
lblMinSalary.Text = string.Format("{0:$#,###}", jp.MinSalary);
lblMaxSalary.Text = string.Format("{0:$#,###}", jp.MaxSalary);
lblPostingDate.Text = jp.PostingDate.ToShortDateString();
}
}
protected void BtnApplyJob_Click(object sender, EventArgs e)
{
DataSet seekerobj = JobSeekerPersonalInformation.GetJobSeekerByName(Membership.GetUser().UserName);
Resume resobj = Resume.GetResume(Membership.GetUser().UserName);
string EmailAddress = seekerobj.Tables[0].Rows[0]["EmailAddress"].ToString();
string filename = resobj.ResumeFileName;
if (filename == "")
{
lblmessage.CssClass = "error";
lblmessage.Text = "Resume file is not uploaded!";
// error msg
}
else
{
string username = seekerobj.Tables[0].Rows[0]["FirstName"].ToString() + " " + seekerobj.Tables[0].Rows[0]["LastName"].ToString();//Membership.GetUser().UserName.ToString();
string subject = "Hello Mr." + lblContactPerson.Text.Trim() + ".
";
subject += "Mr." + username + " has applied for the post of " + lblJobTitle.Text.Trim() + ".
";
subject += "Hope you will find the required source for you job.
Best Regards,
WorkSpecial Team";
filename = Server.MapPath(ConfigurationManager.AppSettings["JobSeekerResumes"] + filename);
Helper.Mail(CompanyEmailAddress, "Workspecial.com", "postmaster@workspecial.com", subject, "Applicant [" + username + "] for the post of [" + lblJobTitle.Text + "]", filename, true);
subject = "";
subject = "Hello Mr." + username + ".
";
subject += "Your application has been sent for the post of " + lblJobTitle.Text.Trim() + ".
";
subject += "Hope you will find the job.
Best Regards,
WorkSpecial Team";
Helper.Mail(EmailAddress, "Workspecial.com", "postmaster@workspecial.com", subject,"Applied Mr.[" + username + "] for the post of [" + lblJobTitle.Text + "]", "",true);
AppliedJobs obj = new AppliedJobs();
obj.PostID = Convert.ToInt32(PostID);
obj.UserName = Membership.GetUser().UserName;
obj.ApplyDate = DateTime.Today.ToShortDateString();
AppliedJobs.Insert(obj);
lblmessage.CssClass = "text-blue";
lblmessage.Text = "Job applied successfully!";
}
}
protected void BtnBack_Click(object sender, EventArgs e)
{
Response.Redirect("index.aspx");
}
}