コード例 #1
0
        protected void bindBillTo(CRM.Data.Entities.Leads lead)
        {
            ListItem billToItem   = null;
            string   itemValue    = null;
            string   claimantName = null;

            ddlBillTo.Items.Add(new ListItem("Select One", "0"));

            if (lead != null && lead.LeadPolicy != null && lead.LeadPolicy.Count > 0)
            {
                // add insurance company policy
                foreach (CRM.Data.Entities.LeadPolicy policy in lead.LeadPolicy)
                {
                    if (!string.IsNullOrEmpty(policy.InsuranceCompanyName))
                    {
                        itemValue = string.Format("{0}|{1}", policy.PolicyType, policy.CarrierID ?? 0);

                        billToItem = new ListItem(policy.InsuranceCompanyName, itemValue);

                        ddlBillTo.Items.Add(billToItem);
                    }
                }

                // add client mailing address as option
                claimantName = string.Format("{0} {1}", lead.ClaimantFirstName ?? "", lead.ClaimantLastName ?? "");

                itemValue = string.Format("{0}|{1}|{2}|{3}|{4}|{5}",
                                          1,                                    // homeowners
                                          claimantName,
                                          lead.MailingAddress ?? "",
                                          lead.MailingCity ?? "",
                                          lead.MailingState ?? "",
                                          lead.MailingZip ?? ""
                                          );
                ddlBillTo.Items.Add(new ListItem("Policyholder - Mailing Address", itemValue));

                // add client loss address as option
                claimantName = string.Format("{0} {1}", lead.ClaimantFirstName ?? "", lead.ClaimantLastName ?? "");

                itemValue = string.Format("{0}|{1}|{2}|{3}|{4}|{5}",
                                          1,                                    // homeowners
                                          claimantName,
                                          (lead.LossAddress ?? "") + (lead.LossAddress2 ?? ""),
                                          lead.CityName ?? "",
                                          lead.StateName ?? "",
                                          lead.Zip ?? ""
                                          );
                ddlBillTo.Items.Add(new ListItem("Policyholder - Loss Address", itemValue));
            }
        }
コード例 #2
0
        public static List<CurrentLeadPolicy> GetCurrentPolicy(Leads lead)
        {
            List<CurrentLeadPolicy> currentPolicyTypes = null;

            if (lead.LeadPolicy != null) {
                currentPolicyTypes = (from x in lead.LeadPolicy
                                  where x.IsActive
                                  select new CurrentLeadPolicy {
                                      policyTypeDescription = x.LeadPolicyType.Description,
                                      policyTypeID = x.LeadPolicyType.LeadPolicyTypeID
                                  }).ToList();
            }

            return currentPolicyTypes;
        }
コード例 #3
0
        //2014-04-25 deprecated
        public static void loadFieldValues(Leads lead)
        {
            //string homeownerPolicy = null;
            //string commercialPolicy = null;
            //string floodPolicy = null;
            //string earhtquakePolicy = null;

            //string homeownerClaimNumber = null;
            //string commercialClaimNumber = null;
            //string floodClaimNumber = null;
            //string earhtquakeClaimNumber = null;

            //string homeowner_insurance = null;
            //string homeonwer_insurance_address = null;
            //string homeonwer_insurance_address2 = null;
            //string homeowner_insurance_city = null;
            //string homeowner_insurance_state = null;
            //string homeonwer_insurance_zipcode = null;
            //string homeonwer_phone_number = null;

            //string commercial_insurance_address = null;
            //string commercial_insurance_city = null;
            //string commercial_insurance_state = null;
            //string commercial_insurance_zipcode = null;
            //string commercial_phone_number = null;

            //string flood_insurance_address = null;
            //string flood_insurance_city = null;
            //string flood_insurance_state = null;
            //string flood_insurance_zipcode = null;
            //string flood_phone_number = null;

            //string earthquake_insurance_address = null;
            //string earthquake_insurance_city = null;
            //string earthquake_insurance_state = null;
            //string earthquake_insurance_zipcode = null;
            //string earthquake_phone_number = null;

            //CityMaster cityMaster = null;
            //StateMaster stateMaster = null;

            //string lossDate = null;

            //string commercialInsurance = null;
            //string floodInsurance = null;
            //string earhtquakeInsurance = null;

            //// remove existing fields
            //mergeFields.Clear();

            //mergeFields.Add(new mergeField("TODAYS_DATE", DateTime.Now.ToShortDateString()));
            //mergeFields.Add(new mergeField("CLAIMANT_FIRST_NAME", lead.ClaimantFirstName));
            //mergeFields.Add(new mergeField("CLAIMANT_LAST_NAME", lead.ClaimantLastName));

            //mergeFields.Add(new mergeField("LOSS_ADDRESS", lead.LossAddress));
            //mergeFields.Add(new mergeField("LOSS_ADDRESS 2", lead.LossAddress2));
            //mergeFields.Add(new mergeField("LOSS_STATE", lead.StateName));
            //mergeFields.Add(new mergeField("LOSS_CITY", lead.CityName));
            //mergeFields.Add(new mergeField("LOSS_ZIPCODE", lead.Zip));

            //mergeFields.Add(new mergeField("CLAIMANT_MAILING_ADDRESS", lead.MailingAddress));
            //mergeFields.Add(new mergeField("CLAIMANT_MAILING_STATE", lead.MailingState));
            //mergeFields.Add(new mergeField("CLAIMANT_MAILING_CITY", lead.MailingCity));
            //mergeFields.Add(new mergeField("CLAIMANT_MAILING_ZIPCODE", lead.MailingZip));

            //mergeFields.Add(new mergeField("CLAIMANT_PHONE_NUMBER", lead.PhoneNumber));
            //mergeFields.Add(new mergeField("CLAIMANT_EMAIL", lead.EmailAddress));

            //LeadPolicy policy = null;

            //if (lead.LeadPolicies != null) {
            //	#region homeowners
            //	policy = lead.LeadPolicies.FirstOrDefault(x => x.PolicyType == (int)PolicyType.Homeowners);
            //	homeownerPolicy = policy.PolicyNumber;
            //	homeownerClaimNumber = policy.ClaimNumber;
            //	homeowner_insurance = policy.InsuranceCompanyName;
            //	homeonwer_insurance_address = policy.InsuranceAddress;

            //	cityMaster = policy.CityMaster;
            //	homeowner_insurance_city = cityMaster == null ? "" : cityMaster.CityName;

            //	stateMaster = policy.StateMaster;
            //	homeowner_insurance_state = stateMaster == null ? "" : stateMaster.StateName;

            //	string homeowner_zip = policy.InsuranceZipCode ?? "";
            //	homeonwer_insurance_zipcode = getZipCode(homeowner_zip);

            //	homeonwer_phone_number = policy.PhoneNumber ?? "";
            //	#endregion

            //	#region commercial
            //	policy = lead.LeadPolicies.FirstOrDefault(x => x.PolicyType == (int)PolicyType.Commercial);
            //	if (policy != null) {
            //		commercialClaimNumber = policy.ClaimNumber;

            //		commercialPolicy = policy.PolicyNumber;
            //		commercialInsurance = policy.InsuranceCompanyName;
            //		commercial_insurance_address = policy.InsuranceAddress;
            //		cityMaster = policy.CityMaster;
            //		commercial_insurance_city = cityMaster == null ? "" : cityMaster.CityName;

            //		stateMaster = policy.StateMaster;
            //		commercial_insurance_state = stateMaster == null ? "" : stateMaster.StateName;

            //		string commercial_zip = policy.InsuranceZipCode ?? "";
            //		commercial_insurance_zipcode = getZipCode(commercial_zip);

            //		commercial_phone_number = policy.PhoneNumber ?? "";
            //	}
            //	#endregion

            //	#region flood
            //	policy = lead.LeadPolicies.FirstOrDefault(x => x.PolicyType == (int)PolicyType.Flood);
            //	if (policy != null) {
            //		floodClaimNumber = policy == null ? "" : policy.ClaimNumber;
            //		floodPolicy = policy.PolicyNumber;
            //		floodInsurance = policy.InsuranceCompanyName;
            //		flood_insurance_address = policy.InsuranceAddress;
            //		cityMaster = policy.CityMaster;
            //		flood_insurance_city = cityMaster == null ? "" : cityMaster.CityName;

            //		stateMaster = policy.StateMaster;
            //		flood_insurance_state = stateMaster == null ? "" : stateMaster.StateName;

            //		string flood_zip = policy.InsuranceZipCode ?? "";
            //		flood_insurance_zipcode = getZipCode(flood_zip);

            //		flood_phone_number = policy.PhoneNumber;
            //	}
            //	#endregion

            //	#region earthquake
            //	policy = lead.LeadPolicies.FirstOrDefault(x => x.PolicyType == (int)PolicyType.Earthquake);
            //	if (policy != null) {
            //		earhtquakeClaimNumber = policy == null ? "" : policy.ClaimNumber;
            //		earhtquakePolicy = policy.PolicyNumber;
            //		earhtquakeInsurance = policy.InsuranceCompanyName;
            //		earthquake_insurance_address = policy.InsuranceAddress;
            //		cityMaster = policy.CityMaster;
            //		earthquake_insurance_city = cityMaster == null ? "" : cityMaster.CityName;

            //		stateMaster = policy.StateMaster;
            //		earthquake_insurance_state = stateMaster == null ? "" : stateMaster.StateName;

            //		string earthquake_zip = policy.InsuranceZipCode;
            //		earthquake_insurance_zipcode = getZipCode(earthquake_zip);

            //		earthquake_phone_number = policy.PhoneNumber;
            //	}
            //	#endregion

            //}

            //mergeFields.Add(new mergeField("HOMEOWNER_POLICY_NO", homeownerPolicy));
            //mergeFields.Add(new mergeField("COMMERCIAL_POLICY_NO", commercialPolicy));
            //mergeFields.Add(new mergeField("FLOOD_POLICY_NO", floodPolicy));
            //mergeFields.Add(new mergeField("EARTHQUAKE_POLICY_NO", earhtquakePolicy));

            //mergeFields.Add(new mergeField("HOMEOWNER_CLAIM_NUMBER", homeownerClaimNumber));
            //mergeFields.Add(new mergeField("COMMERCIAL_CLAIM_NUMBER", commercialClaimNumber));
            //mergeFields.Add(new mergeField("FLOOD_CLAIM_NUMBER", floodClaimNumber));
            //mergeFields.Add(new mergeField("EARTHQUAKE_CLAIM_NUMBER", earhtquakeClaimNumber));

            //mergeFields.Add(new mergeField("HOMEOWNER_INSURANCE_CO", homeowner_insurance));
            //mergeFields.Add(new mergeField("HOMEONWER_INSURANCE_ADDRESS", homeonwer_insurance_address));
            //mergeFields.Add(new mergeField("HOMEONWER_INSURANCE_ADDRESS2", homeonwer_insurance_address2));
            //mergeFields.Add(new mergeField("HOMEONWER_INSURANCE_CITY", homeowner_insurance_city));
            //mergeFields.Add(new mergeField("HOMEONWER_INSURANCE_STATE", homeowner_insurance_state));
            //mergeFields.Add(new mergeField("HOMEONWER_INSURANCE_ZIPCODE", homeonwer_insurance_zipcode));
            //mergeFields.Add(new mergeField("HOMEONWER_INSURANCE_PHONE", homeonwer_phone_number));

            //mergeFields.Add(new mergeField("COMMERCIAL_INSURANCE_CO", commercialInsurance));
            //mergeFields.Add(new mergeField("COMMERCIAL_INSURANCE_ADDRESS", commercial_insurance_address));
            //mergeFields.Add(new mergeField("COMMERCIAL_INSURANCE_CITY", commercial_insurance_city));
            //mergeFields.Add(new mergeField("COMMERCIAL_INSURANCE_STATE", commercial_insurance_state));
            //mergeFields.Add(new mergeField("COMMERCIAL_INSURANCE_ZIPCODE", commercial_insurance_zipcode));
            //mergeFields.Add(new mergeField("COMMERCIAL_INSURANCE_PHONE", commercial_phone_number));

            //mergeFields.Add(new mergeField("FLOOD_INSURANCE_CO", floodInsurance));
            //mergeFields.Add(new mergeField("FLOOD_INSURANCE_ADDRESS", flood_insurance_address));
            //mergeFields.Add(new mergeField("FLOOD_INSURANCE_CITY", flood_insurance_city));
            //mergeFields.Add(new mergeField("FLOOD_INSURANCE_STATE", flood_insurance_state));
            //mergeFields.Add(new mergeField("FLOOD_INSURANCE_ZIPCODE", flood_insurance_zipcode));
            //mergeFields.Add(new mergeField("FLOOD_INSURANCE_PHONE", flood_phone_number));

            //mergeFields.Add(new mergeField("EARTHQUAKE_INSURANCE_CO", earhtquakeInsurance));
            //mergeFields.Add(new mergeField("EARTHQUAKE_INSURANCE_ADDRESS", earthquake_insurance_address));
            //mergeFields.Add(new mergeField("EARTHQUAKE_INSURANCE_CITY", earthquake_insurance_city));
            //mergeFields.Add(new mergeField("EARTHQUAKE_INSURANCE_STATE", earthquake_insurance_state));
            //mergeFields.Add(new mergeField("EARTHQUAKE_INSURANCE_ZIPCODE", earthquake_insurance_zipcode));
            //mergeFields.Add(new mergeField("EARTHQUAKE_INSURANCE_PHONE", earthquake_phone_number));

            //if (lead.LossDate != null)
            //	lossDate = string.Format("{0:MM-dd-yyyy}", lead.LossDate);

            //mergeFields.Add(new mergeField("LOSS_DATE", lossDate));

            //string[] damageType = lead.TypeofDamageText.Split(',');
            //if (damageType != null && damageType.Length > 0) {
            //	string[] damageCause = damageType.Where(x => !string.IsNullOrEmpty(x)).ToArray();

            //	mergeFields.Add(new mergeField("DAMAGE_CAUSE", string.Join(",", damageCause)));
            //}

            //if (lead.ClientID != null) {
            //	mergeFields.Add(new mergeField("OFFICE_NAME", lead.Client.BusinessName));
            //	mergeFields.Add(new mergeField("FEDERAL_ID_NO", lead.Client.FederalIDNo));
            //	mergeFields.Add(new mergeField("OFFICE_ADDRESS", lead.Client.StreetAddress1 ?? "" + " " + lead.Client.StreetAddress2 ?? ""));
            //	mergeFields.Add(new mergeField("OFFICE_CITY", lead.Client.CityMaster == null ? "" : lead.Client.CityMaster.CityName));
            //	mergeFields.Add(new mergeField("OFFICE_STATE", lead.Client.StateMaster == null ? "" : lead.Client.StateMaster.StateName));
            //	if (lead.Client.ZipCode != null) {
            //		mergeFields.Add(new mergeField("OFFICE_ZIPCODE", getZipCode(lead.Client.ZipCode)));
            //	}
            //}

            //// build field name arrays
            //fieldNames = mergeFields.Select(x => x.fieldName).ToArray();

            //// build field value arrays
            //fieldValues = mergeFields.Select(x => x.fieldValue).ToArray();
        }
