Exemplo n.º 1
0
        private CRM.Data.Entities.LeadPolicy createPolicy(int leadID, DataRow dataRow)
        {
            CRM.Data.Entities.LeadPolicy policy = null;
            string userFieldName = null;

            policy = new CRM.Data.Entities.LeadPolicy();

            policy.LeadId   = leadID;
            policy.IsActive = true;

            // Policy Number
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Policy Number");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                policy.PolicyNumber = dataRow[userFieldName].ToString().Trim();
            }

            // Policy Form
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Policy Form");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                policy.PolicyFormType = dataRow[userFieldName].ToString().Trim();
            }

            LeadPolicyManager.Save(policy);

            return(policy);
        }
Exemplo n.º 2
0
        protected void gvPolicyList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int id = 0;

            switch (e.CommandName)
            {
            case "DoEdit":
            case "DoView":
                Session["policyID"] = e.CommandArgument;

                Response.Redirect("~/Protected/LeadPolicyEdit.aspx");
                break;

            case "DoDelete":
                id = Convert.ToInt32(e.CommandArgument);
                try {
                    Data.Entities.LeadPolicy policy = LeadPolicyManager.Get(id);
                    if (policy != null)
                    {
                        policy.IsActive = false;

                        LeadPolicyManager.Save(policy);

                        // refresh policy list
                        gvPolicyList.DataBind();
                    }
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
                break;


            default:
                break;
            }
        }
Exemplo n.º 3
0
        // generate invoices
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            Carrier carrier = null;
            CarrierInvoiceProfile profile = null;

            Invoice invoice       = null;
            int     carrierID     = Convert.ToInt32(ddlCarrier.SelectedValue);
            decimal invoiceAmount = 0;
            int     policyID      = 0;

            int profileID = Convert.ToInt32(this.ddlInvoiceProfile.SelectedValue);

            if (carrierID == 0 || profileID == 0)
            {
                return;
            }

            try {
                profile = CarrierInvoiceProfileManager.Get(profileID);

                carrier = CarrierManager.Get(carrierID);
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);

                showErrorMessage();

                return;
            }

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    foreach (GridViewRow row in gvCarrierPolicy.Rows)
                    {
                        if (row.RowType == DataControlRowType.DataRow)
                        {
                            CheckBox cbxSelect = row.FindControl("cbxSelect") as CheckBox;

                            if (cbxSelect.Checked)
                            {
                                invoice = new Invoice();
                                //invoice.ClientID = clientID;
                                //invoice.CarrierID = carrierID;
                                invoice.InvoiceDate = DateTime.Now;

                                invoice.InvoiceTypeID = profile.InvoiceType;

                                invoice.CarrierInvoiceProfileID = profileID;

                                invoice.IsVoid = false;

                                invoice.BillToAddress1 = carrier.AddressLine1;
                                invoice.BillToAddress2 = carrier.AddressLine2;
                                invoice.BillToAddress3 = string.Empty;
                                invoice.BillToName     = carrier.CarrierName;

                                policyID = (int)gvCarrierPolicy.DataKeys[row.RowIndex].Values[0];

                                //invoice.PolicyID = policyID;

                                //invoice.LeadId = (int)gvCarrierPolicy.DataKeys[row.RowIndex].Values[1];

                                //invoice.PolicyTypeID = (int)gvCarrierPolicy.DataKeys[row.RowIndex].Values[2];

                                Label lblInvoiceAmount = row.FindControl("lblInvoiceAmount") as Label;

                                decimal.TryParse(lblInvoiceAmount.Text, out invoiceAmount);

                                invoice.TotalAmount = invoiceAmount;

                                invoice.InvoiceNumber = InvoiceManager.GetNextInvoiceNumber(clientID);

                                int invoiceID = InvoiceManager.Save(invoice);

                                InvoiceDetail invoiceDetail = new InvoiceDetail();
                                invoiceDetail.InvoiceID       = invoiceID;
                                invoiceDetail.isBillable      = true;
                                invoiceDetail.Qty             = 1;
                                invoiceDetail.Rate            = invoiceAmount;
                                invoiceDetail.LineAmount      = invoiceAmount;
                                invoiceDetail.LineDate        = DateTime.Now;
                                invoiceDetail.LineDescription = "As per contract";

                                InvoiceDetailManager.Save(invoiceDetail);

                                // flag policy as invoiced
                                CRM.Data.Entities.LeadPolicy policy = LeadPolicyManager.Get(policyID);

                                if (policy != null)
                                {
                                    policy.IsInvoiced = true;

                                    LeadPolicyManager.Save(policy);
                                }
                            }
                        }
                    }                     // foreach

                    // complete transaction
                    scope.Complete();

                    lblMessage.Text     = "Invoice(s) have been generated.";
                    lblMessage.CssClass = "ok";
                }
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);

                showErrorMessage();
            }
            finally {
                // refresh those policies to be invoiced
                bindPoliciesReadyForInvoice();
            }
        }
