Beispiel #1
0
        private void bindInvoiceDetailLines(int invoiceID)
        {
            List <InvoiceDetail> invoiceDetails = null;

            invoiceDetails = InvoiceDetailManager.GetInvoiceDetails(invoiceID);

            gvTimeExpense.DataSource = invoiceDetails;
            gvTimeExpense.DataBind();
        }
Beispiel #2
0
        protected void bindInvoiceDetails(int invoiceID)
        {
            List <InvoiceDetail> invoiceDetailLines = null;
            decimal?totalAmount = 0;

            invoiceDetailLines = InvoiceDetailManager.GetInvoiceDetails(invoiceID);

            gvInvoiceLines.DataSource = invoiceDetailLines.OrderBy(x => x.LineDate);

            gvInvoiceLines.DataBind();

            // total invoice lines
            if (invoiceDetailLines != null && invoiceDetailLines.Count > 0)
            {
                totalAmount = invoiceDetailLines.Where(x => x.isBillable == true).Sum(x => x.LineAmount);


                txtTotalAmount.Text = string.Format("{0:N2}", totalAmount);
            }
        }
Beispiel #3
0
        private void calculateLineTotal()
        {
            int     invoiceID                   = 0;
            decimal qty                         = 0;
            decimal rate                        = 0;
            decimal totalAmount                 = 0;
            decimal taxableTotal                = 0;
            string  unitDescription             = null;
            List <InvoiceDetail> invoiceDetails = null;

            // get service unit type
            Label lblUnitDescription = gvInvoiceLines.FooterRow.FindControl("lblUnitDescription") as Label;

            if (lblUnitDescription != null)
            {
                unitDescription = lblUnitDescription.Text;
            }

            // get quantity
            WebNumericEditor txtQty = gvInvoiceLines.FooterRow.FindControl("txtQty") as WebNumericEditor;

            if (txtQty != null)
            {
                qty = txtQty.Value == null ? 0 : Convert.ToDecimal(txtQty.Value);
            }

            // rate
            WebNumericEditor txtRate = gvInvoiceLines.FooterRow.FindControl("txtRate") as WebNumericEditor;

            // remove any % symbol
            if (txtRate != null)
            {
                rate = txtRate.Value == null ? 0 : Convert.ToDecimal(txtRate.Value);
            }

            if (!string.IsNullOrEmpty(unitDescription) && unitDescriptions.Contains(unitDescription.ToLower()))
            {
                rate /= 100;                    // make it a percent for "percentage, sales tax"
            }
            totalAmount = rate * qty;

            if (!string.IsNullOrEmpty(unitDescription) && unitDescription.ToLower().Equals("sales tax"))
            {
                int.TryParse(ViewState["InvoiceID"].ToString(), out invoiceID);

                invoiceDetails = InvoiceDetailManager.GetInvoiceDetails(invoiceID);

                taxableTotal = (decimal)invoiceDetails.Where(x => x.isBillable == true &&
                                                             x.InvoiceServiceType.InvoiceServiceUnit.UnitID != SALES_TAX_ID)
                               .Sum(x => x.LineAmount);

                totalAmount = taxableTotal * rate;
            }


            TextBox txtLineAmount = gvInvoiceLines.FooterRow.FindControl("txtLineAmount") as TextBox;

            if (txtLineAmount != null)
            {
                txtLineAmount.Text = totalAmount.ToString("N2");
            }
        }