コード例 #4
0
        protected void gvUserLeads_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 Copied Sucessfully.";
                    lblSave.Visible = true;
                    DoBind();
                }
                catch (Exception ex) {
                    lblError.Text = "Record Not Copied.";
                    lblError.Visible = true;
                }
            }
        }
コード例 #5
0
        protected void gvUserLeads_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            lblError.Visible = false;
            lblError.Text = string.Empty;
            lblSave.Text = string.Empty;
            lblSave.Visible = false;

            if (e.CommandName == "DoView")
            {
                this.Context.Items.Add("selectedleadid", e.CommandArgument.ToString());
                this.Context.Items.Add("view", "A");
                Server.Transfer("~/protected/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");

                // because of update panels
                // int a = Convert.ToInt32(e.CommandArgument);
                //PUT IN PLACE TO GRAB THE CLAIM ID WHEN THE USER HITS EDIT TO SET THE SESSION VARIABLE TO BE USED IN THE POLLICY GRID
                //TO TAKE CARE OF CLAIM LIMIT STUFF: OC 9/16/14
                Claim claim = null;
                GridViewRow gvRow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                LinkButton lb = (LinkButton)gvRow.FindControl("lbtnClaim");

                string claimNumber = lb.Text;

                if (!string.IsNullOrEmpty(claimNumber))
                {
                    claim = ClaimsManager.Get(claimNumber);

                    if (claim != null)
                    {
                        Session["ClaimID"] = claim.ClaimID;

                    }
                }
                Response.Redirect("~/protected/newlead.aspx?q=" + Core.SecurityManager.EncryptQueryString(e.CommandArgument.ToString()));
            }
            //ADD NOTE
            if(e.CommandName =="AddNotes")
            {
                Claim claim = null;
                int myClaimID = Convert.ToInt32(e.CommandArgument);
                claim = ClaimsManager.Get(myClaimID);

                //Carrier Invoice type for new window
                CarrierInvoiceProfile cip = null;
                int myCIPID = Convert.ToInt32(claim.CarrierInvoiceProfileID);
                cip = CarrierInvoiceProfileManager.Get(myCIPID);
                Session["CarrierType"] = cip.ProfileName;

                //Insured Name for new window
                GridViewRow gvRow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                Label lbl = (Label)gvRow.FindControl("lblInsuredName");
                Session["InsuredName"] = lbl.Text;
                //Leads lead = LeadsManager.GetByLeadId(LeadId);

                //CLient for new window
                GridViewRow gvRow2 = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                Label lblClient = (Label)gvRow.FindControl("lblClient");
                Session["myClient"] = lblClient.Text;

                //Insurer/Branch for new window
                GridViewRow gvRow3 = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                Label lblBranch = (Label)gvRow.FindControl("lblBranch");
                Session["InsurerBranch"] = lblBranch.Text;

                //Net Claim Payable for new window
                decimal d = Convert.ToDecimal(claim.NetClaimPayable);
                Session["ClaimPayable"] = "$" + Math.Round(d, 2);

                if (myClaimID == 0)
                {
                    popUpService.Show();
                    //pnlService.Visible = true;
                }
                else
                {
                    Session["CarrierInvoiceID"] = claim.CarrierInvoiceProfileID;
                    Session["ClaimID"] = e.CommandArgument;
                    Session["ComingFromAllClaims"] = 1;

                    var claimID = Core.SecurityManager.EncryptQueryString(e.CommandArgument.ToString());
                    // Response.Redirect("~/protected/ClaimTimeExpense.aspx?q=" + Core.SecurityManager.EncryptQueryString(e.CommandArgument.ToString()));
                    ScriptManager.RegisterStartupScript(Page, typeof(string), "popup", "window.open('../ClaimTimeExpense.aspx?q=" + claimID + " ' , '_blank');", true);
                    // ScriptManager.RegisterStartupScript(this, typeof(string), "PersonalData", "window.open( 'StudentManager.aspx?id=" + studentid + " ', null,  );", true);
                }
            }
            //ADD EXPENSE
            if (e.CommandName == "AddExpense")
            {
                Claim claim = null;
                int myClaimID = Convert.ToInt32(e.CommandArgument);
                claim = ClaimsManager.Get(myClaimID);

                CarrierInvoiceProfile cip = null;
                int myCIPID = Convert.ToInt32(claim.CarrierInvoiceProfileID);
                cip = CarrierInvoiceProfileManager.Get(myCIPID);
                Session["CarrierType"] = cip.ProfileName;

                //Insured Name for new window
                GridViewRow gvRow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                Label lbl = (Label)gvRow.FindControl("lblInsuredName");
                Session["InsuredName"] = lbl.Text;
                //Leads lead = LeadsManager.GetByLeadId(LeadId);

                //CLient for new window
                GridViewRow gvRow2 = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                Label lblClient = (Label)gvRow.FindControl("lblClient");
                Session["myClient"] = lblClient.Text;

                //Insurer/Branch for new window
                GridViewRow gvRow3 = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                Label lblBranch = (Label)gvRow.FindControl("lblBranch");
                Session["InsurerBranch"] = lblBranch.Text;

                //Net Claim Payable for new window
                decimal d = Convert.ToDecimal(claim.NetClaimPayable);
                Session["ClaimPayable"] = "$" + Math.Round(d, 2);

                if (myClaimID == 0)
                {
                    popUpService.Show();
                    //pnlService.Visible = true;
                }
                else
                {
                    Session["CarrierInvoiceID"] = claim.CarrierInvoiceProfileID;
                    Session["ClaimID"] = e.CommandArgument;
                    Session["ComingFromAllClaimsExpense"] = 1;

                    var claimID = Core.SecurityManager.EncryptQueryString(e.CommandArgument.ToString());
                    // Response.Redirect("~/protected/ClaimTimeExpense.aspx?q=" + Core.SecurityManager.EncryptQueryString(e.CommandArgument.ToString()));
                    ScriptManager.RegisterStartupScript(Page, typeof(string), "popup", "window.open('../ClaimTimeExpense.aspx?q=" + claimID + " ' , '_blank');", true);
                    // ScriptManager.RegisterStartupScript(this, typeof(string), "PersonalData", "window.open( 'StudentManager.aspx?id=" + studentid + " ', null,  );", true);
                }
            }

            if (e.CommandName == "DoDelete")
            {
                int LeadId = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var list = LeadsManager.GetByLeadId(LeadId);
                    list.Status = 0;
                    LeadsManager.Save(list);

                    lblSave.Text = "Record Deleted Successfully.";
                    lblSave.Visible = true;
                    bindLeads();
                }
                catch (Exception ex)
                {
                    lblError.Text = "Record Not Deleted.";
                    lblError.Visible = true;
                }
            }
            if (e.CommandName == "DoCopy")
            {
                int LeadId = Convert.ToInt32(e.CommandArgument);
                try
                {

                    Leads lead = LeadsManager.GetByLeadId(LeadId);

                    var list = LeadsManager.GetByLeadId(LeadId);
                    Leads objlead = new Leads();// CRM.Web.Utilities.cln.Clone(list);

                    objlead.ClientID = SessionHelper.getClientId();

                    //objlead.AllDocumentsOnFile = list.AllDocumentsOnFile;
                    objlead.InsuredName = list.InsuredName;
                    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.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.LeadSource = list.LeadSource;
                    //objlead.LeadStatus = list.LeadStatus;
                    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.Zip = list.Zip;

                    objlead.LossAddress2 = list.LossAddress2;
                    objlead.LossDate = list.LossDate;
                    objlead.LossLocation = list.LossLocation;

                    objlead.StateName = list.StateName;
                    objlead.CityName = list.CityName;

                    objlead = LeadsManager.Save(objlead);

                    copyPolicy(LeadId, objlead.LeadId);

                    copyInvoices(LeadId, objlead.LeadId);

                    copyLienholders(LeadId, objlead.LeadId);

                    copyComments(LeadId, objlead.LeadId);

                    copyContacts(LeadId, objlead.LeadId);

                    lblSave.Text = "Record Copied Successfully.";
                    lblSave.Visible = true;
                    bindLeads();
                }
                catch (Exception ex)
                {
                    lblError.Text = "Record Not Copied.";
                    lblError.Visible = true;
                }
            }
        }
コード例 #6
0
        protected static void exportDemographics(Leads lead, Claim claim)
        {
            Stream imageStream = null;
            string cityName = null;
            string stateName = null;
            string zipCode = null;
            string[] damageType = null;
            string imagePath = null;

            if (lead == null)
                return;

            PdfPTable tblHeader = new PdfPTable(new float[] { 30, 60 });
            tblHeader.WidthPercentage = 90;

            PdfPCell headerCell = new PdfPCell(new Phrase("Policyholder Information"));
            headerCell.Colspan = 2;
            headerCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tblHeader.AddCell(headerCell);
            doc.Add(tblHeader);

            PdfPTable ptable = new PdfPTable(new float[] { 30, 60 });

            addTableCell(ptable, "Insured Name");
            addTableCell(ptable, lead.InsuredName);

            addTableCell(ptable, "First Name");
            addTableCell(ptable, lead.ClaimantFirstName);

            addTableCell(ptable, "Last Name");
            addTableCell(ptable, lead.ClaimantLastName);

            addTableCell(ptable, "Business Name");
            addTableCell(ptable, lead.BusinessName);

            addTableCell(ptable, "Phone");
            addTableCell(ptable, lead.PhoneNumber);

            addTableCell(ptable, " ");
            addTableCell(ptable, lead.SecondaryPhone);

            addTableCell(ptable, "Email");
            addTableCell(ptable, lead.EmailAddress);

            addTableCell(ptable, " ");
            addTableCell(ptable, lead.SecondaryEmail);

            addTableCell(ptable, "Loss Address");
            addTableCell(ptable, lead.LossAddress);

            addTableCell(ptable, " ");
            addTableCell(ptable, lead.LossAddress2);

            cityName = lead.CityName ?? " ";
            stateName = lead.StateName ?? " ";
            zipCode = lead.Zip ?? " ";

            addTableCell(ptable, " ");
            addTableCell(ptable, cityName + ", " + stateName + " " + zipCode);

            addTableCell(ptable, "Type of Loss");

            if (!string.IsNullOrEmpty(claim.CauseOfLoss)) {
                string[] causeOfLossDescriptions = TypeofDamageManager.GetDescriptions(claim.CauseOfLoss);

                string typeOfLoss = string.Join(",", causeOfLossDescriptions);
                addTableCell(ptable, typeOfLoss);
            }

            //addTableCell(ptable, "Lead Source");
            //addTableCell(ptable, lead.LeadSourceMaster == null ? " " : lead.LeadSourceMaster.LeadSourceName);

            doc.Add(ptable);

            //if (lead.Latitude != null && lead.Longitude != null) {
            //	imageStream = bingMapHelper.getMapImage(lead.Latitude, lead.Longitude);

            //	// add areal map to pdf
            //	if (imageStream != null) {
            //		Image img = iTextSharp.text.Image.GetInstance(imageStream);

            //		PdfPTable maptable = new PdfPTable(new float[] { 90 });
            //		maptable.WidthPercentage = 90;

            //		PdfPCell filler = new PdfPCell(new Phrase(" "));
            //		filler.Border = 0;
            //		maptable.AddCell(filler);

            //		PdfPCell imageHeader = new PdfPCell(new Phrase("Loss Map"));
            //		imageHeader.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            //		imageHeader.VerticalAlignment = PdfPCell.ALIGN_CENTER;
            //		//imageHeader.PaddingBottom = 10f;
            //		//imageHeader.PaddingTop = 10f;
            //		maptable.AddCell(imageHeader);

            //		img.ScaleToFit(500f, 400f);
            //		PdfPCell cellp = new PdfPCell(img, false);

            //		cellp.HorizontalAlignment = PdfPCell.ALIGN_MIDDLE;
            //		cellp.VerticalAlignment = PdfPCell.ALIGN_TOP;

            //		cellp.Padding = 2f;
            //		//cellp.PaddingBottom = 2;
            //		//cellp.PaddingRight = 2;
            //		cellp.BorderWidthLeft = 1f;
            //		cellp.BorderWidthRight = 1f;
            //		cellp.BorderWidthTop = 1f;
            //		cellp.BorderWidthBottom = 1f;
            //		maptable.AddCell(cellp);

            //		doc.Add(maptable);
            //	}
            //}
        }
