示例#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);
        }
        private void bindHistoricalComments()
        {
            int leadID = Core.SessionHelper.getLeadId();

            Data.Entities.LeadPolicy policy = LeadPolicyManager.GetByID(this.policyID);

            if (policy != null && policy.PolicyType != null)
            {
                List <LeadComment> historicalComments = LeadCommentManager.getLeadCommentByLeadID(leadID, (int)policy.PolicyType);

                gvHistoricalComments.DataSource = historicalComments;
                gvHistoricalComments.DataBind();
            }
        }
示例#3
0
        public void bindData(int claimID)
        {
            adsource.PageSize    = 10;
            adsource.AllowPaging = true;

            pos = Convert.ToInt32(ViewState["vs"]);

            Data.Entities.LeadPolicy policy = LeadPolicyManager.Get(this.policyID);

            if (policy != null)
            {
                ViewState["policyTypeID"] = policy.PolicyType.ToString();

                ViewState["vs"] = ViewState["pageIndex"] == null ? "0" : ViewState["pageIndex"].ToString();

                pos = Convert.ToInt32(ViewState["vs"]);

                Session["pageIndex"] = null;

                FillImage(this.leadID);
            }
        }
示例#4
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;
            }
        }
示例#5
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();
            }
        }
示例#6
0
        public void bindData(int invoiceID)
        {
            int                  claimID        = 0;
            int                  clientID       = 0;
            int                  leadID         = 0;
            int                  policyID       = 0;
            Claim                claim          = null;
            Invoice              invoice        = null;
            InvoiceDetail        invoiceDetail  = null;
            Leads                lead           = null;
            List <InvoiceDetail> invoiceDetails = null;

            // save invoice id
            ViewState["InvoiceID"] = invoiceID.ToString();

            invoice = InvoiceManager.Get(invoiceID);

            if (invoice != null)
            {
                claimID = invoice.ClaimID;
                claim   = ClaimsManager.Get(claimID);

                policyID = claim.PolicyID;

                leadID = claim.LeadPolicy.Leads.LeadId;
                lead   = claim.LeadPolicy.Leads;

                clientID = (int)lead.ClientID;

                // get policy type
                if (claim.LeadPolicy != null && claim.LeadPolicy.LeadPolicyType != null)
                {
                    lblPolicyType.Text = claim.LeadPolicy.LeadPolicyType.Description;
                }

                // get policy number
                if (claim.LeadPolicy != null)
                {
                    lblPolicyNumber.Text = claim.LeadPolicy.PolicyNumber;
                }

                // get insurer claim number
                lblInsurerClaimNumber.Text = claim.InsurerClaimNumber;
            }
            else
            {
                // new invoice
                // get id for current lead
                claimID = Core.SessionHelper.getClaimID();

                // get id for current lead
                leadID = Core.SessionHelper.getLeadId();

                // get client id
                clientID = Core.SessionHelper.getClientId();

                // get current policy
                policyID = Core.SessionHelper.getPolicyID();

                // get lead/claim
                lead = LeadsManager.GetByLeadId(leadID);

                // get policy type
                lblPolicyType.Text = LeadPolicyManager.GetPolicyTypeDescription(policyID);

                // get policy number
                lblPolicyNumber.Text = LeadPolicyManager.GetPolicyNumber(policyID);

                // get insurer claim number
                lblInsurerClaimNumber.Text = ClaimsManager.getInsurerClaimNumber(claimID);
            }


            // get policy information
            if (lead != null)
            {
                lblClient.Text = string.Format("<b>{0} {1}<br/>{2}<br/>{3}<br/>{4}, {5} {6}</b>",
                                               lead.ClaimantFirstName ?? "",            //0
                                               lead.ClaimantLastName ?? "",             //1
                                               lead.LossAddress ?? "",                  //2
                                               lead.LossAddress2 ?? "",                 //3
                                               lead.CityName ?? "",                     //4
                                               lead.StateName ?? "",                    //5
                                               lead.Zip ?? ""                           //6
                                               );
            }

            if (invoiceID == 0)
            {
                // new invoice
                txtInvoiceDate.Text = DateTime.Now.ToShortDateString();

                invoiceDetail          = new InvoiceDetail();
                invoiceDetail.LineDate = DateTime.Now;

                invoiceDetails = new List <InvoiceDetail>();
                invoiceDetails.Add(invoiceDetail);

                gvInvoiceLines.DataSource = invoiceDetails;

                gvInvoiceLines.DataBind();


                // hide empty row
                gvInvoiceLines.Rows[0].Visible = false;

                // hide print button
                //btnPrint.Visible = false;

                // hiden invoice number
                //pnlInvoiceNumber.Visible = false;
            }
            else
            {
                // edit invoice

                // show print button
                btnPrint.Visible  = true;
                lbtnEmail.Visible = true;

                if (invoice != null && invoice.InvoiceDetail != null)
                {
                    txtInvoiceDate.Text = string.Format("{0:MM/dd/yyyy}", invoice.InvoiceDate);
                    txtDueDate.Text     = string.Format("{0:MM/dd/yyyy}", invoice.DueDate);

                    txtBillTo.Text         = invoice.BillToName;
                    txtBillToAddress1.Text = invoice.BillToAddress1;
                    txtBillToAddress2.Text = invoice.BillToAddress2;
                    txtBillToAddress3.Text = invoice.BillToAddress3;

                    // reference
                    txtReferenceNumber.Text = (invoice.InvoiceNumber ?? 0).ToString();

                    // show total
                    txtTotalAmount.Text = string.Format("{0:N2}", invoice.TotalAmount);


                    // sort line items by date
                    gvInvoiceLines.DataSource = invoice.InvoiceDetail.OrderBy(x => x.LineDate);

                    gvInvoiceLines.DataBind();

                    // show invoice numebr
                    //pnlInvoiceNumber.Visible = true;


                    txtInvoiceNumber.Text = string.Format("{0:N0}", invoice.InvoiceNumber ?? 0);
                }
            }


            bindInvoiceServices();

            contractGrid.DataBind();
        }
        public void fillForm()
        {
            Contact primaryContact = null;
            string  zipCode        = null;

            if (policyID > 0)
            {
                CRM.Data.Entities.LeadPolicy policy = LeadPolicyManager.Get(policyID);

                if (policy == null)
                {
                    return;
                }

                ViewState["policyType"] = policy.PolicyType.ToString();

                hf_policyID.Value     = policy.Id.ToString();
                hf_lastStatusID.Value = (policy.LeadStatus ?? 0).ToString();

                //cbxAllDocumentUploaded.Checked = policy.isAllDocumentUploaded ?? false;

                if (policy.PolicyType != null)
                {
                    ucPolicyType1.SelectedValue = policy.PolicyType.ToString();
                }

                txtPolicyFormType.Text = policy.PolicyFormType;

                txtInsuranceCompanyName.Text  = policy.Carrier == null ? policy.InsuranceCompanyName : policy.Carrier.CarrierName;
                txtInsuranceAddress.Text      = policy.Carrier == null ? policy.InsuranceAddress : policy.Carrier.AddressLine1;
                txtInsuranceAddress2.Text     = policy.Carrier == null ? "" : policy.Carrier.AddressLine2;
                txtInsurancePolicyNumber.Text = policy.PolicyNumber;

                if (policy.Carrier != null)
                {
                    txtInsuranceState.Text   = policy.Carrier.StateName;
                    txtInsuranceCity.Text    = policy.Carrier.CityMaster != null ? policy.Carrier.CityMaster.CityName : string.Empty;
                    txtInsuranceZipCode.Text = policy.Carrier.ZipCode;

                    ddlCarrier.SelectedValue = policy.CarrierID.ToString();

                    // get primary carrier contact
                    primaryContact = CarrierContactManager.GetPrimaryContact((int)policy.CarrierID);
                    if (primaryContact != null)
                    {
                        txtPrimaryContactName.Text  = primaryContact.fullName;
                        txtPrimaryContactEmail.Text = primaryContact.Email;
                        txtPrimaryContactPhone.Text = primaryContact.Phone;
                    }
                }
                else
                {
                    zipCode = policy.InsuranceZipCode ?? "";
                }

                txtInsuranceFaxNumber.Text = policy.FaxNumber;

                txtInsurancePhoneNumber.Text = policy.PhoneNumber;

                txtEffectiveDate.Value = policy.EffectiveDate;

                txtExpirationDate.Value = policy.ExpirationDate;

                txtInitialCoverageDate.Value = policy.InitialCoverageDate;

                if (policy.AgentID != null)
                {
                    fillAgentDetails((int)policy.AgentID);
                }
            }
        }
        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);
            }
        }
        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);
            }
        }
