protected void btnNext_Click(object sender, EventArgs e) { rfvMedicareEligibility.Validate(); rfvMedicareAandB.Validate(); rfvParticipantProgram.Validate(); if ((String)Session["AccountId"] != null) { strAccountId = (String)Session["AccountId"]; } if ((String)Session["ContactId"] != null) { strPrimaryContactId = (String)Session["ContactId"]; } else { String strQueryForPrimaryContactId = "select Id from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrPrimaryContactId = Sfdcbinding.query(strQueryForPrimaryContactId); if (qrPrimaryContactId.size > 0) { SForce.Contact ctPrimaryContactId = qrPrimaryContactId.records[0] as SForce.Contact; strPrimaryContactId = ctPrimaryContactId.Id; } } if ((String)Session["SpouseId"] != null) { strSpouseId = (String)Session["SpouseId"]; } else { String strQueryForSpouseId = "select Id from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Spouse'"; SForce.QueryResult qrSpouseId = Sfdcbinding.query(strQueryForSpouseId); if (qrSpouseId.size > 0) { SForce.Contact ctSpouseId = qrSpouseId.records[0] as SForce.Contact; strSpouseId = ctSpouseId.Id; } } SForce.Contact ctUpdate = new SForce.Contact(); ctUpdate.Id = strPrimaryContactId; ctUpdate.cmm_Household__c = strAccountId; ctUpdate.cmm_Household_Role__c = "Head of Household"; // whether or not qualifying medicare if (rbListMedicareYesNo.SelectedIndex == 0) { ctUpdate.c4g_Qualifies_for_Medicare__c = true; ctUpdate.c4g_Qualifies_for_Medicare__cSpecified = true; } if (rbListMedicareYesNo.SelectedIndex == 1) { ctUpdate.c4g_Qualifies_for_Medicare__c = false; ctUpdate.c4g_Qualifies_for_Medicare__cSpecified = true; } // whether or not qualifying medicare A and B if (rbListMedicareAandB.SelectedIndex == 0) { ctUpdate.c4g_Qualifies_for_Medicare_A_and_B__c = true; ctUpdate.c4g_Qualifies_for_Medicare_A_and_B__cSpecified = true; } if (rbListMedicareAandB.SelectedIndex == 1) { ctUpdate.c4g_Qualifies_for_Medicare_A_and_B__c = false; ctUpdate.c4g_Qualifies_for_Medicare_A_and_B__cSpecified = true; } String strPrimaryProgram = ddlParticipantProgram.SelectedValue.Substring(0, ddlParticipantProgram.SelectedValue.IndexOf('(')).Trim(); String strQueryForPrimaryProgramId = "select Id from c4g_Plan__c where Name = '" + strPrimaryProgram + "'"; SForce.QueryResult qrPrimaryProgramId = Sfdcbinding.query(strQueryForPrimaryProgramId); if (qrPrimaryProgramId.size > 0) { SForce.c4g_Plan__c primaryPlan = qrPrimaryProgramId.records[0] as SForce.c4g_Plan__c; ctUpdate.c4g_Plan__c = primaryPlan.Id; SForce.SaveResult[] updateResultsPrimary = Sfdcbinding.update(new SForce.sObject[] { ctUpdate }); if (updateResultsPrimary[0].success) { // the primary member's program info added successfully } } String strSpouseProgram = String.Empty; if (ddlSpouseProgram.Items.Count != 0) { strSpouseProgram = ddlSpouseProgram.SelectedValue.Substring(0, ddlSpouseProgram.SelectedValue.IndexOf('(')).Trim(); } String strQueryForSpouseProgramId = "select Id from c4g_Plan__c where Name = '" + strSpouseProgram + "'"; SForce.QueryResult qrSpouseProgramId = Sfdcbinding.query(strQueryForSpouseProgramId); if (qrSpouseProgramId.size > 0) { SForce.c4g_Plan__c spousePlan = qrSpouseProgramId.records[0] as SForce.c4g_Plan__c; SForce.Contact ctSpouseUpdate = new SForce.Contact(); ctSpouseUpdate.Id = strSpouseId; ctSpouseUpdate.c4g_Plan__c = spousePlan.Id; SForce.SaveResult[] updateResultsSpouse = Sfdcbinding.update(new SForce.sObject[] { ctSpouseUpdate }); if (updateResultsSpouse[0].success) { // the spouse's program info is added } } String strChildProgram = String.Empty; if (ddlChildrenProgram.Items.Count != 0) { strChildProgram = ddlChildrenProgram.SelectedValue.Substring(0, ddlChildrenProgram.SelectedValue.IndexOf('(')).Trim(); } String strQueryForChildProgramId = "select Id from c4g_Plan__c where Name = '" + strChildProgram + "'"; SForce.QueryResult qrChildProgramId = Sfdcbinding.query(strQueryForChildProgramId); if (qrChildProgramId.size > 0) { SForce.c4g_Plan__c childPlan = qrChildProgramId.records[0] as SForce.c4g_Plan__c; foreach (String strChildId in lstChildId) { SForce.Contact ctChildUpdate = new SForce.Contact(); ctChildUpdate.Id = strChildId; ctChildUpdate.c4g_Plan__c = childPlan.Id; SForce.SaveResult[] updateResultsChild = Sfdcbinding.update(new SForce.sObject[] { ctChildUpdate }); if (updateResultsChild[0].success) { // the child's program info is added } } } ///// This section insert church info to membership detail aspx String strQueryForHeadOfHouseholdId = "select Id from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrHeadOfHouseholdId = Sfdcbinding.query(strQueryForHeadOfHouseholdId); //String strHeadOfHouseholdId = null; if (qrHeadOfHouseholdId.size > 0) { SForce.Contact ctHead = (SForce.Contact)qrHeadOfHouseholdId.records[0]; String strHeadOfHouseholdId = ctHead.Id; SForce.Account acctChurchInfo = new SForce.Account(); acctChurchInfo.RecordTypeId = "01237000000R6cjAAC"; acctChurchInfo.Name = txtChurchName.Text; acctChurchInfo.Senior_Pastor_s_Name__c = txtSeniorPastor.Text; if (txtChurchStreetAddress.Text != String.Empty) { acctChurchInfo.ShippingStreet = txtChurchStreetAddress.Text; } if (txtChurchZipCode.Text != String.Empty) { acctChurchInfo.ShippingPostalCode = txtChurchZipCode.Text; } if (ddlChurchState.Items != null) { acctChurchInfo.ShippingState = ddlChurchState.SelectedItem.Text; } if (ddlChurchCity.Items != null) { acctChurchInfo.ShippingCity = ddlChurchCity.SelectedItem.Text; } if (txtChurchPhone.Text != String.Empty) { acctChurchInfo.Phone = txtChurchPhone.Text; } SForce.SaveResult[] saveAcctResults = Sfdcbinding.create(new SForce.sObject[] { acctChurchInfo }); if (saveAcctResults[0].success) { SForce.Contact ctHeadOfHousehold = new SForce.Contact(); ctHeadOfHousehold.Id = strHeadOfHouseholdId; //ctHeadOfHousehold.Referral_Source__c = ddlReferredBy.SelectedValue; ctHeadOfHousehold.c4g_Church__c = saveAcctResults[0].id; SForce.SaveResult[] updateResults = Sfdcbinding.update(new SForce.sObject[] { ctHeadOfHousehold }); if (updateResults[0].success) { // notify the user that church information added to household } } } if (ddlReferredBy.SelectedValue != "") { if (ddlReferredBy.SelectedValue == "Member Referral" && txtMembershipNumber.Text != "" && ddlReferrerName.SelectedValue != "") { String strMembershipNumber = String.Empty; if (txtMembershipNumber.Text.Contains("MEMB-")) { strMembershipNumber = txtMembershipNumber.Text; } else { strMembershipNumber = txtMembershipNumber.Text; if (txtMembershipNumber.Text.Length < 7) { for (int i = txtMembershipNumber.Text.Length; i < 7; i++) { strMembershipNumber = '0' + strMembershipNumber; } } strMembershipNumber = "MEMB-" + strMembershipNumber; } String strQueryForContact = "select Id from Contact where c4g_Membership__r.Name = '" + strMembershipNumber + "' and Name = '" + ddlReferrerName.SelectedValue + "'"; SForce.QueryResult qrContactForMembership = Sfdcbinding.query(strQueryForContact); if (qrContactForMembership.size > 0) { SForce.Contact ctReferrer = qrContactForMembership.records[0] as SForce.Contact; SForce.Membership__c memReferralInfo = new SForce.Membership__c(); memReferralInfo.Paying_Member__c = strPrimaryContactId; memReferralInfo.Referred_By__c = ddlReferredBy.SelectedValue; memReferralInfo.Referrer__c = ctReferrer.Id; if ((String)Session["Email"] != null) { memReferralInfo.Email__c = (String)Session["Email"]; } SForce.SaveResult[] saveResults = Sfdcbinding.create(new SForce.sObject[] { memReferralInfo }); if (saveResults[0].success) { // Membership object is created successfully String strQueryForFamilyMembers = "select Id from Contact where cmm_Household__c = '" + strAccountId + "'"; SForce.QueryResult qrFamilyMembers = Sfdcbinding.query(strQueryForFamilyMembers); if (qrFamilyMembers.size > 0) { for (int i = 0; i < qrFamilyMembers.size; i++) { SForce.Contact ctFamilyMemberId = qrFamilyMembers.records[i] as SForce.Contact; SForce.Contact ctFamilyMember = new SForce.Contact(); ctFamilyMember.Id = ctFamilyMemberId.Id; ctFamilyMember.c4g_Membership__c = saveResults[0].id; SForce.SaveResult[] updateResults = Sfdcbinding.update(new SForce.sObject[] { ctFamilyMember }); if (updateResults[0].success) { // Membership object added to each member of the household } } } } } } else { SForce.Membership__c memReferralInfo = new SForce.Membership__c(); memReferralInfo.Paying_Member__c = strPrimaryContactId; memReferralInfo.Referred_By__c = ddlReferredBy.SelectedValue; if ((String)Session["Email"] != null) { memReferralInfo.Email__c = (String)Session["Email"]; } SForce.SaveResult[] saveResults = Sfdcbinding.create(new SForce.sObject[] { memReferralInfo }); if (saveResults[0].success) { // Membership object is created successfully // Membership object is created successfully String strQueryForFamilyMembers = "select Id from Contact where cmm_Household__c = '" + strAccountId + "'"; SForce.QueryResult qrFamilyMembers = Sfdcbinding.query(strQueryForFamilyMembers); if (qrFamilyMembers.size > 0) { for (int i = 0; i < qrFamilyMembers.size; i++) { SForce.Contact ctFamilyMemberId = qrFamilyMembers.records[i] as SForce.Contact; SForce.Contact ctFamilyMember = new SForce.Contact(); ctFamilyMember.Id = ctFamilyMemberId.Id; ctFamilyMember.c4g_Membership__c = saveResults[0].id; SForce.SaveResult[] updateResults = Sfdcbinding.update(new SForce.sObject[] { ctFamilyMember }); if (updateResults[0].success) { // Membership object added to each member of the household } } } } } } SForce.Account acctPrimary = new SForce.Account(); acctPrimary.Id = strAccountId; acctPrimary.cmm_Account_Creation_Step_Code__c = "5"; SForce.SaveResult[] srAccount = Sfdcbinding.update(new SForce.sObject[] { acctPrimary }); if (srAccount[0].success) { Session["PreviousPage"] = "MembershipDetails"; Response.Redirect("~/PaymentInfo.aspx"); } }
protected void btnNext_Click(object sender, EventArgs e) { Set_smoking_drug_alcohol_buttons(); if (IsValid && btnCurrentSmokerYes.BackColor == Color.LightGray && btnNarcoticYes.BackColor == Color.LightGray && btnAlcoholYes.BackColor == Color.LightGray) { String strAccountName = strLastName + " (" + strFirstName + ") Household"; Session["Title"] = ddlTitle.SelectedItem.Text; Session["MiddleName"] = txtMiddleName.Text; Session["DateOfBirth"] = txtDateOfBirth.Text; //if (rbMale.Checked) Session["Gender"] = "Male"; //if (rbFemale.Checked) Session["Gender"] = "Female"; Session["SSN"] = txtSSN.Text; Session["Telephone1"] = txtTelephone1.Text; Session["Telephone2"] = txtTelephone2.Text; Session["Telephone3"] = txtTelephone3.Text; Session["StreetAddress"] = txtAddress.Text; // This section should uncommented in production code Session["ZipCode"] = txtZipCode.Text; Session["State"] = ddlState.SelectedItem.Text; Session["City"] = ddlCity.SelectedItem.Text; //Session["ZipCode"] = "60714"; //Session["State"] = "Illinois"; //Session["City"] = "Niles"; //InitializedSfdcbinding(); //String strQueryForAccountIdOnEmail = "select Id from Account where cmm_Email__c = '" + strEmail + "'"; //SForce.QueryResult qrAccountId = Sfdcbinding.query(strQueryForAccountIdOnEmail); //if (qrAccountId.size > 0) //{ //SForce.Account acctHouseholdId = qrAccountId.records[0] as SForce.Account; //} //SForce.SaveResult[] srNewContact = Sfdcbinding.create(new SForce.sObject[] { ctPrimary }); //String strPrimaryContactId = null; //if (srNewContact[0].success) //{ // lblSaveSuccessFailure.Text += "Contact added successfully"; // strPrimaryContactId = srNewContact[0].id; // Session["ContactId"] = srNewContact[0].id; //} //else //{ // lblSaveSuccessFailure.Text += srNewContact[0].errors[0].message; //} Boolean bUpdatePrimarySuccess = false; String strPrimaryContactId = null; String strQueryForPrimaryId = "select Id from Contact where Email = '" + txtEmail.Text + "'"; SForce.QueryResult qrPrimary = Sfdcbinding.query(strQueryForPrimaryId); if (qrPrimary.size > 0) { SForce.Contact ctPrimary = new SForce.Contact(); ctPrimary.Id = qrPrimary.records[0].Id; ctPrimary.cmm_Household__c = strAccountId; //ctPrimary.Email = txtEmail.Text; ctPrimary.Title = ddlTitle.SelectedItem.Text; //ctPrimary.LastName = txtLastName.Text; //ctPrimary.FirstName = txtFirstName.Text; ctPrimary.MiddleName = txtMiddleName.Text; ctPrimary.cmm_Household_Role__c = "Head of Household"; String strBirthDate = txtDateOfBirth.Text; String[] arryBirthDate = strBirthDate.Split('/'); int nBirthMonth = Int32.Parse(arryBirthDate[0]); int nBirthDay = Int32.Parse(arryBirthDate[1]); int nBirthYear = Int32.Parse(arryBirthDate[2]); ctPrimary.Birthdate = new DateTime(nBirthYear, nBirthMonth, nBirthDay); ctPrimary.BirthdateSpecified = true; ctPrimary.cmm_Gender__c = rbGenderList.SelectedItem.Text; ctPrimary.Social_Security_Number__c = txtSSN.Text; ctPrimary.Phone = txtTelephone1.Text; ctPrimary.HomePhone = txtTelephone1.Text; ctPrimary.MobilePhone = txtTelephone2.Text; ctPrimary.OtherPhone = txtTelephone3.Text; SForce.SaveResult[] srUpdatePrimary = Sfdcbinding.update(new SForce.sObject[] { ctPrimary }); if (srUpdatePrimary[0].success) { strPrimaryContactId = qrPrimary.records[0].Id; Session["ContactId"] = qrPrimary.records[0].Id; bUpdatePrimarySuccess = true; } } String strQueryForContactId = "select Name from Contact where Email = '" + txtEmail.Text + "'"; SForce.QueryResult qrContactId = Sfdcbinding.query(strQueryForContactId); //String strContactId = strPrimaryContactId; //String strMemberName = null; if (qrContactId.size > 0) { SForce.Contact ctName = (SForce.Contact)qrContactId.records[0]; //strContactId = ctId.Id; //strMemberName = ctId.Name; //Session["ContactId"] = strContactId; // MemberSmokingDrugAlcohol primarySDA = new MemberSmokingDrugAlcohol(); // primarySDA.AccountId = strAccountId; // primarySDA.HouseholdRole = HouseholdRoles.Primary; // primarySDA.ContactId = strPrimaryContactId; // primarySDA.Name = ctName.Name; // primarySDA.bCurrentSmoker = false; // primarySDA.bCurrentDrug = false; //primarySDA.bAlcohol = false; // if (btnFormerSmokerYes.BackColor == Color.Green) primarySDA.bFormerSmoker = true; // if (btnFormerSmokerNo.BackColor == Color.Blue) primarySDA.bFormerSmoker = false; // if (btnFormerNarcoticYes.BackColor == Color.Green) primarySDA.bFormerDrug = true; // if (btnFormerNarcoticNo.BackColor == Color.Blue) primarySDA.bFormerDrug = false; // //if (btnAlcoholYes.BackColor == Color.Green) primarySDA.bAlcohol = true; // //if (btnAlcoholNo.BackColor == Color.Blue) primarySDA.bAlcohol = false; // lstMemberSDA.Add(primarySDA); // Session["MemberSmokingDrugAlcohol"] = lstMemberSDA; // Save lstMemberSDA to salesforce for incomplete application - done string strQueryForPrimarySDA = "select Id from tmp_SmokingDrugAlcohol__c where cmm_Account__c = '" + strAccountId + "' and " + "cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrTmpPrimarySDA = Sfdcbinding.query(strQueryForPrimarySDA); if (qrTmpPrimarySDA.size > 0) { SForce.tmp_SmokingDrugAlcohol__c tmpHeadSDA = qrTmpPrimarySDA.records[0] as SForce.tmp_SmokingDrugAlcohol__c; SForce.tmp_SmokingDrugAlcohol__c tmpPrimarySDA = new SForce.tmp_SmokingDrugAlcohol__c(); tmpPrimarySDA.Id = tmpHeadSDA.Id; tmpPrimarySDA.cmm_bCurrentSmoker__c = "No"; tmpPrimarySDA.cmm_bCurrentDrug__c = "No"; tmpPrimarySDA.cmm_bAlcohol__c = "No"; if (btnFormerSmokerYes.BackColor == Color.Green) { tmpPrimarySDA.cmm_bFormerSmoker__c = "Yes"; } if (btnFormerSmokerNo.BackColor == Color.Blue) { tmpPrimarySDA.cmm_bFormerSmoker__c = "No"; } if (btnFormerNarcoticYes.BackColor == Color.Green) { tmpPrimarySDA.cmm_bFormerDrug__c = "Yes"; } if (btnFormerNarcoticNo.BackColor == Color.Blue) { tmpPrimarySDA.cmm_bFormerDrug__c = "No"; } SForce.SaveResult[] srUpdateTmpPrimarySDA = Sfdcbinding.update(new SForce.sObject[] { tmpPrimarySDA }); if (srUpdateTmpPrimarySDA[0].success) { // temporary instance of salesforc object is udpated successfully } } else if (qrTmpPrimarySDA.size == 0) { SForce.tmp_SmokingDrugAlcohol__c tmpPrimarySDA = new SForce.tmp_SmokingDrugAlcohol__c(); tmpPrimarySDA.cmm_Account_Creation_Step_Code__c = 3; tmpPrimarySDA.cmm_Account_Creation_Step_Code__cSpecified = true; tmpPrimarySDA.cmm_Account__c = strAccountId; tmpPrimarySDA.cmm_Contact__c = strPrimaryContactId; tmpPrimarySDA.cmm_Household_Role__c = "Head of Household"; tmpPrimarySDA.cmm_Name__c = ctName.Name; tmpPrimarySDA.cmm_bCurrentSmoker__c = "No"; tmpPrimarySDA.cmm_bCurrentDrug__c = "No"; tmpPrimarySDA.cmm_bAlcohol__c = "No"; if (btnFormerSmokerYes.BackColor == Color.Green) { tmpPrimarySDA.cmm_bFormerSmoker__c = "Yes"; } if (btnFormerSmokerNo.BackColor == Color.Blue) { tmpPrimarySDA.cmm_bFormerSmoker__c = "No"; } if (btnFormerNarcoticYes.BackColor == Color.Green) { tmpPrimarySDA.cmm_bFormerDrug__c = "Yes"; } if (btnFormerNarcoticNo.BackColor == Color.Blue) { tmpPrimarySDA.cmm_bFormerDrug__c = "No"; } //if (btnAlcoholYes.BackColor == Color.Green) tmpPrimarySDA.cmm_bAlcohol__c = "Yes"; //if (btnAlcoholNo.BackColor == Color.Blue) tmpPrimarySDA.cmm_bAlcohol__c = "No"; SForce.SaveResult[] srTmpPrimarySDA = Sfdcbinding.create(new SForce.sObject[] { tmpPrimarySDA }); if (srTmpPrimarySDA[0].success) { // temporary instance of salesforce object is created successfully } } } //SForce.Account acctUpdate = new SForce.Account(); //if (strAccountId != null) acctUpdate.Id = strAccountId; //if (strPrimaryContactId != null) acctUpdate.cmm_Contact__c = strPrimaryContactId; //SForce.SaveResult[] updateResultsAccount = Sfdcbinding.update(new SForce.sObject[] { acctUpdate }); //if (updateResultsAccount[0].success) //{ // lblSaveSuccessFailure.Text += "Account update succeeded"; //} //else //{ // lblSaveSuccessFailure.Text += updateResultsAccount[0].errors[0].message; //} //SForce.Contact ctUpdate = new SForce.Contact(); //if (strPrimaryContactId != null) ctUpdate.Id = strPrimaryContactId; //if (strAccountId != null) ctUpdate.cmm_Household__c = strAccountId; //SForce.SaveResult[] updateResultsContact = Sfdcbinding.update(new SForce.sObject[] { ctUpdate }); //if (updateResultsContact[0].success) //{ // lblSaveSuccessFailure.Text += "Contact update succeeded"; //} //else //{ // lblSaveSuccessFailure.Text += updateResultsContact[0].errors[0].message; //} Boolean bUpdateAcctHouseholdSuccess = false; SForce.Account acctHousehold = new SForce.Account(); acctHousehold.Id = strAccountId; acctHousehold.cmm_Account_Creation_Step_Code__c = "3"; acctHousehold.cmm_Contact__c = strPrimaryContactId; acctHousehold.ShippingStreet = txtAddress.Text; acctHousehold.ShippingCity = ddlCity.SelectedValue; acctHousehold.ShippingState = ddlState.SelectedValue; acctHousehold.ShippingPostalCode = txtZipCode.Text; acctHousehold.BillingStreet = txtAddress.Text; acctHousehold.BillingCity = ddlCity.SelectedValue; acctHousehold.BillingState = ddlState.SelectedValue; acctHousehold.BillingPostalCode = txtZipCode.Text; SForce.SaveResult[] updateResults = Sfdcbinding.update(new SForce.sObject[] { acctHousehold }); if (updateResults[0].success) { // The Household account updated with Shipping address //Session["PreviousPage"] = "PersonalDetails"; //Response.Redirect("~/FamilyDetails.aspx"); bUpdateAcctHouseholdSuccess = true; } if (bUpdatePrimarySuccess && bUpdateAcctHouseholdSuccess) { Session["PreviousPage"] = "PersonalDetails"; Response.Redirect("~/FamilyDetails.aspx"); } //if (updateResultsAccount[0].success && updateResultsContact[0].success) //{ // //SForce.Account acctPrimary = new SForce.Account(); // //if (strAccountId != null) acctPrimary.Id = strAccountId; // //acctPrimary.cmm_Account_Creation_Step_Code__c = "2"; // //SForce.SaveResult[] srAccount = Sfdcbinding.update(new SForce.sObject[] { acctPrimary }); // //if (srAccount[0].success) // //{ // // Session["PreviousPage"] = "CreateAccount"; // // Response.Redirect("~/PersonalDetails.aspx"); // //} // SForce.Account acctPrimary = new SForce.Account(); // acctPrimary.Id = strAccountId; // acctPrimary.cmm_Account_Creation_Step_Code__c = "3"; // acctPrimary.BillingStreet = txtAddress.Text; // acctPrimary.BillingCity = ddlCity.SelectedItem.Text; // acctPrimary.BillingState = ddlState.SelectedItem.Text; // acctPrimary.BillingPostalCode = txtZipCode.Text; // SForce.SaveResult[] srAccount = Sfdcbinding.update(new SForce.sObject[] { acctPrimary }); // if (srAccount[0].success) // { // // the update has succeeded // Session["PreviousPage"] = "PersonalDetails"; // Response.Redirect("~/FamilyDetails.aspx"); // } //} } else { // user is current smoker or taking narcotic drug mpeUserSmokingDrugAlcohol.Show(); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { //lblSeverSideCode.Text = "The personal information is submitted."; //if (Page.IsValid) //{ /////// Should be uncommented for the application to work var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = MemberEmail, Email = MemberEmail }; IdentityResult result = manager.Create(user, txtPassword.Text); bool bCreateUserSucceeded = result.Succeeded; if (result.Succeeded) { SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()); SqlCommand cmd = new SqlCommand(); strSQLSetEmailConfirmed = "Update AspNetUsers Set EmailConfirmed = @bEmailConfirmed where Email = @EmailAddr"; cmd.CommandText = strSQLSetEmailConfirmed; cmd.Connection = cnn; cmd.Parameters.Add("@bEmailConfirmed", SqlDbType.Bit); cmd.Parameters["@bEmailConfirmed"].Value = true; cmd.Parameters.Add("@EmailAddr", SqlDbType.NVarChar); cmd.Parameters["@EmailAddr"].Value = MemberEmail; try { cnn.Open(); int nRowsAffected = cmd.ExecuteNonQuery(); cnn.Close(); } catch (Exception ex) { //ErrorMessage.Text = ex.Message; } //signInManager.SignIn(user, isPersistent: false, rememberBrowser: false); } //} /// Should be uncommented up to this line //////////////////////////////////////////////////////////////// //lblReCaptchaError.Text = "Recaptcha Error!"; //lblErrorMessage.Text = "This is ReCaptcha succeeded"; //if (reCaptcha.Validate()) //{ // lblReCaptchaError.Text = "ReCaptcha validation succeeded"; //} //else //{ // lblReCaptchaError.Text = "ReCaptcha validation failed"; //} //String strQueryForAcctId = "select Id from Account where cmm_Email__c = '" + MemberEmail + "'"; //SForce.QueryResult qrAccountId = Sfdcbinding.query(strQueryForAcctId); //if (qrAccountId.size > 0) //{ //SForce.Account acctPrimaryId = qrAccountId.records[0] as SForce.Account; SForce.Account acctPrimary = new SForce.Account(); if (strAccountId != null) { acctPrimary.Id = strAccountId; } acctPrimary.cmm_Account_Creation_Step_Code__c = "2"; SForce.SaveResult[] srAccount = Sfdcbinding.update(new SForce.sObject[] { acctPrimary }); if (srAccount[0].success) { SForce.Contact ctPrimary = new SForce.Contact(); ctPrimary.cmm_Household__c = strAccountId; ctPrimary.Email = txtEmail.Text; ctPrimary.LastName = txtLastName.Text; ctPrimary.FirstName = txtFirstName.Text; ctPrimary.cmm_Household_Role__c = "Head of Household"; SForce.SaveResult[] srPrimary = Sfdcbinding.create(new SForce.sObject[] { ctPrimary }); if (srPrimary[0].success) { SForce.Account acctHousehold = new SForce.Account(); acctHousehold.Id = strAccountId; acctHousehold.cmm_Contact__c = srPrimary[0].id; SForce.SaveResult[] updateHousehold = Sfdcbinding.update(new SForce.sObject[] { acctHousehold }); if (updateHousehold[0].success) { } SForce.Contact ctUpdate = new SForce.Contact(); ctUpdate.Id = srPrimary[0].id; ctUpdate.cmm_Household__c = strAccountId; SForce.SaveResult[] srUpdatePrimary = Sfdcbinding.update(new SForce.sObject[] { ctUpdate }); if (srUpdatePrimary[0].success) { } } var signInResult = signInManager.PasswordSignIn(txtEmail.Text, txtPassword.Text, false, shouldLockout: false); switch (signInResult) { case SignInStatus.Success: Session["PreviousPage"] = "CreateAccount"; Response.Redirect("~/PersonalDetails.aspx"); break; case SignInStatus.LockedOut: Response.Redirect("~/Account/Lockout.aspx"); break; case SignInStatus.Failure: Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie); Response.Redirect("~/Account/Login.aspx"); break; } } }
protected void btnConfirmPersonalInfo_Click(object sender, EventArgs e) { // Send the email to confirm that the user entered correct email address and send the link to CreateAccount page to allow user to create account //SmtpClient smtpClient = new SmtpClient("mail.logosmissions.com"); //smtpClient.Port = 25; //smtpClient.Credentials = new System.Net.NetworkCredential("hyungpark", "0particle8"); //smtpClient.EnableSsl = true; //smtpClient.UseDefaultCredentials = false; //MailAddress from = new MailAddress("*****@*****.**", "Christian Mutual MedAid", System.Text.Encoding.UTF8); //MailAddress to = new MailAddress(txtEmail.Text); //MailMessage message = new MailMessage(from, to); //message.Body = "This is test email from Christian Mutual MedAid"; //message.BodyEncoding = System.Text.Encoding.UTF8; //message.Subject = "CMM Confirmation Email"; //message.SubjectEncoding = System.Text.Encoding.UTF8; //smtpClient.Send(message); //String strQueryForEmail = "select Id from Account where cmm_Email__c = '" + txtEmail.Text + "'"; //SForce.QueryResult qrAccountForEmail = Sfdcbinding.query(strQueryForEmail); //if (qrAccountForEmail.size == 0) //{ Session["FirstName"] = txtFirstName.Text; Session["LastName"] = txtLastName.Text; Session["Email"] = txtEmail.Text; //FirstName = txtFirstName.Text; //LastName = txtLastName.Text; //Email = txtEmail.Text; //Server.Transfer("~/CreateAccount.aspx", true); //String strAccountName = strLastName + " (" + strFirstName + ") Household"; String strAccountName = txtLastName.Text + " (" + txtFirstName.Text + ") Household"; Session["AccountName"] = strAccountName; SForce.Account acctPrimary = new SForce.Account(); acctPrimary.Name = strAccountName; acctPrimary.RecordType = new SForce.RecordType(); acctPrimary.RecordType.Name = "Household"; acctPrimary.cmm_Account_Creation_Step_Code__c = "1"; acctPrimary.cmm_Email__c = txtEmail.Text; SForce.SaveResult[] srAcctPrimary = Sfdcbinding.create(new SForce.sObject[] { acctPrimary }); if (srAcctPrimary[0].success) { Session["AccountId"] = srAcctPrimary[0].id; Session["PreviousPage"] = "PersonalInfo"; Response.Redirect("~/CreateAccount.aspx"); } else { // Error: creating account failed } //} //else if (qrAccountForEmail.size > 0) //{ // Display message that indicates the email is already in salesforce database //String strQueryForAcctInfo = "select cmm_Account_Creation_Step_Code__c, Id from Account where cmm_Email__c = '" + txtEmail.Text + "'"; //SForce.QueryResult qrAcctInfo = Sfdcbinding.query(strQueryForAcctInfo); //if (qrAcctInfo.size > 0) //{ // SForce.Account acctAcctInfo = qrAcctInfo.records[0] as SForce.Account; // Session["FirstName"] = txtFirstName.Text; // Session["LastName"] = txtLastName.Text; // Session["Email"] = txtEmail.Text; // Session["AccountId"] = acctAcctInfo.Id; // String strAccountName = txtLastName.Text + " (" + txtFirstName.Text + ") Household"; // Session["AccountName"] = strAccountName; // //Session["AccountId"] = acctAcctInfo.Id; // Session["PreviousPage"] = "PersonalInfo"; // switch (acctAcctInfo.cmm_Account_Creation_Step_Code__c) // { // case "1": // Response.Redirect("~/CreateAccount.aspx"); // break; // case "2": // Response.Redirect("~/PersonalDetails.aspx"); // break; // case "3": // Response.Redirect("~/FamilyDetails.aspx"); // break; // case "4": // Response.Redirect("~/MembershipDetails.aspx"); // break; // case "5": // Response.Redirect("~/PaymentInfo.aspx"); // break; // case "6": // Response.Redirect("~/HealthHistory.aspx"); // break; // case "7": // Response.Redirect("~/Agreement.aspx"); // break; // case "8": // // Show the message informing the user is already registered, tell the user to log on instead of registering // Response.Redirect("~/Account/Login.aspx"); // break; // } //} //} }
protected void btnSave_Click(object sender, EventArgs e) { if (txtLastName.Text == null) { lblErrorMessage.Text = "Error: You must enter your last name"; } else { SForce.Contact sfdcContact = new SForce.Contact(); sfdcContact.FirstName = txtFirstName.Text; sfdcContact.LastName = txtLastName.Text; sfdcContact.MailingStreet = txtStreetAddress.Text; sfdcContact.MailingCity = txtCity.Text; sfdcContact.MailingState = txtState.Text; sfdcContact.MailingPostalCode = txtZip.Text; sfdcContact.MobilePhone = txtMobilePhone.Text; sfdcContact.Phone = txtPhone.Text; sfdcContact.Email = txtEmail.Text; SForce.SforceService sfdcbinding = new SForce.SforceService(); SForce.LoginResult login_result = null; login_result = sfdcbinding.login(strUserName, strPasswd); sfdcbinding.Url = login_result.serverUrl; sfdcbinding.SessionHeaderValue = new SForce.SessionHeader(); sfdcbinding.SessionHeaderValue.sessionId = login_result.sessionId; SForce.SaveResult[] saveResults = sfdcbinding.create(new SForce.sObject[] { sfdcContact }); if (saveResults[0].success) { lblErrorMessage.Text = "You added a new record successfully."; nCurrentIndex = nTotalRecord; Session["CurrentIndex"] = nCurrentIndex; nTotalRecord++; Sfdcbinding = new SForce.SforceService(); CurrentLoginResult = Sfdcbinding.login(strUserName, strPasswd); Sfdcbinding.Url = CurrentLoginResult.serverUrl; Sfdcbinding.SessionHeaderValue = new SForce.SessionHeader(); Sfdcbinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId; strQuerySelectFromContact = "select Id, FirstName, LastName, MailingAddress, Email, MobilePhone, Phone from Contact order by LastName nulls last"; queryResult = Sfdcbinding.query(strQuerySelectFromContact); nTotalRecord = queryResult.size - 1; } else { lblErrorMessage.Text = saveResults[0].errors[0].message; } btnFirst.Enabled = true; btnPrev.Enabled = true; btnNext.Enabled = true; btnLast.Enabled = true; btnSave.Enabled = false; btnCancel.Enabled = false; } }