コード例 #7
0
        public static string SaveClaimExpense(string expenseType, string insurerClaimId, string insurerName, int claimAdjusterId, string adjusterComapnyName, string updatedby, string commentNote, string emailTo, int carrierID, int claimID, string recipientId, string claimAdjuster, string expenseTypeName, string carrier, string idOf, string expenseQty, string expenseAmount, string expenseDate, string reimbrance)
        {
            string json = "";
            Claim objclaim = null;
            AdjusterMaster objAdjusterMaster = null;
            Leads objLeads = null;
            ClaimComment comment = null;
            ClaimExpense claimExpense = null;
            CRM.Data.Entities.LeadPolicy objLeadPolicy = null;
            int userID = SessionHelper.getUserId();
            int leadID = 0;
            int policyId = 0;
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimManager repository = new ClaimManager())
                    {
                        objclaim = new Claim();
                        objclaim.ClaimID = claimID;

                        objclaim.InsurerClaimNumber = insurerClaimId;
                        //objclaim.CarrierID = carrierID;
                        objclaim.AdjusterID = claimAdjusterId;
                        // objclaim.StatusUpdatedBy = updatedby;
                        repository.UpdateClaimStatus(objclaim);

                        // AdjusterMaster
                        objAdjusterMaster = new AdjusterMaster();
                        objAdjusterMaster.AdjusterId = claimAdjusterId;
                        //objAdjusterMaster.CompanyName = AdjusterComapnyName;
                        repository.UpdateAdjusterName(objAdjusterMaster);

                        //leads
                        leadID = repository.GetPolicyId(claimID);
                        objLeads = new Leads();
                        objLeads.LeadId = leadID;
                        objLeads.InsuredName = insurerName;
                        repository.UpdateInsurerName(objLeads);
                        //save carrier id in Lead policy
                        policyId = repository.GetLeadPolicyId(claimID);
                        objLeadPolicy = new Data.Entities.LeadPolicy();
                        objLeadPolicy.Id = policyId;
                        objLeadPolicy.CarrierID = carrierID;
                        repository.UpdateCarrierId(objLeadPolicy);

                        //add expense
                        ClaimExpenseManager objClaimExpenseManager = new ClaimExpenseManager();
                        claimExpense = new ClaimExpense();
                        claimExpense.ClaimID = claimID;
                        if (!string.IsNullOrEmpty(expenseAmount))
                        {
                            claimExpense.ExpenseAmount = Convert.ToDecimal(expenseAmount);
                        }
                        if (!string.IsNullOrEmpty(expenseDate))
                        {
                            claimExpense.ExpenseDate = Convert.ToDateTime(expenseDate);
                        }
                        claimExpense.ExpenseDescription = commentNote.Trim();
                        claimExpense.ExpenseTypeID = Convert.ToInt32(expenseType);
                        if (reimbrance == "1")
                        {
                            claimExpense.IsReimbursable = true;
                        }
                        else
                        {
                            claimExpense.IsReimbursable = false;
                        }

                        claimExpense.UserID = userID;
                        claimExpense.AdjusterID = Convert.ToInt32(claimAdjusterId);
                        if (!string.IsNullOrEmpty(expenseQty))
                        {
                            claimExpense.ExpenseQty = Convert.ToDecimal(expenseQty);
                        }
                        objClaimExpenseManager.Save(claimExpense);

                        //claim comment for add notes
                        comment = new ClaimComment();
                        comment.ClaimID = claimID;
                        comment.IsActive = true;
                        comment.UserId = Core.SessionHelper.getUserId();
                        comment.CommentDate = DateTime.Now;
                        comment.ActivityType = "Add Expense";
                        comment.CommentText = string.Format("Expense: {0}, Description: {1}, Date: {2:MM/dd/yyyy}, Amount: {3:N2}, Adjuster: {4} Qty: {5:N2}",
                                                 expenseTypeName,
                                                 commentNote.Trim(),
                                                 Convert.ToDateTime(expenseDate),
                                                 expenseAmount,
                                                 claimAdjuster,
                                                 expenseQty
                                                 );
                        ClaimCommentManager.Save(comment);

                    }
                    scope.Complete();
                }
                string[] recipId = recipientId.Split(',');
                string recipientEmailId = string.Empty;

                string[] IdofTable = idOf.Split(',');
                int index2 = 0;
                for (int index = 0; index < recipId.Length; index++)
                {
                    index2 = 0;
                    int.TryParse(recipId[index], out index2);
                    if (IdofTable[index] == "c")
                    {

                        Contact objContact = ContactManager.Get(index2);
                        if (!string.IsNullOrEmpty(objContact.Email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objContact.Email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objContact.Email;
                            }
                        }
                    }
                    else
                    {

                        AdjusterMaster objAdjuster = AdjusterManager.GetAdjusterId(index2);

                        if (!string.IsNullOrEmpty(objAdjuster.email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objAdjuster.email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objAdjuster.email;
                            }
                        }

                    }
                }
                SendExpenseEmail(expenseType, insurerClaimId, insurerName, claimAdjusterId, adjusterComapnyName, updatedby, commentNote, "", carrierID, claimID, recipientEmailId, claimAdjuster, expenseTypeName, carrier, recipId, IdofTable, expenseQty, expenseAmount, expenseDate, reimbrance);
                json = "Expense add successfully";

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
            }

            return json;
        }