示例#10
0
        private void saveInvoice()
        {
            string[] billToValues  = null;
            int      clientID      = 0;
            int      invoiceID     = 0;
            int      InvoiceLineID = 0;

            Data.Entities.LeadInvoice    invoice           = null;
            CRM.Data.Entities.LeadPolicy policy            = null;
            LeadInvoiceDetail            invoiceDetailLine = null;
            LeadInvoiceDetail            invoiceDetail     = null;

            int     nextInvoiceNumber = 0;
            int     policyID          = 0;
            decimal taxAmount         = 0;

            billToValues = ddlBillTo.SelectedValue.Split(new char[] { '|' });

            // get invoice id
            invoiceID = Convert.ToInt32(ViewState["InvoiceID"].ToString());

            clientID = Core.SessionHelper.getClientId();

            // current policy being edited
            policyID = Session["policyID"] == null ? 0 : Convert.ToInt32(Session["policyID"]);
            policy   = LeadPolicyManager.GetByID(policyID);



            if (invoiceID == 0)
            {
                invoice = new Data.Entities.LeadInvoice();

                // get id for current lead
                invoice.LeadId = Core.SessionHelper.getLeadId();

                invoice.isVoid = false;

                // assign client
                invoice.ClientID = clientID;

                // hide print button
                //btnPrint.Visible = false;
            }
            else
            {
                invoice = LeadInvoiceManager.Get(invoiceID);

                // show print button
                //btnPrint.Visible = true;
            }


            invoice.PolicyID = policy.PolicyType;

            invoice.InvoiceDate    = Convert.ToDateTime(txtInvoiceDate.Text);
            invoice.DueDate        = Convert.ToDateTime(txtDueDate.Text);
            invoice.BillToName     = txtBillTo.Text.Trim();
            invoice.BillToAddress1 = txtBillToAddress1.Text.Trim();
            invoice.BillToAddress2 = txtBillToAddress2.Text.Trim();
            invoice.BillToAddress3 = txtBillToAddress3.Text.Trim();

            invoice.AdjusterID = policy.AdjusterID;

            invoice.AdjusterInvoiceNumber = txtReferenceNumber.Text.Trim();

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    if (invoiceID == 0)
                    {
                        // assign next invoice number to new invoice
                        nextInvoiceNumber = LeadInvoiceManager.GetNextInvoiceNumber(clientID);

                        invoice.InvoiceNumber = nextInvoiceNumber;
                    }

                    invoiceID = LeadInvoiceManager.Save(invoice);

                    // save newly generated invoice id
                    ViewState["InvoiceID"] = invoiceID.ToString();

                    // check for add/edit invoice detail line
                    InvoiceLineID = ViewState["InvoiceLineID"] == null ? 0 : Convert.ToInt32(ViewState["InvoiceLineID"]);

                    if (InvoiceLineID > 0)
                    {
                        invoiceDetail = LeadInvoiceDetailManager.Get(InvoiceLineID);
                    }
                    else
                    {
                        invoiceDetail = new LeadInvoiceDetail();
                    }


                    // get detail line from gridview footer
                    if (invoiceDetail != null)
                    {
                        invoiceDetailLine = getInvoiceDetailLine();

                        if (invoiceDetailLine.LineDate != null && !string.IsNullOrEmpty(invoiceDetailLine.LineDescription) && invoiceDetailLine.Qty > 0 &&
                            invoiceDetailLine.Rate > 0)
                        {
                            // update fields
                            invoiceDetail.InvoiceID       = invoiceID;
                            invoiceDetail.InvoiceLineID   = InvoiceLineID;
                            invoiceDetail.ServiceTypeID   = invoiceDetailLine.ServiceTypeID;
                            invoiceDetail.Comments        = invoiceDetailLine.Comments;
                            invoiceDetail.isBillable      = invoiceDetailLine.isBillable;
                            invoiceDetail.LineAmount      = invoiceDetailLine.LineAmount;
                            invoiceDetail.LineDate        = invoiceDetailLine.LineDate;
                            invoiceDetail.LineDescription = invoiceDetailLine.LineDescription;
                            invoiceDetail.Qty             = invoiceDetailLine.Qty;
                            invoiceDetail.Rate            = invoiceDetailLine.Rate;
                            invoiceDetail.UnitDescription = invoiceDetailLine.UnitDescription;
                            invoiceDetail.Total           = invoiceDetailLine.Total;

                            // save invoice detail
                            LeadInvoiceDetailManager.Save(invoiceDetail);

                            // clear
                            ViewState["InvoiceLineID"] = "0";

                            // update invoice total after adding
                            invoice = LeadInvoiceManager.Get(invoiceID);

                            invoice.TotalAmount = invoice.LeadInvoiceDetail.Where(x => x.isBillable == true).Sum(x => x.LineAmount);

                            taxAmount = (invoice.TotalAmount ?? 0) * ((invoice.TaxRate ?? 0) / 100);

                            //invoice.TotalAmount = invoice.TotalAmount + taxAmount;

                            LeadInvoiceManager.Save(invoice);

                            // update comment
                            updateInvoiceComment(invoice, invoiceDetail);
                        }
                    }
                    // complete transaction
                    scope.Complete();
                }

                // refresh invoice detail lines
                bindInvoiceDetails(invoiceID);

                clearFields();

                showToolbarButtons();
            }
            catch (Exception ex) {
                lblMessage.Text     = "Error while saving invoice.";
                lblMessage.CssClass = "error";
                Core.EmailHelper.emailError(ex);
            }
        }
