protected void btnJobApply_Click(object sender, EventArgs e)
{
if (Session["ap_id"] == null)
Response.Redirect("applicantsLogin.aspx");
if (Page.IsValid)
{
string applicantJob = "";
con.Open();
String queryA = "SELECT j_id FROM tbl_vacanciesapplied WHERE j_id = '" + applicantJob + "' ";
SqlCommand cmdA = new SqlCommand(queryA, con);
SqlDataReader drA = cmdA.ExecuteReader();
if (drA.Read())
{
string message = " You already apply for this job.";
string url = "jobDescription.aspx";
string script = "window.onload = function(){ if(alert('";
script += message;
script += "'));";
script += "window.location = '";
script += url;
script += "'; }";
ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);
}
else
{
int jobID = Convert.ToInt32(Request.QueryString["j_id"]);
int applicantID = Convert.ToInt32(Session["ap_id"]);
try
{
string query = "applyvacancy";
SqlCommand cmdVacancy = new SqlCommand(query, con);
cmdVacancy.CommandType = CommandType.StoredProcedure;
cmdVacancy.Parameters.Add("@v_statusupdate", SqlDbType.NVarChar).Value = "Unprocess";
cmdVacancy.Parameters.Add("@j_id", SqlDbType.Int).Value = jobID;
cmdVacancy.Parameters.Add("@ap_id", SqlDbType.Int).Value = applicantID;
cmdVacancy.Parameters.Add("@v_dateapply", SqlDbType.DateTime).Value = now;
cmdVacancy.ExecuteNonQuery();
Response.Redirect("submitJob.aspx");
con.Close();
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
}
}
Hi, regarding to the coding, how to write condition that user cannot apply the same job
twice or more within the same time frame.This is because he/she already applied the
job before. Do I need to check jobId = applicantId. I already done but its not working or
maybe I'm missed out few step. Kindly advise for me. Currently I am developing a job application
system like "Jobstreet". Thank you