コード例 #8
0
        protected void UploadTemplate2_bak()
        {
            // original format designed by Vivek
            lblSave.Text = string.Empty;
            lblSave.Visible = false;
            lblError.Text = string.Empty;
            lblError.Visible = false;
            lblMessage.Text = string.Empty;
            lblMessage.Visible = false;
            // 2013-02-09 tortega -- Added data validation prior to import. File is not aborted in the event of incorrect data.
            string str = null;

            int clientID = Core.SessionHelper.getClientId();

            // assume homeowner
            int policyType = 1;
            DateTime DateSubmitted = DateTime.Now;

            try {
                if (FileUpload1.HasFile) {

                    string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
                    string ActualFileName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(@"\") + 1);
                    string FileNameWithoutExt = ActualFileName.Replace(ext, "");
                    if (ext == ".csv") {

                        if (!Directory.Exists(Server.MapPath("~//CSVLoad//"))) {
                            Directory.CreateDirectory(Server.MapPath("~//CSVLoad//"));
                        }
                        FileUpload1.SaveAs(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName));
                        DataTable table = CSVReader.ReadCSVFile(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName), true);
                        using (TransactionScope scope = new TransactionScope()) {
                            Leads objLead = null;
                            for (int i = 0; i < table.Rows.Count; i++) {

                                objLead = new Leads();

                                //objLead.LeadStatus = 1;	// active
                                objLead.OriginalLeadDate = DateTime.Now;
                                objLead.TypeOfProperty = 18;	//residential
                                objLead.UserId = Convert.ToInt32(Session["UserId"]);

                                if (table.Rows[i]["Create Date"] != string.Empty) {

                                    DateTime.TryParse(table.Rows[i]["Create Date"].ToString(), out DateSubmitted);

                                    objLead.DateSubmitted = DateSubmitted;

                                    objLead.OriginalLeadDate = DateSubmitted;
                                }

                                if (table.Rows[i]["Last Name"] != string.Empty) {
                                    str = table.Rows[i]["Last Name"].ToString();
                                    if (str.Length > 50) {
                                        objLead.ClaimantLastName = str.Substring(0, 50);
                                        objLead.OwnerLastName = objLead.ClaimantLastName;
                                    }
                                    else {
                                        objLead.ClaimantLastName = str;
                                        objLead.OwnerLastName = str;
                                    }
                                }

                                if (table.Rows[i]["First Name"] != string.Empty) {
                                    str = table.Rows[i]["First Name"].ToString();
                                    if (str.Length > 50) {
                                        objLead.ClaimantFirstName = str.Substring(0, 50);
                                        objLead.OwnerFirstName = objLead.ClaimantFirstName;
                                    }
                                    else {
                                        objLead.ClaimantFirstName = str;
                                        objLead.OwnerFirstName = str;
                                    }
                                }

                                if (table.Rows[i]["Middle Name"] != string.Empty) {
                                    str = table.Rows[i]["Middle Name"].ToString();
                                    if (str.Length > 50) {
                                        objLead.ClaimantMiddleName = str.Substring(0, 50);
                                    }
                                    else {
                                        objLead.ClaimantMiddleName = str;
                                    }
                                }

                                if (table.Rows[i]["E-mail"] != string.Empty) {
                                    str = table.Rows[i]["E-mail"].ToString();
                                    if (str.Length > 100)
                                        objLead.EmailAddress = str.Substring(0, 100);
                                    else
                                        objLead.EmailAddress = str;
                                }
                                if (table.Rows[i]["Personal E-mail"] != string.Empty) {
                                    str = table.Rows[i]["Personal E-mail"].ToString();
                                    if (str.Length > 100)
                                        objLead.SecondaryEmail = str.Substring(0, 100);
                                    else
                                        objLead.SecondaryEmail = str;
                                }

                                if (table.Rows[i]["Mobile Phone"] != string.Empty) {
                                    str = table.Rows[i]["Mobile Phone"].ToString();
                                    if (str.Length > 20)
                                        objLead.SecondaryPhone = str.Substring(0, 20);
                                    else
                                        objLead.SecondaryPhone = str;
                                }

                                if (table.Rows[i]["Salutation"] != string.Empty) {
                                    str = table.Rows[i]["Salutation"].ToString();
                                    if (str.Length > 50)
                                        objLead.Salutation = str.Substring(0, 20);
                                    else
                                        objLead.Salutation = str;
                                }

                                string adjusterName = null;
                                int? adjusterID = null;
                                AdjusterMaster adjuster = null;

                                if (table.Rows[i]["Adjuster Name"] != string.Empty)
                                    adjusterName = table.Rows[i]["Adjuster Name"].ToString();

                                string adjusterEmail = null;
                                string adjusterFax = null;
                                string AdjusterPhone = null;
                                string AdjusterCo = null;
                                string AdjusterAddress = null;

                                if (table.Rows[i]["Adjuster Email"] != string.Empty)
                                    adjusterEmail = table.Rows[i]["Adjuster Email"].ToString();

                                if (table.Rows[i]["Adjuster Fax"] != string.Empty)
                                    adjusterFax = table.Rows[i]["Adjuster Fax"].ToString();

                                if (table.Rows[i]["Adjuster Phone"] != string.Empty)
                                    AdjusterPhone = table.Rows[i]["Adjuster Phone"].ToString();

                                if (table.Rows[i]["Adjuster Co"] != string.Empty)
                                    AdjusterCo = table.Rows[i]["Adjuster Co"].ToString();

                                if (table.Rows[i]["Adj Address"] != string.Empty)
                                    AdjusterAddress = table.Rows[i]["Adj Address"].ToString();

                                if (!string.IsNullOrEmpty(adjusterName)) {
                                    adjuster = AdjusterManager.GetByAdjusterName(adjusterName.Trim());
                                    if (adjuster.AdjusterId == 0) {
                                        // add adjuster
                                        adjuster = new AdjusterMaster();
                                        adjuster.Status = true;
                                        adjuster.AdjusterName = adjusterName.Trim();
                                        adjuster.ClientId = clientID;
                                        adjuster.InsertBy = objLead.UserId;
                                        adjuster.InsertDate = DateTime.Now;
                                        adjuster.isEmailNotification = true;
                                        adjuster.email = adjusterEmail;
                                        adjuster.Address1 = AdjusterAddress;
                                        adjuster.PhoneNumber = AdjusterPhone;
                                        adjuster.FaxNumber = adjusterFax;
                                        adjuster.CompanyName = AdjusterCo;
                                        adjuster = AdjusterManager.Save(adjuster);
                                    }

                                    adjusterID = adjuster.AdjusterId;
                                }

                                if (table.Rows[i]["Date of Loss"] != string.Empty) {
                                    DateTime lossDate = DateTime.MinValue;
                                    if (DateTime.TryParse(table.Rows[i]["Date of Loss"].ToString(), out lossDate))
                                        objLead.LossDate = lossDate;
                                }

                                if (table.Rows[i]["Loss Location"] != string.Empty)
                                    objLead.LossLocation = table.Rows[i]["Loss Location"].ToString();

                                if (table.Rows[i]["Address 1"] != string.Empty)
                                    objLead.LossAddress = table.Rows[i]["Address 1"].ToString();

                                if (table.Rows[i]["Address 2"] != string.Empty)
                                    objLead.LossAddress2 = table.Rows[i]["Address 2"].ToString();

                                if (table.Rows[i]["City"] != string.Empty)
                                    objLead.CityName = table.Rows[i]["City"].ToString();

                                if (table.Rows[i]["State"] != string.Empty)
                                    objLead.StateName = table.Rows[i]["State"].ToString();

                                if (table.Rows[i]["ZIP Code"] != string.Empty)
                                    objLead.Zip = table.Rows[i]["ZIP Code"].ToString();

                                if (table.Rows[i]["Company"] != string.Empty)
                                    objLead.BusinessName = table.Rows[i]["Company"].ToString();

                                if (table.Rows[i]["Adjuster Name"] != string.Empty)
                                    adjusterName = table.Rows[i]["Adjuster Name"].ToString();

                                if (table.Rows[i]["Phone"] != string.Empty) {
                                    str = table.Rows[i]["Phone"].ToString();
                                    if (str.Length > 20)
                                        objLead.PhoneNumber = str.Substring(0, 20);
                                    else
                                        objLead.PhoneNumber = str.ToString();
                                }

                                StatusMaster statusMaster = null;
                                string statusName = null;

                                if (table.Rows[i]["File Status"] != string.Empty) {
                                    statusName = table.Rows[i]["File Status"].ToString();
                                    statusMaster = StatusManager.GetByStatusName(statusName);

                                    if (statusMaster.StatusId == 0) {
                                        statusMaster = new StatusMaster();
                                        statusMaster.clientID = clientID;
                                        statusMaster.InsertBy = objLead.UserId;
                                        statusMaster.InsertDate = DateTime.Now;
                                        statusMaster.isCountable = true;
                                        statusMaster.Status = true;
                                        statusMaster.StatusName = statusName;

                                        statusMaster = StatusManager.Save(statusMaster);
                                    }
                                }

                                if (!string.IsNullOrEmpty(table.Rows[i]["Peril"].ToString())) {
                                    var id = TypeofDamageManager.getbyTypeOfDamage(table.Rows[i]["Peril"].ToString());
                                    objLead.TypeOfDamage = id.TypeOfDamage;

                                    //string dmgid = string.Empty;
                                    //string[] dmg = table.Rows[i]["Type of Damage"].ToString().Split(',');
                                    //for (int d = 0; d < dmg.Length; d++) {
                                    //     string dmgtext = dmg[d];
                                    //     var dmgdata = TypeofDamageManager.getbyTypeOfDamage(dmgtext);
                                    //     if (dmgdata != null && dmgdata.TypeOfDamage != null && dmgdata.TypeOfDamage.ToString() != string.Empty) {
                                    //          dmgid += dmgdata.TypeOfDamageId + ",";
                                    //     }
                                    //     else {
                                    //          TypeOfDamageMaster objdmg = new TypeOfDamageMaster();
                                    //          objdmg.TypeOfDamage = dmgtext.Length > 100 ? dmgtext.Substring(0, 100) : dmgtext;
                                    //          objdmg.Status = true;
                                    //          TypeOfDamageMaster sv = TypeofDamageManager.Save(objdmg);
                                    //          dmgid += sv.TypeOfDamageId + ",";
                                    //     }
                                    //}

                                    //objLead.TypeOfDamage = dmgid;

                                    str = table.Rows[i]["Peril"].ToString();
                                    if (str.Length > 250)
                                        objLead.TypeofDamageText = str.Substring(0, 250).Replace("/", ",");
                                    else
                                        objLead.TypeofDamageText = str.Replace("/", ",");
                                }

                                objLead.Status = 1;

                                // 2013-08-29 tortega
                                if (clientID > 0)
                                    objLead.ClientID = clientID;

                                Leads newLead = LeadsManager.Save(objLead);

                                if (newLead != null) {
                                    if (table.Rows[i]["Certified Mail Number"] != string.Empty)
                                        AddComments(newLead.LeadId, "Certified Mail Number: " + table.Rows[i]["Certified Mail Number"].ToString());

                                    //if (table.Rows[i]["Contract Signed Date"] != string.Empty)
                                    //     AddComments(newLead.LeadId, "Contract Signed Date: " + table.Rows[i]["Contract Signed Date"].ToString());

                                    if (table.Rows[i]["Last E-mail"] != string.Empty)
                                        AddComments(newLead.LeadId, "Last E-mail Date: " + table.Rows[i]["Last E-mail"].ToString());

                                    if (table.Rows[i]["Last Meeting"] != string.Empty)
                                        AddComments(newLead.LeadId, "Last Meeting Date: " + table.Rows[i]["Last Meeting"].ToString());

                                    if (table.Rows[i]["Letter Date"] != string.Empty)
                                        AddComments(newLead.LeadId, "Letter Date: " + table.Rows[i]["Letter Date"].ToString());

                                    // add policy
                                    CRM.Data.Entities.LeadPolicy policy = new CRM.Data.Entities.LeadPolicy();
                                    policy.PolicyType = 1;
                                    policy.LeadId = newLead.LeadId;
                                    policy.IsActive = true;
                                    policy.isAllDocumentUploaded = false;

                                    if (adjusterID != null)
                                        policy.AdjusterID = adjusterID;

                                    if (table.Rows[i]["Claim Number"] != string.Empty)
                                        policy.ClaimNumber = table.Rows[i]["Claim Number"].ToString();

                                    if (table.Rows[i]["Policy Number"] != string.Empty)
                                        policy.PolicyNumber = table.Rows[i]["Policy Number"].ToString();

                                    if (table.Rows[i]["Policy Period"] != string.Empty)
                                        policy.PolicyPeriod = table.Rows[i]["Policy Period"].ToString();

                                    if (table.Rows[i]["File Number"] != string.Empty)
                                        policy.InsurerFileNo = table.Rows[i]["File Number"].ToString();

                                    if (statusMaster != null)
                                        policy.LeadStatus = statusMaster.StatusId;

                                    if (table.Rows[i]["Ins Carrier"] != string.Empty)
                                        policy.InsuranceCompanyName = table.Rows[i]["Ins Carrier"].ToString();

                                    if (table.Rows[i]["Ins Co Address"] != string.Empty)
                                        policy.InsuranceAddress = table.Rows[i]["Ins Co Address"].ToString();

                                    if (table.Rows[i]["Ins Co City"] != string.Empty) {
                                        string cityName = table.Rows[i]["Ins Co City"].ToString();
                                        CityMaster cityMaster = City.GetByCityName(cityName);
                                        if (cityMaster != null && cityMaster.CityId > 0)
                                            policy.InsuranceCity = cityMaster.CityId;
                                    }

                                    if (table.Rows[i]["Ins Co State"] != string.Empty) {
                                        string stateName = table.Rows[i]["Ins Co State"].ToString();
                                        StateMaster stateMaster = State.Getstateid(stateName);
                                        if (stateMaster != null && stateMaster.StateId > 0)
                                            policy.InsuranceState = stateMaster.StateId;
                                    }

                                    if (table.Rows[i]["Ins Co Zip"] != string.Empty) {
                                        string zipCode = table.Rows[i]["Ins Co Zip"].ToString();
                                        ZipCodeMaster zipMaster = ZipCode.GetByZipCode(zipCode);
                                        if (zipMaster != null && zipMaster.ZipCodeID > 0)
                                            policy.InsuranceZipCode = zipMaster.ZipCodeID.ToString();
                                    }

                                    LeadPolicyManager.Save(policy);
                                }

                            }	//for (int i = 0; i < table.Rows.Count; i++) {

                            scope.Complete();

                        }
                        string rootFolderPath = Server.MapPath("~//CSVLoad//");
                        string filesToDelete = FileUpload1.FileName;
                        string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete);
                        foreach (string file in fileList) {
                            System.IO.File.Delete(file);
                        }
                        lblSave.Text = "Data Saved Successfully !!!";
                        lblSave.Visible = true;
                    }
                }
            }
            catch (Exception ex) {
                lblError.Text = "There Is a problem in  data save  !!!";
                lblError.Visible = true;

                Core.EmailHelper.emailError(ex);
            }
        }