示例#11
0
        protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                Label lblCommissionTotal = e.Row.FindControl("lblCommissionTotal") as Label;
                lblCommissionTotal.Text = string.Format("{0:N2}", totalCommission);

                Label lblTotalExpenses = e.Row.FindControl("lblTotalExpenses") as Label;
                lblTotalExpenses.Text = string.Format("{0:N2}", totalExpenses);

                Label lblAdjusterNet = e.Row.FindControl("lblAdjusterNet") as Label;
                lblAdjusterNet.Text = string.Format("{0:N2}", totalNetAdjuster);

                Label lblInvoiceTotal = e.Row.FindControl("lblInvoiceTotal") as Label;
                lblInvoiceTotal.Text = string.Format("{0:N2}", totalInvoice);
            }
            else if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton btnEdit        = e.Row.FindControl("btnEdit") as ImageButton;
                Label       lblTotalAmount = e.Row.FindControl("lblTotalAmount") as Label;
                List <CRM.Data.Entities.LeadPolicy> policies = null;
                string claimNumber  = null;
                int    policyTypeID = 0;

                ImageButton btnPrint = e.Row.FindControl("btnPrint") as ImageButton;

                Ledger ledger = e.Row.DataItem as Ledger;

                totalCommission  += ledger.CommissionTotal ?? 0;
                totalExpenses    += ledger.TotalExpenses ?? 0;
                totalNetAdjuster += ledger.AdjusterNet ?? 0;
                totalInvoice     += ledger.InvoiceTotal ?? 0;

                //adjusterNet = (ledger.LeadInvoice.TotalAmount ?? 0 ) - (ledger.TotalExpenses ?? 0);

                //Label lblAdjusterNet = e.Row.FindControl("lblAdjusterNet") as Label;
                //lblAdjusterNet.Text = string.Format("{0:N2}", adjusterNet);

                //HyperLink hlink = e.Row.FindControl("lnlEditAdjuster") as HyperLink;
                //hlink.NavigateUrl = "~/Protected/Admin/AdjusterEdit.aspx?id=" + ledger.AdjusterID.ToString();

                policies = LeadPolicyManager.GetPolicies((int)ledger.LeadInvoice.LeadId);
                if (policies != null)
                {
                    policyTypeID = ledger.LeadInvoice.PolicyTypeID ?? 0;
                    claimNumber  = (from x in policies
                                    where x.PolicyType == policyTypeID
                                    select x.ClaimNumber).FirstOrDefault();

                    if (claimNumber != null)
                    {
                        Label lblClaimNumber = e.Row.FindControl("lblClaimNumber") as Label;
                        lblClaimNumber.Text = claimNumber;
                    }
                }

                if (btnEdit != null && ledger != null)
                {
                    //btnEdit.Attributes["onclick"] = string.Format("javascript:return editInvoice({0});", invoice.InvoiceID);
                    btnEdit.PostBackUrl = string.Format("~/Protected/Admin/LeadInvoice.aspx?id={0}", ledger.InvoiceID);
                }

                if (btnPrint != null && ledger != null)
                {
                    btnPrint.Attributes["onclick"] = string.Format("javascript:return printInvoice({0});", ledger.InvoiceID);
                }
            }
        }