Exemplo n.º 4
0
        public void saveForm()
        {
            Page.Validate("Policy");
            //if (!Page.IsValid)
            //    return;

            CRM.Data.Entities.LeadPolicy policy = null;

            lblMessage.Text     = string.Empty;
            lblMessage.CssClass = string.Empty;

            //if (int.TryParse(hf_policyID.Value, out id) && id > 0) {
            if (policyID > 0)
            {
                policy = LeadPolicyManager.Get(policyID);
            }
            else
            {
                // new
                policy          = new CRM.Data.Entities.LeadPolicy();
                policy.LeadId   = Core.SessionHelper.getLeadId();
                policy.Id       = 0;
                policy.IsActive = true;
                policy.isAllDocumentUploaded = false;
            }
            if (ucPolicyType1.SelectedValue == "0" || ucPolicyType1.SelectedValue == "")
            {
                policy.PolicyType = null;
            }
            else
            {
                policy.PolicyType = Convert.ToInt32(ucPolicyType1.SelectedValue);
            }

            // carrier information
            if (ddlCarrier.SelectedIndex > 0)
            {
                policy.CarrierID = Convert.ToInt32(ddlCarrier.SelectedValue);
            }
            else
            {
                policy.CarrierID = null;
            }

            policy.PolicyNumber   = txtInsurancePolicyNumber.Text.Trim();
            policy.PolicyFormType = txtPolicyFormType.Text.Trim();

            policy.InsuranceCompanyName = txtInsuranceCompanyName.Text;

            if (!string.IsNullOrEmpty(txtExpirationDate.Text))
            {
                policy.ExpirationDate = txtExpirationDate.Date;
            }
            else
            {
                policy.ExpirationDate = null;
            }

            if (!string.IsNullOrEmpty(txtExpirationDate.Text))
            {
                policy.EffectiveDate = txtEffectiveDate.Date;
            }
            else
            {
                policy.EffectiveDate = null;
            }

            if (!string.IsNullOrEmpty(txtInitialCoverageDate.Text))
            {
                policy.InitialCoverageDate = txtInitialCoverageDate.Date;
            }

            if (ddlAgent.SelectedIndex > 0)
            {
                policy.AgentID = Convert.ToInt32(ddlAgent.SelectedValue);
            }

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    // save policy id
                    this.policyID = LeadPolicyManager.Save(policy);



                    if (HttpContext.Current.Session["Limit"] != null && HttpContext.Current.Session["PolicyLimit"] != null && HttpContext.Current.Session["tblCasulityPolicylimit"] != null && HttpContext.Current.Session["tblAllPolicylimit"] != null)
                    {
                        AddLimitPolicy(this.policyID);
                        CacheBlank();
                        ShowAddCoverage();
                        SetAddCoverage(this.policyID);
                        HideAddCoverageAdd();
                    }
                    else
                    {
                        propertyLimits.saveLimits(policyID);

                        //casualtyLimits.saveLimits(policyID);
                    }



                    propertySubLimits.saveLimits(policyID);

                    scope.Complete();
                }

                // save policy type in viewstate
                policyType = ucPolicyType1.SelectedValue;

                // save policy id
                hf_policyID.Value = policyID.ToString();

                // activate other tabs
                tabContainerPolicy.Visible = true;

                activateLinks();

                bindLimits();

                bindClaims();

                //bindData();


                lblMessage.Text     = "Policy Information saved successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text     = "Policy Information was not saved.";
                lblMessage.CssClass = "error";

                Core.EmailHelper.emailError(ex);
            }
        }
