protected void DeleteBtn_Click(object sender, EventArgs e) { string connetionString; SqlConnection cnn; connetionString = @"Data Source=DESKTOP-NCLVKS1;Initial Catalog=E-Employment ;User ID=sa;Password=allohomora"; String sql; cnn = new SqlConnection(connetionString); SqlCommand command; cnn.Open(); sql = "Update Job set Status='Deleted' where [Job Id] = @jobid"; command = new SqlCommand(sql, cnn); HiddenField jobid = (HiddenField)VJFormView.FindControl("JobId"); command.Parameters.AddWithValue("jobid", jobid.Value); command.ExecuteNonQuery(); sql = "Update Application set Status='Rejected' where [JobId]=@jobid"; command = new SqlCommand(sql, cnn); command.Parameters.AddWithValue("jobid", jobid.Value); command.ExecuteNonQuery(); cnn.Close(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Job Deleted Successfully')", true); Response.Redirect("Jobs.aspx"); }
protected void VSABtn_Click(object sender, EventArgs e) { HiddenField jobid = (HiddenField)VJFormView.FindControl("JobId"); Session["currentjob"] = jobid.Value; Response.Redirect("ViewSelectedApplicant.aspx"); }
protected void ApplyBtn_Click(object sender, EventArgs e) { string connetionString; SqlConnection cnn; connetionString = @"Data Source=DESKTOP-NCLVKS1;Initial Catalog=E-Employment ;User ID=sa;Password=allohomora"; String sql; cnn = new SqlConnection(connetionString); SqlCommand command, command1; cnn.Open(); sql = "Insert into Application (JobId,SeekerId,Status) values(@jobid,@seekerid,@status) "; command = new SqlCommand(sql, cnn); HiddenField jobid = (HiddenField)VJFormView.FindControl("JobId"); command.Parameters.AddWithValue("@jobid", jobid.Value); command.Parameters.AddWithValue("@seekerid", Session["Username"]); command.Parameters.AddWithValue("@status", "Pending"); sql = "Select * from Application where SeekerId=@seekerid and JobId=@jobid"; command1 = new SqlCommand(sql, cnn); command1.Parameters.AddWithValue("@seekerid", Session["Username"]); command1.Parameters.AddWithValue("@jobid", jobid.Value); SqlDataAdapter sda1 = new SqlDataAdapter(command1); DataTable dt1 = new DataTable(); sda1.Fill(dt1); if (dt1.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Failed : Already applied')", true); } else { sql = "Update Job set [Application Count]=[Application Count]+1 where [Job Id]=@jobid"; command1 = new SqlCommand(sql, cnn); command1.Parameters.AddWithValue("@jobid", jobid.Value); SqlDataAdapter sda2 = new SqlDataAdapter(command1); DataTable dt2 = new DataTable(); sda2.Fill(dt2); command.ExecuteNonQuery(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Applied Successfully')", true); } cnn.Close(); }