private List <ClaimExpense> loadExpenses(int claimID)
        {
            List <ClaimExpense> expenses = null;

            using (ClaimExpenseManager repository = new ClaimExpenseManager()) {
                expenses = repository.GetAll(claimID);
            }

            return(expenses);
        }
Exemple #2
0
        private void bindTimeExpenseForInvoice(int claimID)
        {
            List <InvoiceDetail> invoiceDetails = new List <InvoiceDetail>();
            InvoiceDetail        invoiceDetail  = null;
            decimal serviceRate       = 0;
            decimal servicePercentage = 0;
            decimal rate = 0;

            List <ClaimService> claimServices = null;
            List <ClaimExpense> claimExpenses = null;

            using (ClaimServiceManager repository = new ClaimServiceManager()) {
                claimServices = repository.GetAll(claimID);
            }
            using (ClaimExpenseManager repository = new ClaimExpenseManager()) {
                claimExpenses = repository.GetAll(claimID);
            }

            // add claim services to invoice
            if (claimServices != null)
            {
                foreach (ClaimService service in claimServices)
                {
                    invoiceDetail                 = new InvoiceDetail();
                    invoiceDetail.LineDate        = service.ServiceDate;
                    invoiceDetail.ServiceTypeID   = service.ServiceTypeID;
                    invoiceDetail.LineDescription = service.InvoiceServiceType.ServiceDescription;
                    invoiceDetail.Qty             = service.ServiceQty;
                    invoiceDetail.Comments        = service.ServiceDescription;

                    serviceRate       = service.InvoiceServiceType.ServiceRate ?? 0;
                    servicePercentage = service.InvoiceServiceType.ServicePercentage ?? 0;

                    if (serviceRate > 0)
                    {
                        rate = serviceRate;
                    }
                    else
                    {
                        rate = servicePercentage / 100;
                    }

                    invoiceDetail.LineAmount = invoiceDetail.Qty * rate;
                    invoiceDetail.Rate       = rate;

                    // add service to invoicedetail list
                    invoiceDetails.Add(invoiceDetail);
                }
            }
            // add claim expenses to invoice
            if (claimExpenses != null)
            {
                foreach (ClaimExpense expense in claimExpenses)
                {
                    invoiceDetail = new InvoiceDetail();
                    invoiceDetail.ExpenseTypeID   = expense.ExpenseTypeID;
                    invoiceDetail.LineDate        = expense.ExpenseDate;
                    invoiceDetail.LineDescription = expense.ExpenseDescription;
                    invoiceDetail.Comments        = expense.ExpenseDescription;
                    invoiceDetail.LineAmount      = expense.ExpenseAmount;
                    invoiceDetail.Qty             = 1;
                    invoiceDetail.Rate            = expense.ExpenseAmount;
                    // add expense to invoicedetail list
                    invoiceDetails.Add(invoiceDetail);
                }
            }

            // bind invoice detail lines
            gvTimeExpense.DataSource = invoiceDetails;
            gvTimeExpense.DataBind();
        }