コード例 #9
0
        protected void UploadTemplate1()
        {
            // original format designed by Vivek
            int adjusterID = 0;
            lblSave.Text = string.Empty;
            lblSave.Visible = false;
            lblError.Text = string.Empty;
            lblError.Visible = false;
            lblMessage.Text = string.Empty;
            lblMessage.Visible = false;
            // 2013-02-09 tortega -- Added data validation prior to import. File is not aborted in the event of incorrect data.
            string str = null;

            int clientID = Core.SessionHelper.getClientId();

            // assume homeowner
            int policyType = 1;
            DateTime DateSubmitted = DateTime.Now;

            try {
                if (FileUpload1.HasFile) {

                    string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
                    string ActualFileName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(@"\") + 1);
                    string FileNameWithoutExt = ActualFileName.Replace(ext, "");
                    if (ext == ".csv") {

                        if (!Directory.Exists(Server.MapPath("~//CSVLoad//"))) {
                            Directory.CreateDirectory(Server.MapPath("~//CSVLoad//"));
                        }
                        FileUpload1.SaveAs(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName));
                        DataTable table = CSVReader.ReadCSVFile(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName), true);
                        using (TransactionScope scope = new TransactionScope()) {
                            Leads objLead = null;
                            for (int i = 0; i < table.Rows.Count; i++) {

                                objLead = new Leads();

                                objLead.OriginalLeadDate = DateTime.Now;
                                objLead.UserId = Convert.ToInt32(Session["UserId"]);

                                if (table.Rows[i]["DateSubmitted"] != string.Empty) {

                                    DateTime.TryParse(table.Rows[i]["DateSubmitted"].ToString(), out DateSubmitted);

                                    objLead.DateSubmitted = DateSubmitted;
                                }

                                str = table.Rows[i]["LFUUID"].ToString();
                                if (str.Length > 50)
                                    objLead.LFUUID = table.Rows[i]["LFUUID"].ToString().Substring(0, 50);
                                else
                                    objLead.LFUUID = table.Rows[i]["LFUUID"].ToString();

                                if (table.Rows[i]["Original Lead Date"] != string.Empty) {
                                    objLead.OriginalLeadDate = Convert.ToDateTime(table.Rows[i]["Original Lead Date"]);
                                }

                                if (table.Rows[i]["Last Name"] != string.Empty) {
                                    str = table.Rows[i]["Last Name"].ToString();
                                    if (str.Length > 50)
                                        objLead.ClaimantLastName = table.Rows[i]["Last Name"].ToString().Substring(0, 50);
                                    else
                                        objLead.ClaimantLastName = table.Rows[i]["Last Name"].ToString();
                                }

                                if (table.Rows[i]["First Name"] != string.Empty) {
                                    str = table.Rows[i]["First Name"].ToString();
                                    if (str.Length > 50)
                                        objLead.ClaimantFirstName = table.Rows[i]["First Name"].ToString().Substring(0, 50);
                                    else
                                        objLead.ClaimantFirstName = table.Rows[i]["First Name"].ToString();
                                }

                                if (table.Rows[i]["Email Address"] != string.Empty) {
                                    str = table.Rows[i]["Email Address"].ToString();
                                    if (str.Length > 100)
                                        objLead.EmailAddress = str.Substring(0, 100);
                                    else
                                        objLead.EmailAddress = str;
                                }
                                if (table.Rows[i]["Secondary Email"] != string.Empty) {
                                    str = table.Rows[i]["Secondary Email"].ToString();
                                    if (str.Length > 100)
                                        objLead.SecondaryEmail = str.Substring(0, 100);
                                    else
                                        objLead.SecondaryEmail = str;
                                }

                                if (table.Rows[i]["Adjuster"] != string.Empty) {
                                    string adjusterName = table.Rows[i]["Adjuster"].ToString();
                                    AdjusterMaster adjuster = null;

                                    if (!string.IsNullOrEmpty(adjusterName)) {
                                        adjuster = AdjusterManager.GetByAdjusterName(adjusterName.Trim());
                                        if (adjuster.AdjusterId == 0) {
                                            // add adjuster
                                            adjuster = new AdjusterMaster();
                                            adjuster.Status = true;
                                            adjuster.AdjusterName = adjusterName.Trim();
                                            adjuster.ClientId = clientID;
                                            adjuster.InsertBy = objLead.UserId;
                                            adjuster.InsertDate = DateTime.Now;
                                            adjuster.isEmailNotification = true;

                                            adjuster = AdjusterManager.Save(adjuster);
                                        }

                                        adjusterID = adjuster.AdjusterId;
                                    }

                                }
                                if (table.Rows[i]["Lead Source"] != string.Empty) {

                                    string sourceName = table.Rows[i]["Lead Source"].ToString();

                                    var id = LeadSourceManager.GetByLeadSourceName(sourceName);
                                    if (id.LeadSourceId > 0)
                                        objLead.LeadSource = id.LeadSourceId;
                                    else {
                                        // add source
                                        LeadSourceMaster leadSource = new LeadSourceMaster();
                                        if (clientID > 0)
                                            leadSource.ClientId = clientID;

                                        leadSource.InsertBy = Core.SessionHelper.getUserId();
                                        leadSource.InsertDate = DateTime.Now;
                                        leadSource.LeadSourceName = sourceName.Length > 100 ? sourceName.Substring(0, 100) : sourceName;
                                        leadSource.Status = true;

                                        LeadSourceMaster newLeadSource = LeadSourceManager.Save(leadSource);

                                        objLead.LeadSource = newLeadSource.LeadSourceId;
                                    }
                                }
                                if (table.Rows[i]["Primary Producer"] != string.Empty) {
                                    var id = ProducerManager.GetByProducerName(table.Rows[i]["Primary Producer"].ToString());
                                    if (id != null && id.ProducerId > 0)
                                        objLead.PrimaryProducerId = id.ProducerId;
                                    else {
                                        ProducerMaster producer = AddProducer(objLead, table.Rows[i]["Primary Producer"].ToString());
                                        objLead.PrimaryProducerId = producer.ProducerId;
                                    }
                                }
                                if (table.Rows[i]["Secondary Producer"] != string.Empty) {
                                    var id = SecondaryProducerManager.GetBySecondaryProducerName(table.Rows[i]["Secondary Producer"].ToString());
                                    if (id != null && id.SecondaryProduceId > 0)
                                        objLead.SecondaryProducerId = id.SecondaryProduceId;
                                    else {
                                        ProducerMaster producer = AddProducer(objLead, table.Rows[i]["Secondary Producer"].ToString());
                                        objLead.SecondaryProducerId = producer.ProducerId;
                                    }
                                }
                                if (table.Rows[i]["Inspector Name"] != string.Empty) {
                                    var id = InspectorManager.GetByName(table.Rows[i]["Inspector Name"].ToString());
                                    if (id != null && id.InspectorId > 0)
                                        objLead.InspectorName = id.InspectorId;
                                    else {
                                        InspectorMaster inspector = AddInspector(objLead, table.Rows[i]["Inspector Name"].ToString());
                                        objLead.InspectorName = inspector.InspectorId;
                                    }
                                }
                                if (table.Rows[i]["Inspector Cell"] != string.Empty) {
                                    str = table.Rows[i]["Inspector Cell"].ToString();
                                    if (str.Length > 20)
                                        str = objLead.InspectorCell = table.Rows[i]["Inspector Cell"].ToString().Substring(0, 20);
                                    else
                                        objLead.InspectorCell = table.Rows[i]["Inspector Cell"].ToString();
                                }
                                if (table.Rows[i]["Inspector Email"] != string.Empty) {
                                    str = table.Rows[i]["Inspector Email"].ToString(); ;
                                    if (str.Length > 100)
                                        objLead.InspectorEmail = table.Rows[i]["Inspector Email"].ToString().Substring(0, 100);
                                    else
                                        objLead.InspectorEmail = table.Rows[i]["Inspector Email"].ToString();
                                }

                                if (table.Rows[i]["Phone Number"] != string.Empty) {
                                    str = table.Rows[i]["Phone Number"].ToString();
                                    if (str.Length > 20)
                                        objLead.PhoneNumber = table.Rows[i]["Phone Number"].ToString().Substring(0, 20);
                                    else
                                        objLead.PhoneNumber = table.Rows[i]["Phone Number"].ToString();
                                }
                                if (table.Rows[i]["Secondary Phone"] != string.Empty) {
                                    str = table.Rows[i]["Secondary Phone"].ToString();
                                    if (str.Length > 20)
                                        objLead.SecondaryPhone = str.Substring(0, 20);
                                    else
                                        objLead.SecondaryPhone = str;
                                }
                                //if (table.Rows[i]["Webform Source"] != string.Empty) {
                                //	//objLead.WebformSource = table.Rows[i]["Webform Source"].ToString();
                                //	var id = WebFormSourceManager.GetByName(table.Rows[i]["Webform Source"].ToString());

                                //	if (id != null && id.WebformSourceId > 0)
                                //		objLead.WebformSource = id.WebformSourceId;
                                //}

                                if (!string.IsNullOrEmpty(table.Rows[i]["Type of Damage"].ToString())) {
                                    //objLead.TypeOfDamage = table.Rows[i]["Type of Damage"].ToString();
                                    var id = TypeofDamageManager.getbyTypeOfDamage(table.Rows[i]["Type of Damage"].ToString());
                                    objLead.TypeOfDamage = id.TypeOfDamage;

                                    //string dmgid = string.Empty;
                                    //string[] dmg = table.Rows[i]["Type of Damage"].ToString().Split(',');
                                    //for (int d = 0; d < dmg.Length; d++) {
                                    //     string dmgtext = dmg[d];
                                    //     var dmgdata = TypeofDamageManager.getbyTypeOfDamage(dmgtext);
                                    //     if (dmgdata != null && dmgdata.TypeOfDamage != null && dmgdata.TypeOfDamage.ToString() != string.Empty) {
                                    //          dmgid += dmgdata.TypeOfDamageId + ",";
                                    //     }
                                    //     else {
                                    //          TypeOfDamageMaster objdmg = new TypeOfDamageMaster();
                                    //          objdmg.TypeOfDamage = dmgtext.Length > 100 ? dmgtext.Substring(0, 100) : dmgtext;
                                    //          objdmg.Status = true;
                                    //          TypeOfDamageMaster sv = TypeofDamageManager.Save(objdmg);
                                    //          dmgid += sv.TypeOfDamageId + ",";
                                    //     }
                                    //}

                                    //objLead.TypeOfDamage = dmgid;

                                    str = table.Rows[i]["Type of Damage"].ToString();
                                    if (str.Length > 250)
                                        objLead.TypeofDamageText = table.Rows[i]["Type of Damage"].ToString().Substring(0, 250);
                                    else
                                        objLead.TypeofDamageText = table.Rows[i]["Type of Damage"].ToString();

                                    //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 (!string.IsNullOrEmpty(table.Rows[i]["Type of Property"].ToString())) {
                                    var id = PropertyTypeManager.GetByPropertyName(table.Rows[i]["Type of Property"].ToString());

                                    if (id != null && id.TypeOfPropertyId > 0) {
                                        objLead.TypeOfProperty = id.TypeOfPropertyId;

                                        if (id.TypeOfProperty.Contains("Home"))
                                            policyType = 1;

                                        if (id.TypeOfProperty.Contains("Commercial"))
                                            policyType = 2;

                                        if (id.TypeOfProperty.Contains("Flood"))
                                            policyType = 3;

                                        if (id.TypeOfProperty.Contains("Earthquake"))
                                            policyType = 4;
                                    }
                                }
                                if (table.Rows[i]["Market Value"] != string.Empty) {
                                    decimal MarketValue = 0;
                                    decimal.TryParse(table.Rows[i]["Market Value"].ToString(), out MarketValue);

                                    objLead.MarketValue = MarketValue;	//Convert.ToDecimal(table.Rows[i]["Market Value"]);
                                }
                                if (table.Rows[i]["Loss Address"] != string.Empty) {
                                    str = table.Rows[i]["Loss Address"].ToString();
                                    if (str.Length > 100)
                                        objLead.LossAddress = str.Substring(0, 100);
                                    else
                                        objLead.LossAddress = str;
                                }

                                if (table.Rows[i]["City"] != string.Empty)
                                    objLead.CityName = table.Rows[i]["City"].ToString();

                                if (table.Rows[i]["State"] != string.Empty)
                                    objLead.StateName = table.Rows[i]["State"].ToString();

                                if (table.Rows[i]["Zip"] != string.Empty)
                                    objLead.Zip = table.Rows[i]["Zip"].ToString();

                                if (table.Rows[i]["Property Damage Estimate"] != string.Empty) {
                                    decimal PropertyDamageEstimate = 0;
                                    decimal.TryParse(table.Rows[i]["Property Damage Estimate"].ToString(), out PropertyDamageEstimate);

                                    objLead.PropertyDamageEstimate = PropertyDamageEstimate;// Convert.ToDecimal(table.Rows[i]["Property Damage Estimate"]);
                                }
                                //if (table.Rows[i]["Habitable"] != string.Empty) {
                                //	//objLead.Habitable = table.Rows[i]["Habitable"].ToString();
                                //	var id = HabitableManager.GetbyHabitable(table.Rows[i]["Habitable"].ToString());
                                //	if (id != null && id.HabitableId > 0)
                                //		objLead.Habitable = id.HabitableId;
                                //}
                                //if (table.Rows[i]["Wind Policy"] != string.Empty) {
                                //	//objLead.WindPolicy = table.Rows[i]["Wind Policy"].ToString();
                                //	//var id = WindPolicyManager.getbyWindPolicy(table.Rows[i]["Habitable"].ToString());
                                //	var id = WindPolicyManager.getbyWindPolicy(table.Rows[i]["Wind Policy"].ToString());
                                //	if (id != null && id.WindPolicyId > 0)
                                //		objLead.WindPolicy = id.WindPolicyId;
                                //}
                                //if (table.Rows[i]["Flood Policy"] != string.Empty) {
                                //	//objLead.FloodPolicy = table.Rows[i]["Flood Policy"].ToString();
                                //	var id = FloodPolicyManager.GetByFloodPolicy(table.Rows[i]["Flood Policy"].ToString());
                                //	if (id != null && id.FloodPolicyId > 0)
                                //		objLead.FloodPolicy = id.FloodPolicyId;
                                //}

                                if (table.Rows[i]["Owner First Name"] != string.Empty)
                                    if (table.Rows[i]["Owner First Name"].ToString().Length > 50)
                                        objLead.OwnerFirstName = table.Rows[i]["Owner First Name"].ToString().Substring(0, 50);
                                    else
                                        objLead.OwnerFirstName = table.Rows[i]["Owner First Name"].ToString();

                                if (table.Rows[i]["Owner Last Name"] != string.Empty) {
                                    str = table.Rows[i]["Owner Last Name"].ToString();
                                    objLead.OwnerLastName = str.Length > 50 ? str.Substring(0, 50) : str;
                                }

                                if (table.Rows[i]["Owner Phone Number"] != string.Empty) {
                                    str = table.Rows[i]["Owner Phone Number"].ToString();
                                    objLead.OwnerPhone = str.Length > 15 ? str.Substring(0, 15) : str;
                                }

                                if (table.Rows[i]["Last Contact Date"] != string.Empty)
                                    objLead.LastContactDate = Convert.ToDateTime(table.Rows[i]["Last Contact Date"].ToString());

                                if (table.Rows[i]["Personal Referral"] != string.Empty) {
                                    str = table.Rows[i]["Personal Referral"].ToString();
                                    objLead.HearAboutUsDetail = str.Length > 250 ? str.Substring(0, 250) : str;
                                }

                                StatusMaster statusMaster = null;

                                if (table.Rows[i]["Status"] != string.Empty) {
                                    string statusName = table.Rows[i]["Status"].ToString();
                                    statusName = statusName.Length > 100 ? statusName.Substring(0, 100) : statusName;
                                    statusMaster = StatusManager.GetByStatusName(statusName);

                                    if (statusMaster.StatusId == 0) {
                                        statusMaster = new StatusMaster();
                                        statusMaster.clientID = clientID;
                                        statusMaster.InsertBy = objLead.UserId;
                                        statusMaster.InsertDate = DateTime.Now;
                                        statusMaster.isCountable = true;
                                        statusMaster.isCountAsOpen = true;
                                        statusMaster.Status = true;
                                        statusMaster.StatusName = statusName;

                                        statusMaster = StatusManager.Save(statusMaster);
                                    }
                                }

                                objLead.Status = 1;
                                objLead.InsertBy = objLead.UserId;

                                // 2013-08-29 tortega
                                if (clientID > 0)
                                    objLead.ClientID = clientID;

                                Leads newLead = LeadsManager.Save(objLead);

                                if (newLead != null) {
                                    LeadComment objLeadComment = null;

                                    // add policy
                                    CRM.Data.Entities.LeadPolicy policy = new CRM.Data.Entities.LeadPolicy();
                                    policy.PolicyType = 1;
                                    policy.LeadId = newLead.LeadId;
                                    policy.IsActive = true;
                                    policy.isAllDocumentUploaded = false;

                                    if (statusMaster != null)
                                        policy.LeadStatus = statusMaster.StatusId;

                                    if (adjusterID > 0)
                                        policy.AdjusterID = adjusterID;

                                    if (table.Rows[i]["Claims Number"] != string.Empty)
                                        policy.ClaimNumber = table.Rows[i]["Claims Number"].ToString();

                                    if (table.Rows[i]["Site Survey Date"] != string.Empty)
                                        policy.SiteSurveyDate = Convert.ToDateTime(table.Rows[i]["Site Survey Date"].ToString());

                                    LeadPolicyManager.Save(policy);

                                    if (!string.IsNullOrEmpty(table.Rows[i]["Reported to Insurer"].ToString())) {
                                        objLeadComment = new LeadComment();
                                        int LeadID = objLead.LeadId;

                                        objLeadComment.LeadId = LeadID;

                                        objLeadComment.UserId = objLead.UserId;

                                        objLeadComment.Status = 1;

                                        // 2013-08-29 tortega
                                        objLeadComment.PolicyType = policyType;

                                        str = table.Rows[i]["Reported to Insurer"].ToString();
                                        if (str.Length > 8000)
                                            objLeadComment.CommentText = "Reported to Insurer " + str.Substring(0, 8000);
                                        else
                                            objLeadComment.CommentText = "Reported to Insurer " + str;

                                        LeadComment objld = LeadCommentManager.Save(objLeadComment);
                                    }

                                    if (!string.IsNullOrEmpty(table.Rows[i]["Claimant Comments"].ToString())) {
                                        objLeadComment = new LeadComment();
                                        int LeadID = objLead.LeadId;

                                        objLeadComment.LeadId = LeadID;

                                        objLeadComment.UserId = objLead.UserId;

                                        objLeadComment.Status = 1;

                                        // 2013-08-29 tortega
                                        objLeadComment.PolicyType = policyType;

                                        str = table.Rows[i]["Claimant Comments"].ToString();
                                        if (str.Length > 8000)
                                            objLeadComment.CommentText = str.Substring(0, 8000);
                                        else
                                            objLeadComment.CommentText = str;

                                        LeadComment objld = LeadCommentManager.Save(objLeadComment);
                                    }
                                }

                            }	//for (int i = 0; i < table.Rows.Count; i++) {

                            scope.Complete();

                        }
                        string rootFolderPath = Server.MapPath("~//CSVLoad//");
                        string filesToDelete = FileUpload1.FileName;
                        string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete);
                        foreach (string file in fileList) {
                            System.IO.File.Delete(file);
                        }
                        lblSave.Text = "Data Saved Successfully !!!";
                        lblSave.Visible = true;
                    }
                }
            }
            catch (Exception ex) {
                lblError.Text = "There Is a problem in  data save  !!!";
                lblError.Visible = true;

                Core.EmailHelper.emailError(ex);
            }
        }
