protected void btnExtendAdvert_Click(object sender, EventArgs e) { dataAccess database = new dataAccess(); advertiser post = new advertiser(); string totalUnits = post.GetUnitCountByEmail(User.Identity.Name); int unitAmount = 0; double addDate = 0; if (ddlAdvertLength.SelectedValue.ToString() == "15") { addDate = 15; unitAmount = 1; } else if (ddlAdvertLength.SelectedValue.ToString() == "30") { addDate = 30; unitAmount = 2; } DateTime expiryDate = post.GetExpireDateByJobPostID(GridView1.SelectedValue.ToString()); bool flag = post.DepleteUnitsByEmail(unitAmount, User.Identity.Name); //Redirect user to success page if (flag) { database.updateData("UPDATE jobsdb_JobPost SET ExpireDate ='" + string.Format("{0:yyyy/MM/dd}", expiryDate.AddDays(addDate)) + "' WHERE ID='" + GridView1.SelectedValue.ToString() + "'"); Response.Redirect("PostSuccessfull.aspx?PostID=" + GridView1.SelectedValue.ToString() + "&type=e&amt=" + unitAmount.ToString() + "&units=" + totalUnits); } else { Response.Redirect("PostFailed.aspx"); } }
protected void btnPurchaseDetails_Click(object sender, EventArgs e) { string jobseekerID = Request.QueryString["id"].ToString(); advertiser purchase = new advertiser(); int unitAmount = 1; string totalUnits = purchase.GetUnitCountByEmail(User.Identity.Name); try { bool flag = purchase.DepleteUnitsByEmail(unitAmount, User.Identity.Name); //Redirect user to success page if (flag) { purchase.PurchaseJobseeker(jobseekerID, User.Identity.Name); Response.Redirect("PurchasedJobseekerDetail.aspx?id=" + jobseekerID + "&units=" + totalUnits + "&amt=" + unitAmount); } else { Response.Redirect("PurchaseFailure.aspx"); } } catch (SqlException) { Response.Redirect("PurchaseFailure.aspx"); } }
protected void btnPost_Click(object sender, EventArgs e) { SqlConnection connString = new SqlConnection(ConfigurationManager.ConnectionStrings["ZamJobsConnString"].ConnectionString); string title = txtJobTitle.Text; string overview = txtJobOverview.Text; string companyEmail = User.Identity.Name; dataAccess advertiser = new dataAccess(); advertiser post = new advertiser(); string totalUnits = post.GetUnitCountByEmail(User.Identity.Name); DataTable IdTbl = advertiser.getTable("SELECT ID FROM jobsdb_Employer WHERE email = '" + companyEmail + "'"); Int16 companyID = Convert.ToInt16(IdTbl.Rows[0]["ID"]); Int16 country = Convert.ToInt16(ddlCountry.SelectedValue); Int16 region = 0; if (ddlRegion.SelectedValue != "") { region = Convert.ToInt16(ddlRegion.SelectedValue); } Int16 location = 0; if (ddlLocation.SelectedValue != "") { location = Convert.ToInt16(ddlLocation.SelectedValue); } Int16 type = Convert.ToInt16(ddlJobType.SelectedValue); Int16 category = Convert.ToInt16(ddlCategory.SelectedValue); Int16 jobType = Convert.ToInt16(ddlJobType.SelectedValue); Int16 experience = Convert.ToInt16(ddlWorkExperience.SelectedValue); string exerienceComment = txtWorkExperience.Text; Int16 education = Convert.ToInt16(ddlEducation.SelectedValue); string educationComment = txtEducation.Text; string personalAttributes = txtPesonalAttributes.Text; string competencies = txtCompetencies.Text; string postDate = string.Format("{0:yyyy/MM/dd}", DateTime.Today); int unitAmount = 0; string expiryDate = string.Format("{0:yyyy/MM/dd}", DateTime.Now.AddDays(Convert.ToDouble(ddlAdvertLength.SelectedValue.ToString()))); if (ddlAdvertLength.SelectedValue.ToString() == "15") { unitAmount = 1; } else if (ddlAdvertLength.SelectedValue.ToString() == "30") { unitAmount = 2; } // create query string to insert data in database string insertString = @" insert into jobsdb_JobPost (Title,Overview,Company,Country,Region,Location,Category,Type, WorkExperience,WorkExperienceComment,EducationLevel,EducationLevelComment,PersonalAttributes,Competencies,PostDate,ExpireDate) values ('" + title + "','" + overview + "','" + companyID + "','" + country + "','" + region + "','" + location + "','" + category + "','" + type + "','" + experience + "','" + exerienceComment + "','" + education + "','" + educationComment + "','" + personalAttributes + "','" + competencies + "','" + postDate + "','" + expiryDate + "'); SELECT SCOPE_IDENTITY()"; try { bool flag = post.DepleteUnitsByEmail(unitAmount, User.Identity.Name); //Redirect user to success page if (flag) { //SqlCommand cmd = new SqlCommand(insertString, connString); Int64 id = advertiser.insertData_ReturnID(insertString); //connString.Open(); // Call ExecuteNonQuery to send command //cmd.ExecuteNonQuery(); //connString.Close(); Response.Redirect("PostSuccessfull.aspx?PostID=" + id + "&type=n&amt=" + unitAmount.ToString() + "&units=" + totalUnits); } else { } } catch (SqlException) { Response.Redirect("PostUnsuccessfull.aspx"); } }