protected void btnSaveAndContinue_Click(object sender, EventArgs e) { bool isDuplicate = false; Leads objLead = null; lblError.Text = string.Empty; lblError.Visible = false; lblSave.Text = string.Empty; lblSave.Visible = false; lblMessage.Visible = false; lblMessage.Text = string.Empty; bool isNew = false; Page.Validate("NewLead"); if (!Page.IsValid) { return; } try { if (ViewState["LeadIds"] == null) { // new lead/claim objLead = new Leads(); objLead.UserId = Convert.ToInt32(Session["UserId"]); // 2013-07-19 objLead.ClientID = Convert.ToInt32(Session["ClientId"]); objLead.DateSubmitted = DateTime.Now; objLead.Status = 1; isNew = true; } else { objLead = LeadsManager.GetByLeadId(Convert.ToInt32(ViewState["LeadIds"].ToString())); } //int claimsNumber = 0; objLead.Longitude = Convert.ToDouble(hf_Longitude.Value); objLead.Latitude = Convert.ToDouble(hf_Latitude.Value); DateTime?originalLeadDate = null; if (!string.IsNullOrEmpty(txtOriginalLeadDate.Text.Trim())) { originalLeadDate = Convert.ToDateTime(txtOriginalLeadDate.Text.Trim()); } //DateTime.TryParse(txtOriginalLeadDate.Text.Trim(), out originalLeadDate); DateTime?lastContactDate = null; DateTime?siteSurveyDate = null; objLead.OriginalLeadDate = originalLeadDate; //DateTime? lossDate = null; //if (!string.IsNullOrEmpty(txtLossDate.Text.Trim())) // lossDate = Convert.ToDateTime(txtLossDate.Text.Trim()); //objLead.LossDate = lossDate; // 2013-10-29 tortega objLead.LossLocation = txtLossLocation.Text.Trim(); //objLead.ClaimsNumber = claimsNumber; objLead.InsuredName = txtInsuredName.Text.Trim(); objLead.ClaimantFirstName = txtClaimantName.Text.Trim();; objLead.ClaimantLastName = txtClaimantLastName.Text.Trim(); objLead.ClaimantMiddleName = txtClaimantMiddleName.Text.Trim(); objLead.Salutation = txtSalutation.Text.Trim(); objLead.BusinessName = txtBusinessName.Text; objLead.SecondaryLeadSource = txtSecondaryLeadSource.Text; if (Convert.ToInt32(ddlUmpire.SelectedValue) != 0) { objLead.UmpireID = Convert.ToInt32(ddlUmpire.SelectedValue); } if (Convert.ToInt32(ddlContractor.SelectedValue) != 0) { objLead.ContractorID = Convert.ToInt32(ddlContractor.SelectedValue); } if (Convert.ToInt32(ddlAppraiser.SelectedValue) != 0) { objLead.AppraiserID = Convert.ToInt32(ddlAppraiser.SelectedValue); } // mailing address objLead.MailingAddress = txtMailingAddress.Text.Trim(); objLead.MailingAddress2 = txtMailingAddress2.Text.Trim(); objLead.MailingCity = txtMailingCity.Text.Trim(); if (ddlMailingState.SelectedIndex > 0) { objLead.MailingState = ddlMailingState.SelectedValue; } objLead.MailingZip = txtMailingZip.Text.Trim(); // Loss Address objLead.LossAddress = txtLossAddress.Text; objLead.LossAddress2 = txtLossAddress2.Text; if (ddlState.SelectedIndex > 0) { objLead.StateName = ddlState.SelectedValue; } objLead.CityName = txtCityName.Text; objLead.Zip = txtZipCode.Text; // check for duplicate name/address isDuplicate = LeadsManager.CheckForDuplicate(objLead); if (isDuplicate) { lblError.Text = "Duplicate clients not allowed."; lblError.Visible = true; return; } objLead.EmailAddress = txtEmail.Text; if (Convert.ToInt32(ddlLeadSource.SelectedValue) != 0) { objLead.LeadSource = Convert.ToInt32(ddlLeadSource.SelectedValue); } if (Convert.ToInt32(ddlPrimaryProducer.SelectedValue) != 0) { objLead.PrimaryProducerId = Convert.ToInt32(ddlPrimaryProducer.SelectedValue); } if (Convert.ToInt32(ddlSecondaryProducer.SelectedValue) != 0) { objLead.SecondaryProducerId = Convert.ToInt32(ddlSecondaryProducer.SelectedValue); } objLead.PhoneNumber = txtPhoneNumber.Text; objLead.MobilePhone = txtMobilePhone.Text; //string Damagetxt = string.Empty; //string DamageId = string.Empty; //for (int j = 0; j < chkTypeOfDamage.Items.Count; j++) { // if (chkTypeOfDamage.Items[j].Selected == true) { // Damagetxt += chkTypeOfDamage.Items[j].Text + ','; // DamageId += chkTypeOfDamage.Items[j].Value + ','; // } //} //if (Damagetxt != string.Empty && DamageId != string.Empty) { // objLead.TypeOfDamage = DamageId; // objLead.TypeofDamageText = Damagetxt; //} //if (Convert.ToInt32(ddlTypeOfProperty.SelectedValue) != 0) { // objLead.TypeOfProperty = Convert.ToInt32(ddlTypeOfProperty.SelectedValue); //} objLead.IsSubmitted = true; objLead.SiteSurveyDate = siteSurveyDate; objLead.LastContactDate = lastContactDate; if (Convert.ToInt32(ddlOwnerSame.SelectedValue) != 0) { objLead.OwnerSame = Convert.ToInt32(ddlOwnerSame.SelectedValue); } objLead.OwnerFirstName = txtOwnerFirstName.Text.Trim(); objLead.OwnerLastName = txtOwnerLastName.Text.Trim(); objLead.OwnerPhone = txtOwnerPhone.Text.Trim(); // 2013-03-11 tortega added owner email objLead.OwnerEmail = txtOwnerEmail.Text.Trim(); objLead.SecondaryEmail = txtSecondaryEmail.Text.Trim(); objLead.SecondaryPhone = txtSecondaryPhone.Text.Trim(); //save new fields if (!string.IsNullOrEmpty(txtBirthdate.Text)) { objLead.Birthdate = Convert.ToDateTime(txtBirthdate.Text); } objLead.Reference = txtReference.Text; objLead.Languages = txtLanguage.Text; objLead.Title = txtTitle.Text; objLead.LossCounty = txtlossCountry.Text; objLead.MailingCounty = txtMailingCountry.Text; Leads ins = LeadsManager.Save(objLead); if (ins.LeadId > 0) { int categoryId = ContactManager.GetContactId("Claimant");; Contact objcontact = ContactManager.GetLeadContact(objLead.LeadId, categoryId); string[] name = txtThirdPartyName.Text.Split(' '); int nameLength = name.Length; string firstName = string.Empty; string lastName = string.Empty; firstName = firstName.Trim(); if (nameLength > 1) { for (int count = 0; count <= nameLength - 2; count++) { firstName = firstName + " " + name[count]; } lastName = name[nameLength - 1]; } else { firstName = name[0]; } Contact contact = null; contact = new Contact(); if (objcontact != null) { contact.ContactID = objcontact.ContactID; } contact.LeadId = ins.LeadId; contact.ClientID = SessionHelper.getClientId(); contact.UserID = SessionHelper.getUserId(); contact.IsActive = true; contact.FirstName = firstName.Trim(); contact.LastName = lastName.Trim(); contact.ContactName = firstName.Trim() + " " + lastName.Trim();; contact.Address1 = txtThirdPartyStreet.Text; contact.CityName = txtThirdPartyCity.Text; contact.State = txtThirdPartyState.Text; contact.ZipCode = txtThirdPartyPostalCodes.Text; contact.Phone = txtThirdPartyPhoneNumber.Text; contact.CategoryID = categoryId; if (objcontact == null) { contact = ContactManager.SaveContact(contact); //Contact contactupdate = new Contact(); //contactupdate.ContactID = contact.ContactID; //contactupdate.ContactName = contact.ContactName; //contact = ContactManager.UpdateContact(contactupdate); } else { contact = ContactManager.Update(contact); } Session["LeadIds"] = ins.LeadId; ViewState["LeadIds"] = ins.LeadId; //savePolicy(); //SaveLeadLog(objLead); showControls(true); lblSave.Text = "Claim/Lead information saved successfully."; lblSave.Visible = true; //// repopulate policy info after saving a new lead //if (isNew) { // fillPolicy(ins.LeadId); //} } } catch (Exception ex) { lblError.Text = "Your update could not be saved for the following reason(s):<br />" + ex.ToString(); lblError.Visible = true; } }
private Leads createLead(DataRow dataRow) { Leads lead = null; string userFieldName = null; int clientID = SessionHelper.getClientId(); int userID = SessionHelper.getUserId(); string insuredName = null; string strValue = null; // insured name userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Insured Name"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { insuredName = dataRow[userFieldName].ToString().Trim(); } if (string.IsNullOrEmpty(insuredName)) { return(null); } lead = new Leads(); lead.ClientID = clientID; lead.UserId = userID; lead.Status = 1; lead.OriginalLeadDate = DateTime.Now; lead.InsuredName = insuredName; // mailing address 1 userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Mailing Address"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.MailingAddress = strValue.Length > 50 ? strValue.Substring(0, 50) : strValue; lead.LossAddress = lead.MailingAddress; } // mailing address 2 userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Mailing Address2"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.MailingAddress2 = strValue.Length > 50 ? strValue.Substring(0, 50) : strValue; lead.LossAddress2 = lead.MailingAddress2; } // mailing city userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Mailing City"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.MailingCity = strValue.Length > 50 ? strValue.Substring(0, 50) : strValue; lead.CityName = lead.MailingCity; } // mailing state userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Mailing State"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.MailingState = strValue.Length > 20 ? strValue.Substring(0, 20) : strValue; lead.StateName = lead.MailingState; } // mailing zip userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Mailing Zip"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.MailingZip = strValue.Length > 10 ? strValue.Substring(0, 10) : strValue; lead.Zip = lead.MailingZip; } // mailing county userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Mailing County"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.MailingCounty = strValue.Length > 50 ? strValue.Substring(0, 50) : strValue; lead.LossCounty = lead.MailingCounty; } // Business Phone Number userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Business Phone Number"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.SecondaryPhone = strValue.Length > 35 ? strValue.Substring(0, 35) : strValue; } // Home Phone Number userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Home Phone Number"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { strValue = dataRow[userFieldName].ToString().Trim(); lead.PhoneNumber = strValue.Length > 35 ? strValue.Substring(0, 35) : strValue; } lead = LeadsManager.Save(lead); return(lead); }
//protected void saveCoverages(int policyID) { // LeadPolicyCoverage coverage = null; // decimal deductible = 0; // foreach (GridViewRow row in gvCoverages.Rows) { // if (row.RowType == DataControlRowType.DataRow) { // TextBox txtCoverage = row.FindControl("txtCoverage") as TextBox; // TextBox txtLimit = row.FindControl("txtLimit") as TextBox; // WebTextEditor txtDeductible = row.FindControl("txtDeductible") as WebTextEditor; // TextBox txtCoinsuranceForm = row.FindControl("txtCoinsuranceForm") as TextBox; // // skip empty rows // if (string.IsNullOrEmpty(txtCoverage.Text) && string.IsNullOrEmpty(txtLimit.Text) && string.IsNullOrEmpty(txtDeductible.Text)) // continue; // coverage = new LeadPolicyCoverage(); // coverage.LeadPolicyID = policyID; // decimal.TryParse(txtDeductible.Text, out deductible); // coverage.Deductible = deductible; // coverage.Description = txtCoverage.Text.Trim(); // LeadPolicyCoverageManager.Save(coverage); // } // } //} protected Leads saveLead() { Leads lead = new Leads(); AdjusterMaster adjuster = null; lead.ClientID = clientID; lead.UserId = userID; lead.Status = 1; //if (roleID == (int)UserRole.Adjuster) { // // assign adjuster // adjuster = AdjusterManager.GetAdjusterByUserID(userID); // if (adjuster != null) // lead.Adjuster = adjuster.AdjusterId; //} lead.ClaimantFirstName = txtInsuredFirstName.Text.Trim(); lead.ClaimantLastName = txtInsuredLastName.Text.Trim(); #region insured loss address lead.LossAddress = txtInsuredLossAddressLine.Text.Trim(); lead.LossAddress2 = txtInsuredLossAddressLine2.Text.Trim(); if (ddlInsuredLossState.SelectedIndex > 0) { lead.StateId = Convert.ToInt32(ddlInsuredLossState.SelectedValue); lead.StateName = ddlInsuredLossState.SelectedItem.Text; } if (this.ddlInsuredLossCity.SelectedIndex > 0) { lead.CityId = Convert.ToInt32(ddlInsuredLossCity.SelectedValue); lead.CityName = ddlInsuredLossCity.SelectedItem.Text; } if (this.ddlInsuredLossZipCode.SelectedIndex > 0) { lead.Zip = ddlInsuredLossZipCode.SelectedItem.Text; } #endregion #region insured mailing address lead.MailingAddress = txtInsuredMailingAddress.Text.Trim(); if (ddlInsuredMailingCity.SelectedIndex > 0) { lead.MailingCity = ddlInsuredMailingCity.SelectedItem.Text; } if (ddlInsuredMailingState.SelectedIndex > 0) { lead.MailingState = ddlInsuredMailingState.SelectedItem.Text; } if (ddlInsuredMailingZipCode.SelectedIndex > 0) { lead.MailingZip = ddlInsuredMailingZipCode.SelectedItem.Text; } #endregion lead.OriginalLeadDate = DateTime.Now; lead.PhoneNumber = txtInsuredPhone.Text.Trim(); lead.EmailAddress = txtInsuredEmail.Text.Trim(); lead.SecondaryPhone = txtInsuredFax.Text.Trim(); if (ddlTypeOfProperty.SelectedIndex > 0) { lead.TypeOfProperty = Convert.ToInt32(ddlTypeOfProperty.SelectedValue); } #region damage type string Damagetxt = string.Empty; string DamageId = string.Empty; for (int j = 0; j < chkTypeOfDamage.Items.Count; j++) { if (chkTypeOfDamage.Items[j].Selected == true) { Damagetxt += chkTypeOfDamage.Items[j].Text + ','; DamageId += chkTypeOfDamage.Items[j].Value + ','; } } if (Damagetxt != string.Empty && DamageId != string.Empty) { lead.TypeOfDamage = DamageId; lead.TypeofDamageText = Damagetxt; } #endregion lead = LeadsManager.Save(lead); return(lead); }
protected void btnSave_click(object sender, EventArgs e) { int userID = 0; Leads lead = null; int leadID = 0; StringBuilder claimList = new StringBuilder(); int transferCount = 0; userID = Convert.ToInt32(ddlUsers.SelectedValue); if (userID > 0) { try { using (TransactionScope scope = new TransactionScope()) { foreach (GridViewRow row in gvUserLeads.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox cbx = row.FindControl("cbxLead") as CheckBox; if (cbx != null && cbx.Checked) { leadID = (int)gvUserLeads.DataKeys[row.RowIndex].Value; lead = LeadsManager.GetByLeadId(leadID); if (lead != null) { lead.UserId = userID; LeadsManager.Save(lead); ++transferCount; claimList.Append(string.Format("<tr align=\"center\"><td>{0}</td>", lead.insuredName)); claimList.Append(string.Format("<td>{0}</td>", lead.LossAddress ?? "")); claimList.Append(string.Format("<td>{0}</td>", lead.CityName ?? "")); claimList.Append(string.Format("<td>{0}</td>", lead.StateName ?? "")); claimList.Append(string.Format("<td>{0:MM/dd/yyyy}</td></tr>", lead.LossDate)); } } } } // foreach scope.Complete(); } // using // send email notification to assigned use //notifyUser(userID, claimList); // reset search //resetSearch(); lblSave.Text = "Transfer completed successfully."; lblSave.Visible = true; } catch (Exception ex) { lblError.Text = "Transfer was not completed due to error."; lblError.Visible = true; Core.EmailHelper.emailError(ex); } } }
protected void grdAllLead_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DoView") { this.Context.Items.Add("selectedleadid", e.CommandArgument.ToString()); this.Context.Items.Add("view", "U"); Server.Transfer("~/protected/admin/newlead.aspx"); } if (e.CommandName == "DoEdit") { this.Context.Items.Add("selectedleadid", e.CommandArgument.ToString()); this.Context.Items.Add("view", ""); Server.Transfer("~/protected/admin/newlead.aspx"); } if (e.CommandName == "DoCopy") { int LId = Convert.ToInt32(e.CommandArgument); try { var list = LeadsManager.GetByLeadId(LId); Leads objlead = new Leads(); // CRM.Web.Utilities.cln.Clone(list); //objlead.Adjuster = list.Adjuster; //objlead.AllDocumentsOnFile = list.AllDocumentsOnFile; objlead.BusinessName = list.BusinessName; objlead.CityId = list.CityId; objlead.ClaimantAddress = list.ClaimantAddress; objlead.ClaimantComments = list.ClaimantComments; objlead.ClaimantFirstName = list.ClaimantFirstName; objlead.ClaimantLastName = list.ClaimantLastName; objlead.ClaimsNumber = list.ClaimsNumber; objlead.DateSubmitted = list.DateSubmitted; objlead.EmailAddress = list.EmailAddress; //objlead.FloodPolicy = list.FloodPolicy; //objlead.Habitable = list.Habitable; objlead.hasCertifiedInsurancePolicy = list.hasCertifiedInsurancePolicy; objlead.hasContentList = list.hasContentList; objlead.hasDamageEstimate = list.hasDamageEstimate; objlead.hasDamagePhoto = list.hasDamagePhoto; objlead.hasDamageReport = list.hasDamageReport; objlead.hasInsurancePolicy = list.hasInsurancePolicy; objlead.hasOwnerContract = list.hasOwnerContract; objlead.hasSignedRetainer = list.hasSignedRetainer; objlead.HearAboutUsDetail = list.HearAboutUsDetail; objlead.InspectorCell = list.InspectorCell; objlead.InspectorEmail = list.InspectorEmail; objlead.InspectorName = list.InspectorName; //objlead.InsuranceAddress = list.InsuranceAddress; //objlead.InsuranceCity = list.InsuranceCity; //objlead.InsuranceCompanyName = list.InsuranceCompanyName; //objlead.InsuranceContactEmail = list.InsuranceContactEmail; //objlead.InsuranceContactName = list.InsuranceContactName; //objlead.InsuranceContactPhone = list.InsuranceContactPhone; //objlead.InsurancePolicyNumber = list.InsurancePolicyNumber; //objlead.InsuranceState = list.InsuranceState; //objlead.InsuranceZipCode = list.InsuranceZipCode; objlead.IsSubmitted = list.IsSubmitted; objlead.LastContactDate = list.LastContactDate; // objlead.LeadComments = list.LeadComments; objlead.LeadSource = list.LeadSource; //objlead.LeadStatus = list.LeadStatus; objlead.LFUUID = list.LFUUID; objlead.LossAddress = list.LossAddress; objlead.MarketValue = list.MarketValue; objlead.OriginalLeadDate = list.OriginalLeadDate; objlead.OtherSource = list.OtherSource; objlead.OwnerFirstName = list.OwnerFirstName; objlead.OwnerLastName = list.OwnerLastName; objlead.OwnerPhone = list.OwnerPhone; objlead.OwnerSame = list.OwnerSame; objlead.PhoneNumber = list.PhoneNumber; objlead.PrimaryProducerId = list.PrimaryProducerId; objlead.PropertyDamageEstimate = list.PropertyDamageEstimate; objlead.ReporterToInsurer = list.ReporterToInsurer; objlead.SecondaryEmail = list.SecondaryEmail; objlead.SecondaryPhone = list.SecondaryPhone; objlead.SecondaryProducerId = list.SecondaryProducerId; objlead.SiteInspectionCompleted = list.SiteInspectionCompleted; objlead.SiteLocation = list.SiteLocation; objlead.SiteSurveyDate = list.SiteSurveyDate; objlead.StateId = list.StateId; objlead.Status = list.Status; //objlead.SubStatus = list.SubStatus; objlead.TypeOfDamage = list.TypeOfDamage; objlead.TypeofDamageText = list.TypeofDamageText; objlead.TypeOfProperty = list.TypeOfProperty; objlead.UserId = list.UserId; objlead.WebformSource = list.WebformSource; //objlead.WindPolicy = list.WindPolicy; objlead.Zip = list.Zip; LeadsManager.Save(objlead); lblSave.Text = "Record Copyed Sucessfully."; lblSave.Visible = true; DoBind(); } catch (Exception ex) { lblError.Text = "Record Not Copyed."; lblError.Visible = true; } } }