コード例 #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text = string.Empty;
            lblError.Visible = false;
            lblSave.Text = string.Empty;
            lblSave.Visible = false;
            lblMessage.Visible = false;
            lblMessage.Text = string.Empty;
            try {
                bool isnew = false;
                Leads objLead = new Leads();
                if (hfLeadsId.Value == "0") {
                    isnew = true;
                }
                else {
                    objLead = LeadsManager.GetByLeadId(Convert.ToInt32(hfLeadsId.Value));
                }
                if (isnew) {
                }
                else {
                    /*New Fields*/
                    //objLead.hasInsurancePolicy = chkInsurancePolicy.Checked == true ? true : false;
                    //objLead.hasSignedRetainer = chkSignedRetainer.Checked == true ? true : false;
                    //objLead.hasDamageReport = chkDamageReport.Checked == true ? true : false;
                    //objLead.hasDamagePhoto = chkDamagePhoto.Checked == true ? true : false;
                    //objLead.hasCertifiedInsurancePolicy = chkCertifiedInsurancePolicy.Checked == true ? true : false;
                    //objLead.hasOwnerContract = chkOwnerContract.Checked == true ? true : false;
                    //objLead.hasContentList = chkContentList.Checked == true ? true : false;
                    //objLead.hasDamageEstimate = chkDamageEstimate.Checked == true ? true : false;
                    //if (chkInsurancePolicy.Checked == true && chkSignedRetainer.Checked == true && chkDamageReport.Checked == true && chkDamagePhoto.Checked == true &&
                    //    chkCertifiedInsurancePolicy.Checked == true && chkOwnerContract.Checked == true && chkContentList.Checked == true && chkDamageEstimate.Checked == true) {
                    //     objLead.AllDocumentsOnFile = true;
                    //}
                    //else {
                    //     objLead.AllDocumentsOnFile = false;
                    //}
                    /**/
                    Leads ins = LeadsManager.Save(objLead);

                    //if (ins.LeadId > 0) {
                    //	LeadLog objLeadlog = new LeadLog();
                    //	//objLeadlog.hasInsurancePolicy = chkInsurancePolicy.Checked == true ? true : false;
                    //	//objLeadlog.hasSignedRetainer = chkSignedRetainer.Checked == true ? true : false;
                    //	//objLeadlog.hasDamageReport = chkDamageReport.Checked == true ? true : false;
                    //	//objLeadlog.hasDamagePhoto = chkDamagePhoto.Checked == true ? true : false;
                    //	//objLeadlog.hasCertifiedInsurancePolicy = chkCertifiedInsurancePolicy.Checked == true ? true : false;
                    //	//objLeadlog.hasOwnerContract = chkOwnerContract.Checked == true ? true : false;
                    //	//objLeadlog.hasContentList = chkContentList.Checked == true ? true : false;
                    //	//objLeadlog.hasDamageEstimate = chkDamageEstimate.Checked == true ? true : false;
                    //	//if (chkInsurancePolicy.Checked == true && chkSignedRetainer.Checked == true && chkDamageReport.Checked == true && chkDamagePhoto.Checked == true &&
                    //	//    chkCertifiedInsurancePolicy.Checked == true && chkOwnerContract.Checked == true && chkContentList.Checked == true && chkDamageEstimate.Checked == true) {
                    //	//     objLeadlog.AllDocumentsOnFile = true;
                    //	//}
                    //	//else {
                    //	//     objLeadlog.AllDocumentsOnFile = false;
                    //	//}

                    //	/**/
                    //	LeadLog insLog = LeadsManager.SaveLeadLog(objLeadlog);
                    //	FillDocumentList(Convert.ToInt32(hfLeadsId.Value));
                    //	lblSave.Text = "Data Saved Sucessfully.";
                    //	lblSave.Visible = true;
                    //}
                }
            }
            catch (Exception ex) {
                lblError.Text = "Data Not Saved.";
                lblError.Visible = true;
            }
        }
コード例 #11
0
        protected bool validateForm(Leads lead)
        {
            bool isValid = true;

            //if (	string.IsNullOrEmpty(lead.InsuranceCompanyName) ||
            //	string.IsNullOrEmpty(lead.InsuranceContactName) ||
            //	string.IsNullOrEmpty(lead.InsuranceContactPhone) ||
            //	string.IsNullOrEmpty(lead.InsuranceContactEmail) ||
            //	string.IsNullOrEmpty(lead.InsuranceAddress) ||
            //	(lead.InsuranceCity ?? 0) == 0 ||
            //	(lead.InsuranceState ?? 0) == 0 ||
            //	string.IsNullOrEmpty(lead.InsuranceZipCode) ||
            //	string.IsNullOrEmpty(lead.InsurancePolicyNumber)
            //	)
            //	isValid = false;

            return isValid;
        }
コード例 #12
0
ファイル: form.aspx.cs プロジェクト: Antoniotoress1992/asp
        //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;
        }
コード例 #13
0
        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;
        }
コード例 #14
0
        public static string SaveClaimStatus(int claimStatus, string insurerClaimId, string insurerName, int claimAdjusterId, string adjusterComapnyName, string updatedby, string commentNote, string emailTo, int carrierID, int claimID, string recipientId, string claimAdjuster, string claimStatusName, string carrier, string idOf)
        {
            string json = "";
            Claim objclaim = null;
            AdjusterMaster objAdjusterMaster = null;
            Leads objLeads = null;
            CRM.Data.Entities.LeadPolicy objLeadPolicy = null;
            ClaimComment comment = null;
            Client objClient = null;
            int userID = SessionHelper.getUserId();
            int leadID = 0;
            int policyId = 0;
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimManager repository = new ClaimManager())
                    {
                        objclaim = new Claim();
                        objclaim.ClaimID = claimID;
                        objclaim.StatusID = claimStatus;
                        objclaim.InsurerClaimNumber = insurerClaimId;
                        //objclaim.CarrierID = carrierID;
                        objclaim.AdjusterID = claimAdjusterId;
                        objclaim.StatusUpdatedBy = updatedby;
                        objclaim.StatusCommentNote = commentNote;
                        //objclaim.StatusEmailTo = EmailTo;
                        repository.UpdateClaimStatus(objclaim);

                        // AdjusterMaster
                        objAdjusterMaster = new AdjusterMaster();
                        objAdjusterMaster.AdjusterId = claimAdjusterId;
                        //objAdjusterMaster.CompanyName = AdjusterComapnyName;
                        repository.UpdateAdjusterName(objAdjusterMaster);

                        //leads
                        leadID = repository.GetPolicyId(claimID);
                        objLeads = new Leads();
                        objLeads.LeadId = leadID;
                        objLeads.InsuredName = insurerName;
                        repository.UpdateInsurerName(objLeads);
                        //save carrier id in Lead policy
                        policyId = repository.GetLeadPolicyId(claimID);
                        objLeadPolicy = new Data.Entities.LeadPolicy();
                        objLeadPolicy.Id = policyId;
                        objLeadPolicy.CarrierID = carrierID;
                        repository.UpdateCarrierId(objLeadPolicy);
                        //claim comment for add notes
                        comment = new ClaimComment();
                        comment.ClaimID = claimID;
                        comment.IsActive = true;
                        comment.UserId = Core.SessionHelper.getUserId();
                        comment.CommentDate = DateTime.Now;
                        comment.ActivityType = "Status Changed";
                        comment.CommentText = commentNote.Trim();
                        ClaimCommentManager.Save(comment);

                        //client company name
                        //Client c = ClaimsManager.GetClientByUserId(SessionHelper.getUserId());
                        //c.BusinessName = AdjusterComapnyName;
                        //ClaimsManager.SaveClient(c);

                    }
                    scope.Complete();
                }
                string[] recipId = recipientId.Split(',');
                string recipientEmailId = string.Empty;

                string[] idofTable = idOf.Split(',');
                int index2 = 0;
                for (int index = 0; index < recipId.Length; index++)
                {
                    index2 = 0;
                    int.TryParse(recipId[index], out index2);
                    if (idofTable[index] == "c")
                    {

                        Contact objContact = ContactManager.Get(index2);
                        if (!string.IsNullOrEmpty(objContact.Email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objContact.Email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objContact.Email;
                            }
                        }
                    }
                    else
                    {

                        AdjusterMaster objAdjuster = AdjusterManager.GetAdjusterId(index2);

                        if (!string.IsNullOrEmpty(objAdjuster.email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objAdjuster.email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objAdjuster.email;
                            }
                        }

                    }
                }
                if (!string.IsNullOrEmpty(recipientEmailId))
                {
                    notifyUser(claimStatus, insurerClaimId, insurerName, claimAdjusterId, adjusterComapnyName, updatedby, commentNote, "", carrierID, claimID, recipientEmailId, claimAdjuster, claimStatusName, carrier, recipId, idofTable);
                }
                json = "Status save successfully";

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
            }

            return json;
        }
コード例 #15
0
        public static void autoFillDocument(string templateURL, string filepath, Leads lead, bool isHeader = false)
        {
            Document document = new Document();

            // load document template
            //document.LoadFromFile(templateURL, FileFormat.Doc);
            document.LoadFromFile(templateURL, FileFormat.Auto);

            // load merge fields
            loadFieldValues(lead);

            //if (isHeader)
            //     setHeader(document, lead.Client);

            document.MailMerge.Execute(fieldNames, fieldValues);

            document.SaveToFile(filepath, FileFormat.Doc);
            //document.SaveToFile(filepath, FileFormat.Auto);

            document.Close();

            document = null;
        }