示例#12
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");
                }
            }
        }
示例#13
0
        //protected void bindBillTo(Lead lead) {
        //	ListItem billToItem = null;
        //	string itemValue = null;
        //	string claimantName = null;

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

        //	if (lead != null && lead.LeadPolicies != null && lead.LeadPolicies.Count > 0) {

        //		// add insurance company policy
        //		foreach (LeadPolicy policy in lead.LeadPolicies) {
        //			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));
        //	}
        //}

        protected void bindData()
        {
            int    claimID      = 0;
            int    clientID     = 0;
            int    invoiceID    = 0;
            int    leadID       = 0;
            int    policyID     = 0;
            string dencryptedID = null;

            Invoice              invoice        = null;
            InvoiceDetail        invoiceDetail  = null;
            List <InvoiceDetail> invoiceDetails = null;

            // get id for current lead
            claimID = Core.SessionHelper.getClaimID();

            // get id for current lead
            leadID = Core.SessionHelper.getLeadId();

            // get client id
            clientID = Core.SessionHelper.getClientId();

            // get current policy
            policyID = Core.SessionHelper.getPolicyID();

            // check for new invoice or edit invoice
            if (Request.Params["q"] != null)
            {
                dencryptedID           = Core.SecurityManager.DecryptQueryString(Request.Params["q"].ToString());
                ViewState["InvoiceID"] = dencryptedID;
            }
            else
            {
                ViewState["InvoiceID"] = "0";
            }


            int.TryParse(ViewState["InvoiceID"].ToString(), out invoiceID);

            // get lead/claim
            Leads lead = LeadsManager.GetByLeadId(leadID);

            // get policy type
            lblPolicyType.Text = LeadPolicyManager.GetPolicyTypeDescription(policyID);

            // get policy number
            lblPolicyNumber.Text = LeadPolicyManager.GetPolicyNumber(policyID);

            // get insurer claim number
            lblInsurerClaimNumber.Text = ClaimsManager.getInsurerClaimNumber(claimID);

            // get policy information
            if (lead != null)
            {
                lblClient.Text = string.Format("<b>{0} {1}<br/>{2}<br/>{3}<br/>{4}, {5} {6}</b>",
                                               lead.ClaimantFirstName ?? "",            //0
                                               lead.ClaimantLastName ?? "",             //1
                                               lead.LossAddress ?? "",                  //2
                                               lead.LossAddress2 ?? "",                 //3
                                               lead.CityName ?? "",                     //4
                                               lead.StateName ?? "",                    //5
                                               lead.Zip ?? ""                           //6
                                               );
            }



            if (invoiceID == 0)
            {
                // new invoice
                txtInvoiceDate.Text = DateTime.Now.ToShortDateString();

                invoiceDetail          = new InvoiceDetail();
                invoiceDetail.LineDate = DateTime.Now;

                invoiceDetails = new List <InvoiceDetail>();
                invoiceDetails.Add(invoiceDetail);

                gvInvoiceLines.DataSource = invoiceDetails;

                gvInvoiceLines.DataBind();


                // hide empty row
                gvInvoiceLines.Rows[0].Visible = false;

                // hide print button
                //btnPrint.Visible = false;

                // hiden invoice number
                //pnlInvoiceNumber.Visible = false;
            }
            else
            {
                // edit invoice
                invoice = InvoiceManager.Get(invoiceID);

                // show print button
                //btnPrint.Visible = true;

                if (invoice != null && invoice.InvoiceDetail != null)
                {
                    txtInvoiceDate.Text = string.Format("{0:MM/dd/yyyy}", invoice.InvoiceDate);
                    txtDueDate.Text     = string.Format("{0:MM/dd/yyyy}", invoice.DueDate);

                    txtBillTo.Text         = invoice.BillToName;
                    txtBillToAddress1.Text = invoice.BillToAddress1;
                    txtBillToAddress2.Text = invoice.BillToAddress2;
                    txtBillToAddress3.Text = invoice.BillToAddress3;

                    // reference
                    txtReferenceNumber.Text = (invoice.InvoiceNumber ?? 0).ToString();

                    // show total
                    txtTotalAmount.Text = string.Format("{0:N2}", invoice.TotalAmount);


                    // sort line items by date
                    gvInvoiceLines.DataSource = invoice.InvoiceDetail.OrderBy(x => x.LineDate);

                    gvInvoiceLines.DataBind();

                    // show invoice numebr
                    //pnlInvoiceNumber.Visible = true;


                    txtInvoiceNumber.Text = string.Format("{0:N0}", invoice.InvoiceNumber ?? 0);
                }
            }


            bindInvoiceServices();
        }