private void SaveNewLocation(String newLatitude, String newLongitude) { dsSavedAddresses.ConnectionString = ThisSession.CnxString; if (rbUseSaved.Checked) { String RawQuery = ""; if (ddlSavedAddresses.SelectedValue != "Orig") { RawQuery = "Select Address1, Address2, City, State, Zip From SavedAltAddresses Where AddressID = '" + ddlSavedAddresses.SelectedValue + "'"; } else { RawQuery = "Select Address1, Address2, City, State, Zipcode as [Zip] from Enrollments Where CCHID = '" + ThisSession.CCHID + "'"; } using (BaseCCHData b = new BaseCCHData(RawQuery, true)) { b.GetData(); if (b.Tables.Count > 0 && b.Tables[0].Rows.Count > 0) { using (DataTable dt = b.Tables[0]) { DataRow dr = dt.Rows[0]; ThisSession.PatientAddress1 = dr.Field<String>("Address1"); ThisSession.PatientAddress2 = dr.Field<String>("Address2"); ThisSession.PatientCity = dr.Field<String>("City"); ThisSession.PatientState = dr.Field<String>("State"); ThisSession.PatientZipCode = dr.Field<String>("Zip"); } } } } else if (cbSaveAddress.Checked) { using (SaveAddress sa = new SaveAddress()) { sa.CCHID = ThisSession.CCHID; sa.Address1 = Encoder.HtmlEncode(txtChgAddress.Text); sa.Address2 = String.Empty; sa.City = Encoder.HtmlEncode(txtChgCity.Text); sa.State = ddlState.SelectedValue; if (txtChgZipCode.Text.ToLower().StartsWith("zip")) sa.Zip = String.Empty; else sa.Zip = Encoder.HtmlEncode(txtChgZipCode.Text); sa.PostData(); } ThisSession.PatientAddress1 = Encoder.HtmlEncode(txtChgAddress.Text); ThisSession.PatientAddress2 = ""; ThisSession.PatientCity = Encoder.HtmlEncode(txtChgCity.Text); ThisSession.PatientState = ddlState.SelectedValue; ThisSession.PatientZipCode = Encoder.HtmlEncode(txtChgZipCode.Text); } else { ThisSession.PatientAddress1 = Encoder.HtmlEncode(txtChgAddress.Text); ThisSession.PatientAddress2 = ""; ThisSession.PatientCity = Encoder.HtmlEncode(txtChgCity.Text); ThisSession.PatientState = ddlState.SelectedValue; ThisSession.PatientZipCode = Encoder.HtmlEncode(txtChgZipCode.Text); } ddlSavedAddresses.Items.Clear(); dsSavedAddresses.Select(new DataSourceSelectArguments()); ddlSavedAddresses.DataBind(); ClearLocationFields(); }
private void SaveNewLocation(String newLatitude, String newLongitude) { dsSavedAddresses.ConnectionString = ThisSession.CnxString; if (rbUseSaved.Checked) { String RawQuery = ""; if (ddlSavedAddresses.SelectedValue != "Orig") { RawQuery = "Select Address1, Address2, City, State, Zip From SavedAltAddresses Where AddressID = '" + ddlSavedAddresses.SelectedValue + "'"; } else { RawQuery = "Select Address1, Address2, City, State, Zipcode as [Zip] from Enrollments Where CCHID = '" + ThisSession.CCHID + "'"; } using (BaseCCHData b = new BaseCCHData(RawQuery, true)) { b.GetData(); if (b.Tables.Count > 0 && b.Tables[0].Rows.Count > 0) { using (DataTable dt = b.Tables[0]) { DataRow dr = dt.Rows[0]; ThisSession.PatientAddress1 = dr.Field <String>("Address1"); ThisSession.PatientAddress2 = dr.Field <String>("Address2"); ThisSession.PatientCity = dr.Field <String>("City"); ThisSession.PatientState = dr.Field <String>("State"); ThisSession.PatientZipCode = dr.Field <String>("Zip"); } } } } else if (cbSaveAddress.Checked) { using (SaveAddress sa = new SaveAddress()) { sa.CCHID = ThisSession.CCHID; sa.Address1 = Encoder.HtmlEncode(txtChgAddress.Text); sa.Address2 = String.Empty; sa.City = Encoder.HtmlEncode(txtChgCity.Text); sa.State = ddlState.SelectedValue; if (txtChgZipCode.Text.ToLower().StartsWith("zip")) { sa.Zip = String.Empty; } else { sa.Zip = Encoder.HtmlEncode(txtChgZipCode.Text); } sa.PostData(); } ThisSession.PatientAddress1 = Encoder.HtmlEncode(txtChgAddress.Text); ThisSession.PatientAddress2 = ""; ThisSession.PatientCity = Encoder.HtmlEncode(txtChgCity.Text); ThisSession.PatientState = ddlState.SelectedValue; ThisSession.PatientZipCode = Encoder.HtmlEncode(txtChgZipCode.Text); } else { ThisSession.PatientAddress1 = Encoder.HtmlEncode(txtChgAddress.Text); ThisSession.PatientAddress2 = ""; ThisSession.PatientCity = Encoder.HtmlEncode(txtChgCity.Text); ThisSession.PatientState = ddlState.SelectedValue; ThisSession.PatientZipCode = Encoder.HtmlEncode(txtChgZipCode.Text); } ddlSavedAddresses.Items.Clear(); dsSavedAddresses.Select(new DataSourceSelectArguments()); ddlSavedAddresses.DataBind(); ClearLocationFields(); }
protected void ValidateInput(object sender, EventArgs e) { //Handle no email entered if (Email.Text.Trim() == String.Empty) { VerifyFailureText.Text = "Email is required."; Email.Focus(); ScriptManager.RegisterStartupScript(this, this.GetType(), "ResetCursor", "document.body.style.cursor = 'default';", true); return; } //Handle no SSN nor Member ID if (SSN.Text.Trim() == String.Empty && MemberID.Text.Trim() == String.Empty) { if (onlySSN) { VerifyFailureText.Text = "Please enter the last 4 digits of your SSN."; SSN.Focus(); } else { VerifyFailureText.Text = "Please enter either the last 4 digits of your SSN or you Member ID."; } ScriptManager.RegisterStartupScript(this, this.GetType(), "ResetCursor", "document.body.style.cursor = 'default';", true); return; } //Get the Employer Connection String to validate the user String cnxString = String.Empty; using (GetEmployerConnString gecs = new GetEmployerConnString(empID)) { if (!gecs.HasErrors && gecs.Tables[0].Rows.Count > 0) { cnxString = gecs.ConnectionString; } else { VerifyFailureText.Text = "There was an error validating your enrollment."; ScriptManager.RegisterStartupScript(this, this.GetType(), "ResetCursor", "document.body.style.cursor = 'default';", true); return; } } //Always try to use SSN if it has something in the text box Boolean ssnSuccess = false; if (SSN.Text.Trim() != String.Empty) { String cleanSSN = Regex.Replace(SSN.Text, "[^0-9]", ""); if (cleanSSN.Length == 4) { String query = String.Concat( "SELECT MemberSSN FROM Enrollments WHERE Email = '", Email.Text.Trim(), "'"); using (BaseCCHData b = new BaseCCHData(query, true)) { b.GetData(cnxString); if (!b.HasErrors && b.Tables[0].Rows.Count > 0) { Int32 idFromDB = Convert.ToInt32(b.Tables[0].Rows[0]["MemberSSN"].ToString()); if (idFromDB == Convert.ToInt32(cleanSSN)) { ssnSuccess = true; sSSN = cleanSSN; } } } } } //If nothing was entered into SSN or if SSN validation failed Boolean memberIdSuccess = false; if (!ssnSuccess) { if (MemberID.Text.Trim() != String.Empty) { String cleanMemberID = Regex.Replace(MemberID.Text, "[^0-9]", ""); if (cleanMemberID.Length == 11) { String query = String.Concat( "SELECT MemberMedicalID FROM Enrollments WHERE Email = '", Microsoft.Security.Application.Encoder.HtmlEncode(Email.Text.Trim()), "'"); using (BaseCCHData b = new BaseCCHData(query, true)) { b.GetData(cnxString); if (!b.HasErrors && b.Tables[0].Rows.Count > 0) { Int64 idFromDB = Convert.ToInt64(b.Tables[0].Rows[0]["MemberMedicalID"].ToString()); if (idFromDB == Convert.ToInt64(cleanMemberID)) { memberIdSuccess = true; } } } } } } if (ssnSuccess || memberIdSuccess) { sUserName = Membership.GetUserNameByEmail(Microsoft.Security.Application.Encoder.HtmlEncode(Email.Text.Trim())); if (String.IsNullOrWhiteSpace(sUserName)) { VerifyFailureText.Text = "User not found."; ScriptManager.RegisterStartupScript(this, this.GetType(), "ResetCursor", "document.body.style.cursor = 'default';", true); } else { lblQuestion.Text = Membership.GetUser(Microsoft.Security.Application.Encoder.HtmlEncode(Email.Text.Trim())).PasswordQuestion; tblVerify.Visible = pnlVerify.Visible = false; tblReset.Visible = pnlReset.Visible = true; ScriptManager.RegisterStartupScript(this, this.GetType(), "ResetCursor", "document.body.style.cursor = 'default';", true); } } else { VerifyFailureText.Text = "There was an error resetting your password with the information provided.<br />Please double check the information you entered and try again."; ScriptManager.RegisterStartupScript(this, this.GetType(), "ResetCursor", "document.body.style.cursor = 'default';", true); } }