コード例 #16
0
        protected void UploadTemplate2()
        {
            // original format designed by Vivek
            lblSave.Text = string.Empty;
            lblSave.Visible = false;
            lblError.Text = string.Empty;
            lblError.Visible = false;
            lblMessage.Text = string.Empty;
            lblMessage.Visible = false;
            // 2013-02-09 tortega -- Added data validation prior to import. File is not aborted in the event of incorrect data.
            string str = null;
            int fileLineNumber = 0;
            int clientID = Core.SessionHelper.getClientId();

            // assume homeowner
            int policyType = 1;
            DateTime DateSubmitted = DateTime.Now;
            DateTime ContractDate = DateTime.Now;

            string columnValue = null;
            Mortgagee mortgagee = null;

            StatusMaster statusMaster = null;
            string statusName = null;

            try {
                if (FileUpload1.HasFile) {

                    string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
                    string ActualFileName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(@"\") + 1);
                    string FileNameWithoutExt = ActualFileName.Replace(ext, "");
                    if (ext == ".csv") {

                        if (!Directory.Exists(Server.MapPath("~//CSVLoad//"))) {
                            Directory.CreateDirectory(Server.MapPath("~//CSVLoad//"));
                        }
                        FileUpload1.SaveAs(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName));
                        DataTable table = CSVReader.ReadCSVFile(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName), true);
                        using (TransactionScope scope = new TransactionScope()) {
                            Leads objLead = null;

                            for (int i = 0; i < table.Rows.Count; i++) {
                                fileLineNumber = i;

                                objLead = new Leads();

                                //objLead.LeadStatus = 1;	// active
                                objLead.OriginalLeadDate = DateTime.Now;
                                objLead.TypeOfProperty = 18;	//residential
                                objLead.UserId = Convert.ToInt32(Session["UserId"]);

                                try {

                                    if (columnExists(table, "Create Date") && table.Rows[i]["Create Date"] != string.Empty) {

                                        DateTime.TryParse(table.Rows[i]["Create Date"].ToString(), out DateSubmitted);

                                        objLead.DateSubmitted = DateSubmitted;

                                        objLead.OriginalLeadDate = DateSubmitted;
                                    }

                                    if (columnExists(table, "Last Name") && table.Rows[i]["Last Name"] != string.Empty) {
                                        str = table.Rows[i]["Last Name"].ToString();
                                        if (str.Length > 50) {
                                            objLead.ClaimantLastName = str.Substring(0, 50);
                                            objLead.OwnerLastName = objLead.ClaimantLastName;
                                        }
                                        else {
                                            objLead.ClaimantLastName = str;
                                            objLead.OwnerLastName = str;
                                        }
                                    }

                                    if (columnExists(table, "First Name") && table.Rows[i]["First Name"] != string.Empty) {
                                        str = table.Rows[i]["First Name"].ToString();
                                        if (str.Length > 50) {
                                            objLead.ClaimantFirstName = str.Substring(0, 50);
                                            objLead.OwnerFirstName = objLead.ClaimantFirstName;
                                        }
                                        else {
                                            objLead.ClaimantFirstName = str;
                                            objLead.OwnerFirstName = str;
                                        }
                                    }

                                    if (columnExists(table, "Middle Name") && table.Rows[i]["Middle Name"] != string.Empty) {
                                        str = table.Rows[i]["Middle Name"].ToString();
                                        if (str.Length > 50) {
                                            objLead.ClaimantMiddleName = str.Substring(0, 50);
                                        }
                                        else {
                                            objLead.ClaimantMiddleName = str;
                                        }
                                    }

                                    if (columnExists(table, "E-mail") && table.Rows[i]["E-mail"] != string.Empty) {
                                        str = table.Rows[i]["E-mail"].ToString();
                                        if (str.Length > 100)
                                            objLead.EmailAddress = str.Substring(0, 100);
                                        else
                                            objLead.EmailAddress = str;
                                    }
                                    if (columnExists(table, "Personal E-mail") && table.Rows[i]["Personal E-mail"] != string.Empty) {
                                        str = table.Rows[i]["Personal E-mail"].ToString();
                                        if (str.Length > 100)
                                            objLead.SecondaryEmail = str.Substring(0, 100);
                                        else
                                            objLead.SecondaryEmail = str;
                                    }

                                    if (columnExists(table, "Mobile Phone") && table.Rows[i]["Mobile Phone"] != string.Empty) {
                                        str = table.Rows[i]["Mobile Phone"].ToString();
                                        if (str.Length > 20)
                                            objLead.SecondaryPhone = str.Substring(0, 20);
                                        else
                                            objLead.SecondaryPhone = str;
                                    }

                                    if (columnExists(table, "Salutation") && table.Rows[i]["Salutation"] != string.Empty) {
                                        str = table.Rows[i]["Salutation"].ToString();
                                        if (str.Length > 50)
                                            objLead.Salutation = str.Substring(0, 20);
                                        else
                                            objLead.Salutation = str;
                                    }
                                }
                                catch (Exception ex) {
                                    lblError.Text = "There Is a problem in  data save  !!!";
                                    lblError.Visible = true;

                                    Core.EmailHelper.emailError(ex);

                                    throw new Exception(ex.Message);
                                }

                                string adjusterName = null;
                                int? adjusterID = null;
                                AdjusterMaster adjuster = null;

                                if (columnExists(table, "Adjuster Name") && table.Rows[i]["Adjuster Name"] != string.Empty)
                                    adjusterName = table.Rows[i]["Adjuster Name"].ToString();

                                string adjusterEmail = null;
                                string adjusterFax = null;
                                string AdjusterPhone = null;
                                string AdjusterCo = null;
                                string AdjusterAddress = null;

                                if (columnExists(table, "Adjuster Email") && table.Rows[i]["Adjuster Email"] != string.Empty)
                                    adjusterEmail = table.Rows[i]["Adjuster Email"].ToString();

                                if (columnExists(table, "Adjuster Fax") && table.Rows[i]["Adjuster Fax"] != string.Empty)
                                    adjusterFax = table.Rows[i]["Adjuster Fax"].ToString();

                                if (columnExists(table, "Adjuster Phone") && table.Rows[i]["Adjuster Phone"] != string.Empty)
                                    AdjusterPhone = table.Rows[i]["Adjuster Phone"].ToString();

                                if (columnExists(table, "Adjuster Co") && table.Rows[i]["Adjuster Co"] != string.Empty)
                                    AdjusterCo = table.Rows[i]["Adjuster Co"].ToString();

                                if (columnExists(table, "Adj Address") && table.Rows[i]["Adj Address"] != string.Empty)
                                    AdjusterAddress = table.Rows[i]["Adj Address"].ToString();

                                if (!string.IsNullOrEmpty(adjusterName)) {
                                    adjuster = AdjusterManager.GetByAdjusterName(adjusterName.Trim());
                                    if (adjuster.AdjusterId == 0) {
                                        // add adjuster
                                        adjuster = new AdjusterMaster();
                                        adjuster.Status = true;
                                        adjuster.AdjusterName = adjusterName.Trim();
                                        adjuster.ClientId = clientID;
                                        adjuster.InsertBy = objLead.UserId;
                                        adjuster.InsertDate = DateTime.Now;
                                        adjuster.isEmailNotification = true;
                                        adjuster.email = adjusterEmail;
                                        adjuster.Address1 = AdjusterAddress;
                                        adjuster.PhoneNumber = AdjusterPhone;
                                        adjuster.FaxNumber = adjusterFax;
                                        adjuster.CompanyName = AdjusterCo;
                                        adjuster = AdjusterManager.Save(adjuster);
                                    }

                                    adjusterID = adjuster.AdjusterId;
                                }

                                if (columnExists(table, "ExaminerName") && table.Rows[i]["ExaminerName"] != string.Empty) {
                                    InspectorMaster inspector = InspectorManager.GetByName(table.Rows[i]["ExaminerName"].ToString());
                                    if (inspector.InspectorId > 0) {
                                        objLead.InspectorName = inspector.InspectorId;
                                    }

                                }

                                //if (columnExists(table, "Loss Location") && table.Rows[i]["Loss Location"] != string.Empty)
                                //     objLead.LossLocation = table.Rows[i]["Loss Location"].ToString();

                                //if (columnExists(table, "Date of Loss") && table.Rows[i]["Date of Loss"] != string.Empty) {
                                //     DateTime lossDate = DateTime.MinValue;
                                //     if (DateTime.TryParse(table.Rows[i]["Date of Loss"].ToString(), out lossDate))
                                //          objLead.LossDate = lossDate;
                                //}

                                if (columnExists(table, "Contract Signed Date") && table.Rows[i]["Contract Signed Date"] != string.Empty)
                                    objLead.ContractDate = Convert.ToDateTime(table.Rows[i]["Contract Signed Date"].ToString());

                                if (columnExists(table, "Address 1") && table.Rows[i]["Address 1"] != string.Empty) {
                                    str = table.Rows[i]["Address 1"].ToString();

                                    if (str.Length > 100)
                                        objLead.MailingAddress = str.Substring(0, 99);
                                    else
                                        objLead.LossAddress = str.ToString();
                                }

                                try {

                                    if (columnExists(table, "City") && table.Rows[i]["City"] != string.Empty)
                                        objLead.MailingCity = table.Rows[i]["City"].ToString();

                                    if (columnExists(table, "State") && table.Rows[i]["State"] != string.Empty)
                                        objLead.MailingState = table.Rows[i]["State"].ToString();

                                    if (columnExists(table, "ZIP Code") && table.Rows[i]["ZIP Code"] != string.Empty)
                                        objLead.MailingZip = table.Rows[i]["ZIP Code"].ToString();

                                    if (columnExists(table, "Business Name") && table.Rows[i]["Business Name"] != string.Empty)
                                        objLead.BusinessName = table.Rows[i]["Business Name"].ToString();

                                    if (columnExists(table, "Adjuster Name") && table.Rows[i]["Adjuster Name"] != string.Empty)
                                        adjusterName = table.Rows[i]["Adjuster Name"].ToString();

                                    if (columnExists(table, "Phone") && table.Rows[i]["Phone"] != string.Empty) {
                                        str = table.Rows[i]["Phone"].ToString();
                                        if (str.Length > 20)
                                            objLead.PhoneNumber = str.Substring(0, 20);
                                        else
                                            objLead.PhoneNumber = str.ToString();
                                    }

                                    if (columnExists(table, "Loss Address") && table.Rows[i]["Loss Address"] != string.Empty) {
                                        str = table.Rows[i]["Loss Address"].ToString();

                                        if (str.Length > 100)
                                            objLead.LossAddress = str.Substring(0, 99);
                                        else
                                            objLead.LossAddress = str.ToString();
                                    }
                                    if (columnExists(table, "Loss City") && table.Rows[i]["Loss City"] != string.Empty)
                                        objLead.CityName = table.Rows[i]["Loss City"].ToString();

                                    if (columnExists(table, "Loss State") && table.Rows[i]["Loss State"] != string.Empty)
                                        objLead.StateName = table.Rows[i]["Loss State"].ToString();

                                    if (columnExists(table, "Loss Zip Code") && table.Rows[i]["Loss Zip Code"] != string.Empty) {
                                        str = table.Rows[i]["Loss Zip Code"].ToString();
                                        if (str.Length < 5)
                                            str = "0" + str;

                                        objLead.Zip = str;
                                    }

                                    if (columnExists(table, "Fax") && table.Rows[i]["Fax"] != string.Empty) {
                                        str = table.Rows[i]["Fax"].ToString();
                                        if (str.Length > 20)
                                            objLead.SecondaryPhone = str.Substring(0, 20);
                                        else
                                            objLead.SecondaryPhone = str.ToString();
                                    }

                                    if (columnExists(table, "File Status") && table.Rows[i]["File Status"] != string.Empty) {
                                        statusName = table.Rows[i]["File Status"].ToString();
                                        statusMaster = StatusManager.GetByStatusName(statusName);

                                        if (statusMaster.StatusId == 0) {
                                            statusMaster = new StatusMaster();
                                            statusMaster.clientID = clientID;
                                            statusMaster.InsertBy = objLead.UserId;
                                            statusMaster.InsertDate = DateTime.Now;
                                            statusMaster.isCountable = true;
                                            statusMaster.Status = true;
                                            statusMaster.StatusName = statusName;

                                            statusMaster = StatusManager.Save(statusMaster);
                                        }
                                    }
                                }
                                catch (Exception ex) {
                                    lblError.Text = "There Is a problem in  data save  !!!";
                                    lblError.Visible = true;

                                    Core.EmailHelper.emailError(ex);

                                    throw new Exception(ex.Message);
                                }

                                if (columnExists(table, "Peril") && !string.IsNullOrEmpty(table.Rows[i]["Peril"].ToString())) {
                                    var id = TypeofDamageManager.getbyTypeOfDamage(table.Rows[i]["Peril"].ToString());
                                    if (id.TypeOfDamageId > 0)
                                        objLead.TypeOfDamage = id.TypeOfDamageId.ToString() + ",";

                                    //string dmgid = string.Empty;
                                    //string[] dmg = table.Rows[i]["Type of Damage"].ToString().Split(',');
                                    //for (int d = 0; d < dmg.Length; d++) {
                                    //     string dmgtext = dmg[d];
                                    //     var dmgdata = TypeofDamageManager.getbyTypeOfDamage(dmgtext);
                                    //     if (dmgdata != null && dmgdata.TypeOfDamage != null && dmgdata.TypeOfDamage.ToString() != string.Empty) {
                                    //          dmgid += dmgdata.TypeOfDamageId + ",";
                                    //     }
                                    //     else {
                                    //          TypeOfDamageMaster objdmg = new TypeOfDamageMaster();
                                    //          objdmg.TypeOfDamage = dmgtext.Length > 100 ? dmgtext.Substring(0, 100) : dmgtext;
                                    //          objdmg.Status = true;
                                    //          TypeOfDamageMaster sv = TypeofDamageManager.Save(objdmg);
                                    //          dmgid += sv.TypeOfDamageId + ",";
                                    //     }
                                    //}

                                    //objLead.TypeOfDamage = dmgid;

                                    str = table.Rows[i]["Peril"].ToString();
                                    if (str.Length > 250)
                                        objLead.TypeofDamageText = str.Substring(0, 250).Replace("/", ",");
                                    else
                                        objLead.TypeofDamageText = str.Replace("/", ",");
                                }

                                objLead.Status = 1;

                                // 2013-08-29 tortega
                                if (clientID > 0)
                                    objLead.ClientID = clientID;

                                Leads newLead = LeadsManager.Save(objLead);
                                int policyTypeID = 1;

                                if (newLead != null) {
                                    // add policy
                                    CRM.Data.Entities.LeadPolicy policy = new CRM.Data.Entities.LeadPolicy();

                                    if (columnExists(table, "PolicyType") && table.Rows[i]["PolicyType"] != string.Empty) {
                                        policyTypeID = getPolicyType(table.Rows[i]["PolicyType"].ToString());

                                    }

                                    policy.PolicyType = policyTypeID;

                                    policy.LeadId = newLead.LeadId;
                                    policy.IsActive = true;
                                    policy.isAllDocumentUploaded = false;

                                    if (adjusterID != null)
                                        policy.AdjusterID = adjusterID;

                                    if (columnExists(table, "LoanID") && table.Rows[i]["LoanID"] != string.Empty) {
                                        str = table.Rows[i]["LoanID"].ToString();

                                        if (str.Length > 50)
                                            policy.LoanNumber = str.Substring(0, 50);
                                        else
                                            policy.LoanNumber = str;
                                    }

                                    if (columnExists(table, "DateOfEvaluation") && table.Rows[i]["DateOfEvaluation"] != string.Empty) {
                                        DateTime SiteSurveyDate = DateTime.MinValue;
                                        if (DateTime.TryParse(table.Rows[i]["DateOfEvaluation"].ToString(), out SiteSurveyDate))
                                            policy.SiteSurveyDate = SiteSurveyDate;
                                    }

                                    if (columnExists(table, "Mortgagee") && table.Rows[i]["Mortgagee"] != string.Empty) {
                                        int id = getMortgageeID(table.Rows[i]["Mortgagee"].ToString(), clientID);
                                        if (id > 0)
                                            policy.MortgageeID = id;
                                        else {
                                            mortgagee = new Mortgagee();
                                            mortgagee.ClientID = clientID;
                                            mortgagee.Status = true;
                                            mortgagee.MortageeName = table.Rows[i]["Mortgagee"].ToString();

                                            mortgagee = MortgageeManager.Save(mortgagee);
                                            if (mortgagee.MortgageeID > 0)
                                                policy.MortgageeID = mortgagee.MortgageeID;
                                        }
                                    }

                                    if (columnExists(table, "Loss Location") && table.Rows[i]["Loss Location"] != string.Empty)
                                        policy.LossLocation = table.Rows[i]["Loss Location"].ToString();

                                    if (columnExists(table, "Date of Loss") && table.Rows[i]["Date of Loss"] != string.Empty) {
                                        DateTime lossDate = DateTime.MinValue;
                                        if (DateTime.TryParse(table.Rows[i]["Date of Loss"].ToString(), out lossDate))
                                            policy.LossDate = lossDate;
                                    }

                                    if (columnExists(table, "Policy Period") && table.Rows[i]["Policy Period"] != string.Empty)
                                        policy.PolicyPeriod = table.Rows[i]["Policy Period"].ToString();

                                    string PolicyExpirationDate = null;
                                    if (columnExists(table, "PolicyExpirationDate") && table.Rows[i]["PolicyExpirationDate"] != string.Empty)
                                        PolicyExpirationDate = table.Rows[i]["PolicyExpirationDate"].ToString();

                                    string effectiveDate = null;
                                    if (columnExists(table, "PolicyEffectiveDate") && table.Rows[i]["PolicyEffectiveDate"] != string.Empty)
                                        effectiveDate = table.Rows[i]["PolicyEffectiveDate"].ToString();

                                    str = string.Format("{0} - {1}", effectiveDate ?? "N/A", PolicyExpirationDate ?? "N/A");
                                    if (str.Length > 50)
                                        policy.PolicyPeriod = str.Substring(0, 50);
                                    else
                                        policy.PolicyPeriod = str;

                                    if (columnExists(table, "Claim Number") && table.Rows[i]["Claim Number"] != string.Empty) {
                                        str = table.Rows[i]["Claim Number"].ToString();
                                        if (str.Length > 50)
                                            policy.ClaimNumber = str.Substring(0, 50);
                                        else
                                            policy.ClaimNumber = str;
                                    }

                                    if (columnExists(table, "Policy Number") && table.Rows[i]["Policy Number"] != string.Empty) {
                                        str = table.Rows[i]["Policy Number"].ToString();
                                        if (str.Length > 100)
                                            policy.PolicyNumber = str.Substring(0, 100);
                                        else
                                            policy.PolicyNumber = str;
                                    }

                                    if (columnExists(table, "File Number") && table.Rows[i]["File Number"] != string.Empty) {
                                        str = table.Rows[i]["File Number"].ToString();
                                        if (str.Length > 20)
                                            policy.InsurerFileNo = str.Substring(0, 20);
                                        else
                                            policy.InsurerFileNo = str;
                                    }

                                    if (statusMaster != null)
                                        policy.LeadStatus = statusMaster.StatusId;

                                    if (columnExists(table, "Ins Carrier") && table.Rows[i]["Ins Carrier"] != string.Empty) {
                                        str = table.Rows[i]["Ins Carrier"].ToString();
                                        if (str.Length > 50)
                                            policy.InsuranceCompanyName = str.Substring(0, 50);
                                        else
                                            policy.InsuranceCompanyName = str;
                                    }

                                    if (columnExists(table, "Ins Co Address") && table.Rows[i]["Ins Co Address"] != string.Empty) {
                                        str = table.Rows[i]["Ins Co Address"].ToString();
                                        if (str.Length > 50)
                                            policy.InsuranceAddress = str.Substring(0, 50);
                                        else
                                            policy.InsuranceAddress = str;

                                    }

                                    if (columnExists(table, "Ins Co City") && table.Rows[i]["Ins Co City"] != string.Empty) {
                                        string cityName = table.Rows[i]["Ins Co City"].ToString();
                                        CityMaster cityMaster = City.GetByCityName(cityName);
                                        if (cityMaster != null && cityMaster.CityId > 0)
                                            policy.InsuranceCity = cityMaster.CityId;
                                    }

                                    if (columnExists(table, "Ins Co State") && table.Rows[i]["Ins Co State"] != string.Empty) {
                                        string stateName = table.Rows[i]["Ins Co State"].ToString();
                                        StateMaster stateMaster = State.Getstateid(stateName);
                                        if (stateMaster != null && stateMaster.StateId > 0)
                                            policy.InsuranceState = stateMaster.StateId;
                                    }

                                    if (columnExists(table, "Ins Co Zip") && table.Rows[i]["Ins Co Zip"] != string.Empty) {
                                        string zipCode = table.Rows[i]["Ins Co Zip"].ToString();
                                        ZipCodeMaster zipMaster = ZipCode.GetByZipCode(zipCode);
                                        if (zipMaster != null && zipMaster.ZipCodeID > 0)
                                            policy.InsuranceZipCode = zipMaster.ZipCodeID.ToString();
                                    }

                                    LeadPolicyManager.Save(policy);

                                    // add policy comments
                                    if (columnExists(table, "Notes") && table.Rows[i]["Notes"] != string.Empty) {
                                        char[] splitTokens = { '\n' };

                                        string[] lines = table.Rows[i]["Notes"].ToString().Split(splitTokens, StringSplitOptions.RemoveEmptyEntries);
                                        if (lines != null && lines.Length > 0)
                                            foreach (string line in lines) {

                                                string[] datetimeValues = line.Split(new char[] { ' ' });
                                                if (datetimeValues.Length > 3) {
                                                    string datetime = string.Format("{0} {1} {2}", datetimeValues[0] ?? "", datetimeValues[1] ?? "", datetimeValues[2] ?? "");
                                                    DateTime commentInsertDate = DateTime.Now;
                                                    if (DateTime.TryParse(datetime, out commentInsertDate))
                                                        AddComments(newLead.LeadId, policyTypeID, line, commentInsertDate);
                                                    else
                                                        AddComments(newLead.LeadId, policyTypeID, line);

                                                }
                                                else
                                                    AddComments(newLead.LeadId, policyTypeID, line);
                                            }
                                        //AddComments(newLead.LeadId, policyTypeID, table.Rows[i]["Notes"].ToString().Replace("\n","<br/>");
                                    }

                                    if (columnExists(table, "Certified Mail Number") && table.Rows[i]["Certified Mail Number"] != string.Empty)
                                        AddComments(newLead.LeadId, policyTypeID, "Certified Mail Number: " + table.Rows[i]["Certified Mail Number"].ToString());

                                    //if (columnExists(table, "Contract Signed Date") && table.Rows[i]["Contract Signed Date"] != string.Empty)
                                    //     AddComments(newLead.LeadId, policyTypeID, "Contract Signed Date: " + table.Rows[i]["Contract Signed Date"].ToString());

                                    if (columnExists(table, "Last E-mail") && table.Rows[i]["Last E-mail"] != string.Empty)
                                        AddComments(newLead.LeadId, policyTypeID, "Last E-mail Date: " + table.Rows[i]["Last E-mail"].ToString());

                                    if (columnExists(table, "Last Meeting") && table.Rows[i]["Last Meeting"] != string.Empty)
                                        AddComments(newLead.LeadId, policyTypeID, "Last Meeting Date: " + table.Rows[i]["Last Meeting"].ToString());

                                    if (columnExists(table, "Letter Date") && table.Rows[i]["Letter Date"] != string.Empty)
                                        AddComments(newLead.LeadId, policyTypeID, "Letter Date: " + table.Rows[i]["Letter Date"].ToString());
                                }

                            }	//for (int i = 0; i < table.Rows.Count; i++) {

                            scope.Complete();

                        }
                        string rootFolderPath = Server.MapPath("~//CSVLoad//");
                        string filesToDelete = FileUpload1.FileName;
                        string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete);
                        foreach (string file in fileList) {
                            System.IO.File.Delete(file);
                        }
                        lblSave.Text = "Data Saved Successfully !!!";
                        lblSave.Visible = true;
                    }
                }
            }
            catch (Exception ex) {
                lblError.Text = "There Is a problem in  data save  !!!";
                lblError.Visible = true;
            }
        }
