protected void btnMemberPrev_Click(object sender, EventArgs e) { SForce.SforceService sfdcbindingMembership = new SForce.SforceService(); SForce.LoginResult LoginResult = sfdcbindingMembership.login(strUserName, strPasswd); sfdcbindingMembership.Url = LoginResult.serverUrl; sfdcbindingMembership.SessionHeaderValue = new SForce.SessionHeader(); sfdcbindingMembership.SessionHeaderValue.sessionId = LoginResult.sessionId; queryResultMembership = sfdcbindingMembership.query(strQuerySelectFromMembership); int nMemberIndex = (int)Session["MemberIndex"]; if (nMemberIndex > 0) { nMemberIndex--; } Session["MemberIndex"] = nMemberIndex; SForce.Membership__c membership = (SForce.Membership__c)queryResultMembership.records[nMemberIndex]; txtContactId.Text = membership.Id; txtMembershipName.Text = membership.Name; txtMembershipStatus.Text = membership.c4g_Membership_Status__c; }
protected void btnUpdate_Click(object sender, EventArgs e) { string strId = (string)Session["CurrentId"]; SForce.Contact contact_update = new SForce.Contact(); contact_update.Id = strId; contact_update.FirstName = txtFirstName.Text; contact_update.LastName = txtLastName.Text; contact_update.MailingStreet = txtStreetAddress.Text; contact_update.MailingCity = txtCity.Text; contact_update.MailingState = txtState.Text; contact_update.MailingPostalCode = txtZip.Text; contact_update.MobilePhone = txtMobilePhone.Text; contact_update.Phone = txtPhone.Text; contact_update.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.update(new SForce.sObject[] { contact_update }); if (saveResults[0].success) { lblErrorMessage.Text = "The record id: " + saveResults[0].id + " is updated successfully."; 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 = "Error: " + saveResults[0].errors[0].message; } btnCancel.Enabled = false; btnUpdate.Enabled = false; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //if (PreviousPage != null) //{ // FirstName = PreviousPage.FirstName; // LastName = PreviousPage.LastName; // MemberEmail = PreviousPage.Email; //} FirstName = (string)Session["FirstName"]; LastName = (string)Session["LastName"]; MemberEmail = (string)Session["Email"]; //AccountName = LastName + " (" + FirstName + ") Household"; //Session["AccountName"] = AccountName; //lblErrorMessage.Text = AccountName; //SetSQLStatementForConfirmEmail(); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls; } InitializedSfdcbinding(); if ((String)Session["AccountId"] != null) { strAccountId = (String)Session["AccountId"]; } else { String strQueryForHousehold = "select Id from Account where cmm_Email__c = '" + txtEmail.Text + "'"; SForce.QueryResult qrAcctHousehold = Sfdcbinding.query(strQueryForHousehold); if (qrAcctHousehold.size > 0) { strAccountId = qrAcctHousehold.records[0].Id; } } }
protected void txtMembershipNumber_TextChanged(object sender, EventArgs e) { if (ddlReferredBy.SelectedValue == "Member Referral") { TextBox txtMembershipNumber = (TextBox)sender; 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 strQueryForMembership = "select Name from Contact where c4g_Membership__r.Name = '" + strMembershipNumber + "'"; SForce.QueryResult qrMembership = Sfdcbinding.query(strQueryForMembership); if (qrMembership.size > 0) { ddlReferrerName.Items.Clear(); ddlReferrerName.Enabled = true; for (int i = 0; i < qrMembership.size; i++) { SForce.Contact ctReferrer = qrMembership.records[i] as SForce.Contact; ddlReferrerName.Items.Add(ctReferrer.Name); } } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signinManager = Context.GetOwinContext().GetUserManager <ApplicationSignInManager>(); //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); // Confirm the user email whether or not the user is portal user System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls; //SetSQLStatementForPortalUser(); //InitializedSfdcbinding(); //SForce.QueryResult qrPortalUser = Sfdcbinding.query(strQueryContactForPortalUser); //if (qrPortalUser.size > 0) //{ //SForce.Contact ctPortalUser = (SForce.Contact)qrPortalUser.records[0]; //if (ctPortalUser.causeview__PortalUser__c == true) //{ // Code for Login and Response.Redirect to MainForm.aspx page should be here // This doen't count login failures towards account lockout // To enable password failures to trigger lockout, change to shouldLockout: true var result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout: false); HttpBrowserCapabilities browser = Request.Browser; switch (result) { case SignInStatus.Success: //IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); //if (browser.Type.Contains("Firefox") || // browser.Type.Contains("Chrome") || // browser.Type.Contains("Edge") || // browser.Type.Contains("InternetExplorer11") || // browser.Type.ToUpper().Contains("IE")) //{ // Response.Redirect("~/MainForm.aspx", false); //} //if (browser.Type.Contains("Safari")) Response.Redirect("~/MainFormSafari.aspx", false); String strQueryForAccountCreationStep = "select cmm_Account_Creation_Step_Code__c, Id from Account where cmm_Email__c = '" + Email.Text + "'"; SForce.QueryResult qrAcctCreationStep = Sfdcbinding.query(strQueryForAccountCreationStep); if (qrAcctCreationStep.size > 0) { SForce.Account acctCreationStep = qrAcctCreationStep.records[0] as SForce.Account; Session["Email"] = Email.Text; Session["AccountId"] = acctCreationStep.Id; Session["PreviousPage"] = "Login"; switch (acctCreationStep.cmm_Account_Creation_Step_Code__c) { 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("~/MainForm.aspx"); break; } } break; case SignInStatus.LockedOut: Response.Redirect("/Account/Lockout"); break; //case SignInStatus.RequiresVerification: // Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}", // Request.QueryString["ReturnUrl"], // RememberMe.Checked), // true); // break; case SignInStatus.Failure: Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie); //Response.Redirect("~/Account/Login.aspx"); lblFailureText.Text = "Invalid login attempt"; pnlLoginFailureText.Visible = true; break; default: lblFailureText.Text = "Invalid login attempt"; pnlLoginFailureText.Visible = true; break; } //} //else //{ // FailureText.Text = "You are not a portal user"; // ErrorMessage.Visible = true; //} //} } }
protected void Page_Load(object sender, EventArgs e) { //System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; //InitializedSfdcbinding(); if ((String)Session["AccountId"] != null) { strAccountId = (String)Session["AccountId"]; } if ((String)Session["Email"] != null) { strEmail = (String)Session["Email"]; } 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; } } String strQueryForChildrenId = "select Id from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Child'"; SForce.QueryResult qrChildrenId = Sfdcbinding.query(strQueryForChildrenId); if (qrChildrenId.size > 0) { for (int i = 0; i < qrChildrenId.size; i++) { SForce.Contact ctChildId = qrChildrenId.records[i] as SForce.Contact; lstChildId.Add(ctChildId.Id); } } String strQueryForMedicareDetails = "select c4g_Qualifies_for_Medicare__c, c4g_Qualifies_for_Medicare_A_and_B__c from Contact " + " where cmm_Household__c = '" + strAccountId + "' and cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrQualifyForMedicare = Sfdcbinding.query(strQueryForMedicareDetails); if (qrQualifyForMedicare.size > 0) { SForce.Contact ctQualifyForMedicare = qrQualifyForMedicare.records[0] as SForce.Contact; if (ctQualifyForMedicare.c4g_Qualifies_for_Medicare__c == true && ctQualifyForMedicare.c4g_Qualifies_for_Medicare__cSpecified == true) { rbListMedicareYesNo.SelectedIndex = 0; } else if (ctQualifyForMedicare.c4g_Qualifies_for_Medicare__c == false && ctQualifyForMedicare.c4g_Qualifies_for_Medicare__cSpecified == true) { rbListMedicareYesNo.SelectedIndex = 1; } if (ctQualifyForMedicare.c4g_Qualifies_for_Medicare_A_and_B__c == true && ctQualifyForMedicare.c4g_Qualifies_for_Medicare_A_and_B__cSpecified == true) { rbListMedicareAandB.SelectedIndex = 0; } else if (ctQualifyForMedicare.c4g_Qualifies_for_Medicare_A_and_B__c == false && ctQualifyForMedicare.c4g_Qualifies_for_Medicare_A_and_B__cSpecified == true) { rbListMedicareAandB.SelectedIndex = 1; } } if (!IsPostBack) { String strQueryForMemberPlan = "select c4g_Plan__r.Name from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrMemberPlan = Sfdcbinding.query(strQueryForMemberPlan); if (qrMemberPlan.size > 0) { SForce.Contact ctMemberPlan = qrMemberPlan.records[0] as SForce.Contact; if (ctMemberPlan.c4g_Plan__r != null) { switch (ctMemberPlan.c4g_Plan__r.Name) { case "Gold Medi-I": ddlParticipantProgram.SelectedIndex = 1; break; case "Gold Medi-II": ddlParticipantProgram.SelectedIndex = 2; break; case "Gold Plus": ddlParticipantProgram.SelectedIndex = 3; break; case "Gold": ddlParticipantProgram.SelectedIndex = 4; break; case "Silver": ddlParticipantProgram.SelectedIndex = 5; break; case "Bronze": ddlParticipantProgram.SelectedIndex = 6; break; } } } String strQueryForSpousePlan = "select c4g_Plan__r.Name from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Spouse'"; SForce.QueryResult qrSpousePlan = Sfdcbinding.query(strQueryForSpousePlan); if (qrSpousePlan.size > 0) { SForce.Contact ctSpousePlan = qrSpousePlan.records[0] as SForce.Contact; if (ctSpousePlan.c4g_Plan__r != null) { switch (ctSpousePlan.c4g_Plan__r.Name) { case "Gold Medi-I": ddlSpouseProgram.SelectedIndex = 1; break; case "Gold Medi-II": ddlSpouseProgram.SelectedIndex = 2; break; case "Gold Plus": ddlSpouseProgram.SelectedIndex = 3; break; case "Gold": ddlSpouseProgram.SelectedIndex = 4; break; case "Silver": ddlSpouseProgram.SelectedIndex = 5; break; case "Bronze": ddlSpouseProgram.SelectedIndex = 6; break; } } } String strQueryForChildren = "select c4g_Plan__r.Name from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Child'"; SForce.QueryResult qrChildrenProgram = Sfdcbinding.query(strQueryForChildren); if (qrChildrenProgram.size > 0) { SForce.Contact ctChildProgram = qrChildrenProgram.records[0] as SForce.Contact; if (ctChildProgram.c4g_Plan__r != null) { switch (ctChildProgram.c4g_Plan__r.Name) { case "Gold Plus": ddlChildrenProgram.SelectedIndex = 1; break; case "Gold": ddlChildrenProgram.SelectedIndex = 2; break; case "Silver": ddlChildrenProgram.SelectedIndex = 3; break; case "Bronze": ddlChildrenProgram.SelectedIndex = 4; break; } } } } String strQueryForChurchId = "select Id, c4g_Church__c from Contact where cmm_Household__c = '" + strAccountId + "' " + "and cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrChurchId = Sfdcbinding.query(strQueryForChurchId); if (qrChurchId.size > 0) { SForce.Contact ctChurchId = qrChurchId.records[0] as SForce.Contact; String strQueryForChurchInfo = "select Name, Senior_Pastor_s_Name__c, ShippingAddress, Phone from Account where RecordTypeId = '01237000000R6cjAAC' and " + "Id = '" + ctChurchId.c4g_Church__c + "'"; SForce.QueryResult qrAcctChurchInfo = Sfdcbinding.query(strQueryForChurchInfo); if (qrAcctChurchInfo.size > 0) { SForce.Account acctChurchInfo = qrAcctChurchInfo.records[0] as SForce.Account; txtChurchName.Text = acctChurchInfo.Name; txtSeniorPastor.Text = acctChurchInfo.Senior_Pastor_s_Name__c; txtChurchStreetAddress.Text = acctChurchInfo.ShippingAddress.street; txtChurchZipCode.Text = acctChurchInfo.ShippingAddress.postalCode; ddlChurchState.Items.Add(new ListItem(acctChurchInfo.ShippingAddress.state)); ddlChurchState.SelectedIndex = 0; ddlChurchCity.Items.Add(new ListItem(acctChurchInfo.ShippingAddress.city)); ddlChurchCity.SelectedIndex = 0; txtChurchPhone.Text = acctChurchInfo.Phone; } } //SForce.DescribeSObjectResult describeSObjectResult = Sfdcbinding.describeSObject("Contact"); //// Get the fields //if (describeSObjectResult != null) //{ // SForce.Field[] fields = describeSObjectResult.fields; // for (int i = 0; i < fields.Length; i++) // { // SForce.Field field = fields[i]; // if (field.name == "Referral_Source__c") // { // SForce.PicklistEntry[] pickListValues = field.picklistValues; // if (pickListValues != null) // { // //ddlReferredBy.Items.Clear(); // foreach (SForce.PicklistEntry pickListEntry in pickListValues) // { // ddlReferredBy.Items.Add(pickListEntry.value); // } // } // } // } //} //String strQueryForChurchInfo = "select Name, Senior_Pastor_s_Name__c, ShippingAddress, Phone from Account where RecordTypeId = '01237000000R6cjAAC' and " + // "Id = '" + strAccountId + "'"; //String strQueryForChurchInfo = "select Name, Senior_Pastor_s_Name__c, ShippingAddress, Phone from Account where Id = '" + strAccountId + "'"; if (!IsPostBack) { //////////////////////////////////////////////////////////////////////// // if no spouse is added, then clear the ddlSpouseProgram dropdownlist SForce.QueryResult qrSpouse = Sfdcbinding.query(strQueryForSpouse); if (qrSpouse.size == 0) { ddlSpouseProgram.Items.Clear(); } // if no child is added, then clear the ddlChildProgram dropdownlist SForce.QueryResult qrChild = Sfdcbinding.query(strQueryForChildren); if (qrChild.size == 0) { ddlChildrenProgram.Items.Clear(); } SForce.DescribeSObjectResult describeSObjectResult = Sfdcbinding.describeSObject("Membership__c"); // Get the fields if (describeSObjectResult != null) { SForce.Field[] fields = describeSObjectResult.fields; for (int i = 0; i < fields.Length; i++) { SForce.Field field = fields[i]; if (field.name == "Referred_By__c") { SForce.PicklistEntry[] pickListValues = field.picklistValues; if (pickListValues != null) { //ddlReferredBy.Items.Clear(); foreach (SForce.PicklistEntry pickListEntry in pickListValues) { ddlReferredBy.Items.Add(pickListEntry.value); } } } } } } //strAccountID = (String)Session["AccountId"]; //strSpouseId = (String)Session["ContactId"]; }
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 Page_Load(object sender, EventArgs e) { //Response.Write("<div id='mydiv' >"); //Response.Write("_"); //Response.Write("</div>"); //Response.Write("<script>mydiv.innerText = '';</script>"); //Response.Write("<script language=javascript>;"); //Response.Write("var dots = 0;var dotmax = 10;function ShowWait()"); //Response.Write("{var output; output = 'Loading';dots++;if(dots>=dotmax)dots=1;"); //Response.Write("for(var x = 0;x < dots;x++){output += '.';}mydiv.innerText = output;}"); //Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; window.setInterval('ShowWait()', 1000);}"); //Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';window.clearInterval();}"); //Response.Write("StartShowWait();</script>"); //Response.Flush(); //Thread.Sleep(10000) ; //strEmail = (string)Session["Email"]; //strLastName = (string)Session["LastName"]; //strFirstName = (string)Session["FirstName"]; //txtEmail.Text = strEmail; //txtLastName.Text = strLastName; //txtFirstName.Text = strFirstName; if ((String)Session["Email"] != String.Empty) { strEmail = (String)Session["Email"]; txtEmail.Text = strEmail; } if ((String)Session["AccountId"] != String.Empty) { strAccountId = (String)Session["AccountId"]; } else { String strQueryForAccountIdOnEmail = "select Id from Account where cmm_Email__c = '" + strEmail + "'"; SForce.QueryResult qrAccountId = Sfdcbinding.query(strQueryForAccountIdOnEmail); if (qrAccountId.size > 0) { SForce.Account acctHousehold = qrAccountId.records[0] as SForce.Account; strAccountId = acctHousehold.Id; } } //if (!IsPostBack) //{ if ((String)Session["LastName"] != null && (String)Session["FirstName"] != null) { if ((String)Session["LastName"] != String.Empty) { txtLastName.Text = (String)Session["LastName"]; } if ((String)Session["FirstName"] != String.Empty) { txtFirstName.Text = (String)Session["FirstName"]; } } //else if ((String)Session["LastName"] == null || (String)Session["FirstName"] == null) //{ if (!IsPostBack) { String strQueryForPrimaryContactInfo = "select Email, Title, LastName, FirstName, MiddleName, Birthdate, cmm_Gender__c, Social_Security_Number__c, " + "Phone, HomePhone, MobilePhone, OtherPhone from Contact " + "where cmm_Household__c = '" + strAccountId + "' and cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrPrimaryContactInfo = Sfdcbinding.query(strQueryForPrimaryContactInfo); if (qrPrimaryContactInfo.size > 0) { SForce.Contact ctPrimary = qrPrimaryContactInfo.records[0] as SForce.Contact; txtEmail.Text = ctPrimary.Email; switch (ctPrimary.Title) { case "Jr.": ddlTitle.SelectedIndex = 1; break; case "Mr.": ddlTitle.SelectedIndex = 2; break; case "Mrs.": ddlTitle.SelectedIndex = 3; break; case "Ms.": ddlTitle.SelectedIndex = 4; break; } txtLastName.Text = ctPrimary.LastName; txtFirstName.Text = ctPrimary.FirstName; txtMiddleName.Text = ctPrimary.MiddleName; int?nYear = null; int?nMonth = null; int?nDay = null; if (ctPrimary.Birthdate != null) { nYear = ctPrimary.Birthdate.Value.Year; nMonth = ctPrimary.Birthdate.Value.Month; nDay = ctPrimary.Birthdate.Value.Day; DateTime dtPrimaryBirthdate = new DateTime((int)nYear, (int)nMonth, (int)nDay); txtDateOfBirth.Text = dtPrimaryBirthdate.ToString("MM/dd/yyyy"); } if (ctPrimary.cmm_Gender__c == "Male") { rbGenderList.SelectedIndex = 0; } else if (ctPrimary.cmm_Gender__c == "Female") { rbGenderList.SelectedIndex = 1; } if (ctPrimary.Social_Security_Number__c != null) { txtSSN.Text = ctPrimary.Social_Security_Number__c; txtSSN.ReadOnly = true; revSSN.Enabled = false; } if (ctPrimary.Phone != null) { txtTelephone1.Text = ctPrimary.Phone; } if (ctPrimary.MobilePhone != null) { txtTelephone2.Text = ctPrimary.MobilePhone; } if (ctPrimary.OtherPhone != null) { txtTelephone3.Text = ctPrimary.OtherPhone; } } String strQueryForHousehold = "select ShippingAddress from Account where Id = '" + strAccountId + "' and cmm_Email__c = '" + strEmail + "'"; SForce.QueryResult qrHousehold = Sfdcbinding.query(strQueryForHousehold); if (qrHousehold.size > 0) { SForce.Account acctHousehold = qrHousehold.records[0] as SForce.Account; if (acctHousehold.ShippingAddress != null) { txtAddress.Text = acctHousehold.ShippingAddress.street; txtZipCode.Text = acctHousehold.ShippingAddress.postalCode; InitializeStateNames(); ddlState.SelectedValue = acctHousehold.ShippingAddress.state; String strConnectionString = @"Data Source=10.1.10.79; Port=3306; Database=cmmworld_admin; User ID=Hj_p007; Password='******'"; String strQueryForCityName = "select distinct name, state_code from city where state_code = '" + ddlState.SelectedValue.ToString() + "' order by name"; MySqlConnection conn = new MySqlConnection(strConnectionString); MySqlCommand cmdCityName = new MySqlCommand(strQueryForCityName, conn); DataSet dsCity = new DataSet(); MySqlDataAdapter da = new MySqlDataAdapter(cmdCityName); da.Fill(dsCity); ddlCity.DataSource = dsCity.Tables[0]; ddlCity.DataTextField = "name"; ddlCity.DataValueField = "name"; ddlCity.DataBind(); ddlCity.SelectedValue = acctHousehold.ShippingAddress.city; } } if (qrPrimaryContactInfo.size == 0 && qrHousehold.size == 0) { //if (!IsPostBack) //{ //calexDateOfBirth.DefaultView = AjaxControlToolkit.CalendarDefaultView.Years; // This section is commented out, is needed for production code txtSSN.ReadOnly = false; revSSN.Enabled = true; //revSSN.EnableClientScript = true; String strQueryForStateName = "select distinct name, state_code from state order by name"; String strConnectionString = @"Data Source=10.1.10.79; Port=3306; Database=cmmworld_admin; User ID=Hj_p007; Password='******'"; MySqlConnection connState = new MySqlConnection(strConnectionString); MySqlCommand cmdState = new MySqlCommand(strQueryForStateName, connState); DataSet dsState = new DataSet(); MySqlDataAdapter da = new MySqlDataAdapter(cmdState); da.Fill(dsState); ddlState.DataSource = dsState.Tables[0]; ddlState.DataTextField = "name"; ddlState.DataValueField = "state_code"; ddlState.DataBind(); ddlState.Items.Insert(0, new ListItem(String.Empty, String.Empty)); ddlState.SelectedIndex = 0; } LoadPrimarySDAInfo(); } }
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 LoadPrimarySDAInfo() { String strQueryForPrimarySDA = "select cmm_Account__c, cmm_Contact__c, cmm_Name__c, " + "cmm_bCurrentSmoker__c, cmm_bFormerSmoker__c, cmm_bCurrentDrug__c, cmm_bFormerDrug__c, cmm_bAlcohol__c " + "from tmp_SmokingDrugAlcohol__c where cmm_Account__c = '" + strAccountId + "' and " + "cmm_Household_Role__c = 'Head of Household'"; SForce.QueryResult qrPrimarySDA = Sfdcbinding.query(strQueryForPrimarySDA); if (qrPrimarySDA.size > 0) { SForce.tmp_SmokingDrugAlcohol__c tmpPrimarySDA = qrPrimarySDA.records[0] as SForce.tmp_SmokingDrugAlcohol__c; if (tmpPrimarySDA.cmm_bCurrentSmoker__c == "Yes") { btnCurrentSmokerYes.BackColor = Color.Red; btnCurrentSmokerYes.ForeColor = Color.White; btnCurrentSmokerNo.BackColor = Color.LightGray; btnCurrentSmokerNo.ForeColor = Color.Black; hdnCurrentSmokerYes.Value = "red"; hdnCurrentSmokerNo.Value = "lightgrey"; } else if (tmpPrimarySDA.cmm_bCurrentSmoker__c == "No") { btnCurrentSmokerYes.BackColor = Color.LightGray; btnCurrentSmokerYes.ForeColor = Color.Black; btnCurrentSmokerNo.BackColor = Color.Blue; btnCurrentSmokerNo.ForeColor = Color.White; hdnCurrentSmokerYes.Value = "lightgrey"; hdnCurrentSmokerNo.Value = "blue"; } if (tmpPrimarySDA.cmm_bFormerSmoker__c == "Yes") { btnFormerSmokerYes.BackColor = Color.Green; btnFormerSmokerYes.ForeColor = Color.White; btnFormerSmokerNo.BackColor = Color.LightGray; btnFormerSmokerNo.ForeColor = Color.Black; hdnFormerSmokerYes.Value = "green"; hdnFormerSmokerNo.Value = "lightgrey"; } else if (tmpPrimarySDA.cmm_bFormerSmoker__c == "No") { btnFormerSmokerYes.BackColor = Color.LightGray; btnFormerSmokerYes.ForeColor = Color.Black; btnFormerSmokerNo.BackColor = Color.Blue; btnFormerSmokerNo.ForeColor = Color.White; hdnFormerSmokerYes.Value = "lightgrey"; hdnFormerSmokerNo.Value = "blue"; } if (tmpPrimarySDA.cmm_bCurrentDrug__c == "Yes") { btnNarcoticYes.BackColor = Color.Red; btnNarcoticYes.ForeColor = Color.White; btnNarcoticNo.BackColor = Color.LightGray; btnNarcoticNo.ForeColor = Color.Black; hdnNarcoticYes.Value = "red"; hdnNarcoticNo.Value = "lightgrey"; } else if (tmpPrimarySDA.cmm_bCurrentDrug__c == "No") { btnNarcoticYes.BackColor = Color.LightGray; btnNarcoticYes.ForeColor = Color.Black; btnNarcoticNo.BackColor = Color.Blue; btnNarcoticNo.ForeColor = Color.White; hdnNarcoticYes.Value = "lightgrey"; hdnNarcoticNo.Value = "blue"; } if (tmpPrimarySDA.cmm_bFormerDrug__c == "Yes") { btnFormerNarcoticYes.BackColor = Color.Green; btnFormerNarcoticYes.ForeColor = Color.White; btnFormerNarcoticNo.BackColor = Color.LightGray; btnFormerNarcoticNo.ForeColor = Color.Black; hdnFormerNarcoticYes.Value = "green"; hdnFormerNarcoticNo.Value = "lightgrey"; } else if (tmpPrimarySDA.cmm_bFormerDrug__c == "No") { btnFormerNarcoticYes.BackColor = Color.LightGray; btnFormerNarcoticYes.ForeColor = Color.Black; btnFormerNarcoticNo.BackColor = Color.Blue; btnFormerNarcoticNo.ForeColor = Color.White; hdnFormerNarcoticYes.Value = "lightgrey"; hdnFormerNarcoticNo.Value = "blue"; } if (tmpPrimarySDA.cmm_bAlcohol__c == "Yes") { btnAlcoholYes.BackColor = Color.Red; btnAlcoholYes.ForeColor = Color.White; btnAlcoholNo.BackColor = Color.LightGray; btnAlcoholNo.ForeColor = Color.Black; hdnAlcoholYes.Value = "red"; hdnAlcoholNo.Value = "lightgrey"; } else if (tmpPrimarySDA.cmm_bAlcohol__c == "No") { btnAlcoholYes.BackColor = Color.LightGray; btnAlcoholYes.ForeColor = Color.Black; btnAlcoholNo.BackColor = Color.Blue; btnAlcoholNo.ForeColor = Color.White; hdnAlcoholYes.Value = "lightgrey"; hdnAlcoholNo.Value = "blue"; } } }
protected void btnDelete_Click(object sender, EventArgs e) { string strId = (string)Session["CurrentId"]; String[] ids = new String[] { strId }; 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.DeleteResult[] deleteResults = sfdcbinding.delete(ids); SForce.DeleteResult deleteResult = deleteResults[0]; if (deleteResult.success) { lblErrorMessage.Text = "The record id: " + deleteResult.id + " is deleted successfully."; int nCurrentIndex = (int)Session["CurrentIndex"]; nCurrentIndex--; //contact = (SForce.Contact)queryResult.records[nCurrentIndex]; 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; contact = (SForce.Contact)queryResult.records[nCurrentIndex]; txtFirstName.Text = contact.FirstName; txtLastName.Text = contact.LastName; if (contact.MailingAddress != null) { txtStreetAddress.Text = contact.MailingAddress.street; txtCity.Text = contact.MailingAddress.city; txtState.Text = contact.MailingAddress.state; txtZip.Text = contact.MailingAddress.postalCode; } else if (contact.MailingAddress == null) { txtStreetAddress.Text = ""; txtCity.Text = ""; txtState.Text = ""; txtZip.Text = ""; } txtMobilePhone.Text = contact.MobilePhone; txtPhone.Text = contact.Phone; txtEmail.Text = contact.Email; Session["CurrentIndex"] = nCurrentIndex; if (nCurrentIndex == 0) { btnPrev.Enabled = false; btnFirst.Enabled = false; } strId = contact.Id; Session["CurrentId"] = strId; } else { lblErrorMessage.Text = "Error: " + deleteResult.errors[0].message; } }
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; } }
protected void Page_Load(object sender, EventArgs e) { strUserName = "******"; strPasswd = "speed5of5light5"; if (!IsPostBack) { nCurrentIndex = 0; nTotalRecord = 0; nCurrentIndexTask = 0; System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls; //Sfdcbinding = new SForce.SforceService(); //CurrentLoginResult = Sfdcbinding.login(strUserName, strPasswd); //Sfdcbinding.Url = CurrentLoginResult.serverUrl; //Sfdcbinding.SessionHeaderValue = new SForce.SessionHeader(); //Sfdcbinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId; //strQuery = "select Id, FirstName, LastName, MailingAddress, Email, MobilePhone, Phone from Contact order by LastName nulls last"; //queryResult = Sfdcbinding.query(strQuery); //nTotalRecord = queryResult.size - 1; btnCreateNewContact.Enabled = false; btnSave.Enabled = false; btnEdit.Enabled = false; btnUpdate.Enabled = false; btnCancel.Enabled = false; btnDelete.Enabled = false; txtFirstName.ReadOnly = true; txtLastName.ReadOnly = true; txtStreetAddress.ReadOnly = true; txtCity.ReadOnly = true; txtState.ReadOnly = true; txtZip.ReadOnly = true; txtPhone.ReadOnly = true; txtMobilePhone.ReadOnly = true; txtEmail.ReadOnly = true; //strQuerySelectFromContact = "select Id, FirstName, LastName, MailingAddress, Email, MobilePhone, Phone from Contact order by LastName nulls last"; //strQuerySelectFromMembership = "select Id, Membership.c4g_Membership_Status__c, c4g_Number_of_Gold_Medi_Members__c from Membership nulls last"; //strQuerySelectFromContactIncludeMembership = "select Contact.Id, Contact.FirstName, Contact.LastName " + // "(select Membership.c4g_Membership_Status__c, c4g_Number_of_Gold_Medi_Members__c, " + // "c4g_Number_of_Gold_Members__c, c4g_Number_of_Gold_Plus_Members__c, " + // "Number_of_Members_Units__c, Paying_Member__c, " + // "Registration_Date__c, c4g_Start_Date__c " + // "from Membership) from Contact " + // "where Contact.Id in (select Membership.ContactId from Membership) nulls last"; } //strQuerySelectFromContact = "select Id, c4g_Membership__c, Individual_ID__c, FirstName, LastName, MailingAddress, Email, MobilePhone, Phone from Contact order by LastName nulls last"; strQueryMembershipIdInContact = "select Contact.c4g_Membership__c from Contact order by LastName nulls last"; strQuerySelectFromMembership = "select Id, Name, c4g_Membership_Status__c from Membership__c"; /// This is the current working inner join version strQueryContactInnerJoinMembership = "select Id, Individual_ID__c, FirstName, LastName, MailingAddress, Email, MobilePhone, Phone, " + "(select Name, Id from Memberships__r) from Contact " + "where Contact.c4g_Membership__c in (select Membership__c.Id from Membership__c) " + "order by Contact.LastName, Contact.FirstName nulls last"; // SELECT Name, (SELECT Name FROM Job_Applications__r) FROM Position__c // This is the Left Outer Join version. strQueryContactLeftOuterJoinMembership = "select Id, Individual_ID__c, FirstName, LastName, MailingAddress, Email, MobilePhone, Phone, " + "c4g_Membership__r.Name, c4g_Membership__r.Id from Contact " + "order by Contact.LastName, Contact.FirstName nulls last"; strQueryTask = "select Id, Description from Task"; Sfdcbinding = new SForce.SforceService(); CurrentLoginResult = Sfdcbinding.login(strUserName, strPasswd); Sfdcbinding.Url = CurrentLoginResult.serverUrl; Sfdcbinding.SessionHeaderValue = new SForce.SessionHeader(); Sfdcbinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId; //queryResult = Sfdcbinding.query(strQuerySelectFromContact); // This is Contact Inner Join Membership //queryResult = Sfdcbinding.query(strQueryContactInnerJoinMembership); // This is Contact Outer Join Membership queryResultTask = Sfdcbinding.query(strQueryTask); queryResult = Sfdcbinding.query(strQueryContactLeftOuterJoinMembership); nTotalRecord = queryResult.size - 1; //////////////////////////////////////////////////////////////////////////////// // Testing for select from membership //SForce.SforceService sfdcbindingMembership = new SForce.SforceService(); //SForce.LoginResult LoginResult = sfdcbindingMembership.login(strUserName, strPasswd); //sfdcbindingMembership.Url = LoginResult.serverUrl; //sfdcbindingMembership.SessionHeaderValue = new SForce.SessionHeader(); //sfdcbindingMembership.SessionHeaderValue.sessionId = LoginResult.sessionId; //SForce.QueryResult QueryResultMembership = sfdcbindingMembership.query(strQuerySelectFromMembership); }
protected void btnLoad_Click(object sender, EventArgs e) { //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; if (queryResult.size > 0) { contact = (SForce.Contact)queryResult.records[nCurrentIndex]; txtIndividualId.Text = contact.Individual_ID__c; txtId.Text = contact.Id; //SForce.Membership__c member = (SForce.Membership__c) contact.Memberships__r.records[0]; if (contact.c4g_Membership__r != null) { txtMembershipId.Text = contact.c4g_Membership__r.Id; txtMembershipNameInContact.Text = contact.c4g_Membership__r.Name; } else { txtMembershipId.Text = ""; txtMembershipNameInContact.Text = ""; } //if (contact.c4g_Membership__r != null) //{ // txtMembershipId.Text = contact.c4g_Membership__r.Id; // txtMembershipInContact.Text = contact.c4g_Membership__r.Name; //} //else if (contact.c4g_Membership__r == null) //{ // txtMembershipId.Text = ""; // txtMembershipInContact.Text = ""; //} //txtMembershipId.Text = member.Id; //txtMembershipNameInContact.Text = member.Name; ; txtFirstName.Text = contact.FirstName; txtLastName.Text = contact.LastName; if (contact.MailingAddress != null) { txtStreetAddress.Text = contact.MailingAddress.street; txtCity.Text = contact.MailingAddress.city; txtState.Text = contact.MailingAddress.state; txtZip.Text = contact.MailingAddress.postalCode; } else if (contact.MailingAddress == null) { txtStreetAddress.Text = ""; txtCity.Text = ""; txtState.Text = ""; txtZip.Text = ""; } txtMobilePhone.Text = contact.MobilePhone; txtPhone.Text = contact.Phone; txtEmail.Text = contact.Email; } btnFirst.Enabled = false; btnPrev.Enabled = false; btnCreateNewContact.Enabled = true; btnEdit.Enabled = true; btnDelete.Enabled = true; lblErrorMessage.Text = ""; //////////////////////////////////////////////////////////////////////////////// // Testing for select from membership SForce.SforceService sfdcbindingMembership = new SForce.SforceService(); SForce.LoginResult LoginResult = sfdcbindingMembership.login(strUserName, strPasswd); sfdcbindingMembership.Url = LoginResult.serverUrl; sfdcbindingMembership.SessionHeaderValue = new SForce.SessionHeader(); sfdcbindingMembership.SessionHeaderValue.sessionId = LoginResult.sessionId; queryResultMembership = sfdcbindingMembership.query(strQuerySelectFromMembership); //strQueryMembershipIdInContact ///////////////////////////////////// // Testing for Membership field in Contact SForce.QueryResult queryMembershipInContact = sfdcbindingMembership.query(strQueryMembershipIdInContact); //SForce.QueryResult queryContactInnerJoinMembership = sfdcbindingMembership.query(strQueryContactInnerJoinMembership); if (queryMembershipInContact.size > 0) { SForce.Contact contactMembership = (SForce.Contact)queryMembershipInContact.records[0]; txtMembershipInContact.Text = contactMembership.c4g_Membership__c; } if (queryResultMembership.size > 0) { SForce.Membership__c membership = (SForce.Membership__c)queryResultMembership.records[0]; //SForce.Contact contact = (SForce.Contact)queryResultMembership.records[0]; txtContactId.Text = membership.Id; txtMembershipName.Text = membership.Name; txtMembershipStatus.Text = membership.c4g_Membership_Status__c; //txtContactId.Text = contact.Id; //txtMembershipName.Text = contact.Name; ; //membership.Name; //txtMembershipStatus.Text = contact.c4g_Membership_Status__c; //membership.c4g_Membership_Status__c; int nMemberIndex = 0; Session["MemberIndex"] = nMemberIndex; } if (queryResultTask.size > 0) { SForce.Task task = (SForce.Task)queryResultTask.records[nCurrentIndexTask]; txtTaskName.Text = task.Id; txtTaskComment.Text = task.Description; Session["TaskIndex"] = ++nCurrentIndexTask; Session["CurrentTaskId"] = task.Id; } }