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(); }
//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(); }