コード例 #17
0
ファイル: CreatePDF.cs プロジェクト: Antoniotoress1992/asp
        private static string getClaimantAddress(Leads lead)
        {
            string fulladdress = null;

            fulladdress = string.Format("{0}, {1}, {2} {3}", lead.LossAddress ?? " ", lead.CityName ?? " ", lead.StateName ?? " ", lead.Zip ?? " ");

            return fulladdress;
        }
コード例 #18
0
        protected ProducerMaster AddProducer(Leads lead, string producerName)
        {
            ProducerMaster producer = new ProducerMaster();
            producer.ClientId = lead.ClientID;
            producer.InsertBy = lead.UserId;
            producer.InsertDate = DateTime.Now;
            producer.ProducerName = producerName;
            producer.Status = 1;

            producer = ProducerManager.Save(producer);

            return producer;
        }
コード例 #19
0
        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;

            }
        }
コード例 #20
0
ファイル: ClaimManager.cs プロジェクト: Antoniotoress1992/asp
 public void UpdateInsurerName(Leads objLeads)
 {
     Leads objLeads2 = DbContextHelper.DbContext.Leads.First(x => x.LeadId == objLeads.LeadId);
     objLeads2.InsuredName = objLeads.InsuredName;
     DbContextHelper.DbContext.SaveChanges();
 }