Exemplo n.º 5
0
        protected void btnAgentNewSave_Click(object sender, EventArgs e)
        {
            CRM.Data.Entities.LeadPolicy policy = null;

            Contact contact = null;

            contact          = new Contact();
            contact.ClientID = SessionHelper.getClientId();
            contact.IsActive = true;
            contact.Address1 = txtAgentAddress1.Text;
            contact.Address2 = txtAgentAddress2.Text;

            contact.CategoryID  = (int)Globals.ContactType.Agent;
            contact.CompanyName = txtAgentEntityName.Text;
            contact.ContactName = txtAgentFirstName.Text + " " + txtAgentLastName.Text;

            contact.Email     = txtAgentEmail.Text;
            contact.Fax       = txtAgentFax.Text;
            contact.FirstName = txtAgentFirstName.Text;
            contact.LastName  = txtAgentLastName.Text;

            contact.Phone = txtAgentPhoneNumber.Text;

            if (ddlState.SelectedIndex > 0)
            {
                contact.StateID = Convert.ToInt32(ddlState.SelectedValue);
            }

            if (ddlCity.SelectedIndex > 0)
            {
                contact.CityID = Convert.ToInt32(ddlCity.SelectedValue);
            }

            if (ddlAgentZip.SelectedIndex > 0)
            {
                contact.ZipCodeID = Convert.ToInt32(ddlAgentZip.SelectedValue);
            }


            try {
                using (TransactionScope scope = new TransactionScope()) {
                    contact = ContactManager.Save(contact);

                    policy = LeadPolicyManager.Get(this.policyID);

                    policy.AgentID = contact.ContactID;

                    LeadPolicyManager.Save(policy);

                    scope.Complete();
                }

                showInputFields(false);

                showLabelField(true);

                bindAgents();

                ddlAgent.SelectedValue = contact.ContactID.ToString();

                fillAgentDetails(contact.ContactID);
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);
            }
        }
Exemplo n.º 6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string  assignmentInstructions = null;
            Carrier carrier              = null;
            bool    isSuccess            = true;
            Leads   lead                 = null;
            string  lossPerilDescription = null;

            CRM.Data.Entities.LeadPolicy policy = collectPolicyDataFromUI();
            int policyID = 0;

            lblMessage.Text = string.Empty;

            using (TransactionScope scope = new TransactionScope()) {
                try {
                    // save lead/claim
                    lead = saveLead();

                    // save carrier
                    carrier = saveCarrier();

                    // save carrier contact
                    saveContact(carrier.CarrierID);

                    // save policy
                    policy.LeadId = lead.LeadId;

                    if (carrier != null)
                    {
                        policy.CarrierID = carrier.CarrierID;
                    }

                    policyID = LeadPolicyManager.Save(policy);

                    //saveCoverages(policyID);

                    // save assingment instructions in comments
                    if (!string.IsNullOrEmpty(txtAssignmentInstructions.Text))
                    {
                        assignmentInstructions = "<div><b>Assignment Instructions</b></div><div>" + this.txtAssignmentInstructions.Text.Trim() + "</div>";
                        saveComments(assignmentInstructions, (int)policy.PolicyType, lead.LeadId);
                    }

                    // save loss Peril Description in comments
                    if (!string.IsNullOrEmpty(this.txtLossPerilDescription.Text))
                    {
                        lossPerilDescription = "<div><b>Loss/Peril Description</b></div><div>" + this.txtLossPerilDescription.Text.Trim() + "</div>";
                        saveComments(lossPerilDescription, (int)policy.PolicyType, lead.LeadId);
                    }

                    // save final comments
                    saveComments(txtComments.Text.Trim(), (int)policy.PolicyType, lead.LeadId);

                    uploadFile(fileUpload1, lead.LeadId, txtfileUpload1.Text);
                    uploadFile(fileUpload2, lead.LeadId, txtfileUpload2.Text);
                    uploadFile(fileUpload3, lead.LeadId, txtfileUpload3.Text);
                    uploadFile(fileUpload4, lead.LeadId, txtfileUpload4.Text);
                    uploadFile(fileUpload5, lead.LeadId, txtfileUpload5.Text);

                    // complete transaction and alert user
                    scope.Complete();

                    //lblMessage.Text = "Data has been submitted successfully.";
                    //lblMessage.CssClass = "ok";
                    isSuccess = true;
                }
                catch (Exception ex) {
                    lblMessage.Text     = "Unable to submit data due to error.";
                    lblMessage.CssClass = "error";

                    isSuccess = false;
                }

                // reload page
                if (isSuccess)
                {
                    Response.Redirect("~/Protected/Intake/form.aspx");
                }
            }
        }