protected void EditCategories_Click(object sender, EventArgs e) { try { PRMS controller = new PRMS(); controller.DeleteUserCategories(CurrentUserID); #region add professions List<int> professions = (List<int>)Session["professions"]; foreach (int profession in professions) { controller.AddUserProfessions(CurrentUserID, profession); } #endregion #region add skills List<int> skills = (List<int>)Session["skills"]; foreach (int skill in skills) { controller.AddUserSkills(CurrentUserID, skill); } #endregion #region add regions List<int> regions = (List<int>)Session["regions"]; foreach (int region in regions) { controller.AddUserRegions(CurrentUserID, region); } #endregion ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Categories have been updated successfully.')", true); } catch { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(‘Error occurred with udpating categories. Please contact customer support for assistance if this issue persists.’)", true); } }
protected void Submit_Click(object sender, EventArgs e) { try { List <int> list; bool dropdownsChecked = true; list = (List <int>)Session["professions"]; if (list == null) { dropdownsChecked = false; } list = (List <int>)Session["skills"]; if (list == null) { dropdownsChecked = false; } list = (List <int>)Session["regions"]; if (list == null) { dropdownsChecked = false; } if (dropdownsChecked) { bool success = false; User newCandidate = new User(); newCandidate.UserEmail = EmailTextBox.Text; newCandidate.FirstName = FirstName.Text; newCandidate.LastName = LastName.Text; newCandidate.Phone = Phone.Text; newCandidate.Resume = (ResumeUpload.PostedFile.FileName == "") ? null : ResumeUpload.PostedFile.FileName; newCandidate.CoverLetter = (CoverLetterUpload.PostedFile.FileName == "") ? null : CoverLetterUpload.PostedFile.FileName; newCandidate.UserPassword = Password.Text; PRMS controller = new PRMS(); #region add user success = controller.AddAccount(newCandidate); if (success) { int userID; userID = controller.GetUserIDByEmail(EmailTextBox.Text); if (ResumeUpload.HasFile) { string fileExtension = Path.GetExtension(ResumeUpload.PostedFile.FileName); if (fileExtension == ".pdf" || fileExtension == ".docx") { Directory.CreateDirectory(Server.MapPath("~/Files/" + userID + "/Resume/")); DirectoryInfo directory = new DirectoryInfo(Server.MapPath("~/Files/" + userID + "/Resume/")); foreach (FileInfo file in directory.GetFiles()) { file.Delete(); } foreach (DirectoryInfo di in directory.GetDirectories()) { di.Delete(true); } ResumeUpload.SaveAs(Server.MapPath("~/Files/" + userID + "/" + "Resume/" + ResumeUpload.FileName)); } else { Msg.Text = "Only .pdf and .docx resume files are accepted."; } } if (CoverLetterUpload.HasFile) { string fileExtension = Path.GetExtension(CoverLetterUpload.PostedFile.FileName); if (fileExtension == ".pdf" || fileExtension == ".docx") { Directory.CreateDirectory(Server.MapPath("~/Files/" + userID + "/CoverLetter/")); DirectoryInfo directory = new DirectoryInfo(Server.MapPath("~/Files/" + userID + "/CoverLetter/")); foreach (FileInfo file in directory.GetFiles()) { file.Delete(); } foreach (DirectoryInfo di in directory.GetDirectories()) { di.Delete(true); } CoverLetterUpload.SaveAs(Server.MapPath("~/Files/" + userID + "/" + "CoverLetter/" + CoverLetterUpload.FileName)); } else { Msg.Text = "Only .pdf and .docx cover letter files are accepted."; } } #region add professions int newUserID; newUserID = controller.GetUserIDByEmail(EmailTextBox.Text); List <int> professions = (List <int>)Session["professions"]; foreach (int profession in professions) { controller.AddUserProfessions(newUserID, profession); } #endregion #region add skills List <int> skills = (List <int>)Session["skills"]; foreach (int skill in skills) { controller.AddUserSkills(newUserID, skill); } #endregion #region add regions List <int> regions = (List <int>)Session["regions"]; foreach (int region in regions) { controller.AddUserRegions(newUserID, region); } #endregion #region send email using (SmtpClient smtpClient = new SmtpClient()) { string email = EmailTextBox.Text; string firstName = FirstName.Text; MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress(email); MailMessage message = new MailMessage(from, to); message.Subject = "Placemejob Account Registration"; string note = "Dear " + firstName + ",<br /><br />"; note += "Thank you for your application on Placemejob. We shall check your profile with relevant openings and get back to you."; message.Body = note; message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; SmtpClient client = new SmtpClient("smtp.gmail.com", 25); client.UseDefaultCredentials = false; client.EnableSsl = true; client.Credentials = new NetworkCredential("*****@*****.**", "mejob986"); try { client.Send(message); } catch { Results.Text = "Error occurred with sending email."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('You have successfully registered an account.');window.location ='RegisterAccount.aspx';", true); #endregion } else //if(success) { Results.Text = "An error has occurred with your account registration. Please try again. If this issue persists, please contact customer support for assistance."; } #endregion } else //if(dropdownsChecked) { Results.Text = "You must select at least one profession, skill, and region preference."; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(‘Must have at least one profession, skill, and region added.’)", true); } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(''Error occurred with registering account. Please contact customer support for assistance if this issue persists.'')", true); Results.Text = ex.ToString(); } }
protected void Submit_Click(object sender, EventArgs e) { try { List <int> list; bool dropdownsChecked = true; list = (List <int>)Session["professions"]; if (list == null) { dropdownsChecked = false; } list = (List <int>)Session["skills"]; if (list == null) { dropdownsChecked = false; } list = (List <int>)Session["regions"]; if (list == null) { dropdownsChecked = false; } if (dropdownsChecked) { bool success = false; User newCandidate = new User(); newCandidate.UserEmail = EmailTextBox.Text; newCandidate.FirstName = FirstName.Text; newCandidate.LastName = LastName.Text; newCandidate.Phone = Phone.Text; newCandidate.Resume = (ResumeUpload.PostedFile.FileName == "") ? null : ResumeUpload.PostedFile.FileName; newCandidate.CoverLetter = (CoverLetterUpload.PostedFile.FileName == "") ? null : CoverLetterUpload.PostedFile.FileName; PRMS controller = new PRMS(); #region add user success = controller.AddCandidate(newCandidate); if (success) { try { int userID; userID = controller.GetUserIDByEmail(EmailTextBox.Text); if (ResumeUpload.HasFile) { string fileExtension = Path.GetExtension(ResumeUpload.PostedFile.FileName); if (fileExtension == ".pdf" || fileExtension == ".docx") { Directory.CreateDirectory(Server.MapPath("~/Files/" + userID + "/Resume/")); DirectoryInfo directory = new DirectoryInfo(Server.MapPath("~/Files/" + userID + "/Resume/")); foreach (FileInfo file in directory.GetFiles()) { file.Delete(); } foreach (DirectoryInfo di in directory.GetDirectories()) { di.Delete(true); } ResumeUpload.SaveAs(Server.MapPath("~/Files/" + userID + "/" + "Resume/" + ResumeUpload.FileName)); } else { Msg.Text = "Only .pdf and .docx resume files are accepted."; } } if (CoverLetterUpload.HasFile) { string fileExtension = Path.GetExtension(CoverLetterUpload.PostedFile.FileName); if (fileExtension == ".pdf" || fileExtension == ".docx") { Directory.CreateDirectory(Server.MapPath("~/Files/" + userID + "/CoverLetter/")); DirectoryInfo directory = new DirectoryInfo(Server.MapPath("~/Files/" + userID + "/CoverLetter/")); foreach (FileInfo file in directory.GetFiles()) { file.Delete(); } foreach (DirectoryInfo di in directory.GetDirectories()) { di.Delete(true); } CoverLetterUpload.SaveAs(Server.MapPath("~/Files/" + userID + "/" + "CoverLetter/" + CoverLetterUpload.FileName)); } else { Msg.Text = "Only .pdf and .docx cover letter files are accepted."; } } //Set color to green //Results.ForeColor = System.Drawing.Color.Green; //Results.Text = "Candidate was added"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Candidate was added successfully.');window.location ='RegisterCandidate.aspx';", true); #region add professions int newUserID; newUserID = controller.GetUserIDByEmail(EmailTextBox.Text); List <int> professions = (List <int>)Session["professions"]; foreach (int profession in professions) { controller.AddUserProfessions(newUserID, profession); } #endregion #region add skills List <int> skills = (List <int>)Session["skills"]; foreach (int skill in skills) { controller.AddUserSkills(newUserID, skill); } #endregion #region add regions List <int> regions = (List <int>)Session["regions"]; foreach (int region in regions) { controller.AddUserRegions(newUserID, region); } #endregion } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Candidate was not registered.')", true); Results.Text = ex.ToString(); } } else //if(success) { Results.Text = "Candidate was not added"; } #endregion } else //if(dropdownsChecked) { Results.Text = "Candidate must have at least one profession, skill, and region added."; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(‘Error occurred with registering the candidate. Please contact customer support for assistance if this issue persists.’)", true); } } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(‘Must have at least one profession, skill, and region added.’)", true); Results.Text = "Candidate must have at least one profession, skill, and region added."; throw; } }