Ejemplo n.º 1
0
        private void RefreshDataGridViewRows(DataGridViewRowCollection rows, Price.ShowFormat priceFormat)
        {
            foreach (DataGridViewRow row in rows)
            {
                InvoiceShared invoice = GetCommonInvoiceFromRow(row);

                if (IsUserInvoice(row))
                {
                    ShowUserInvoice(row, invoice, GetUserInvoiceFromRow(row), priceFormat);
                }
                else
                {
                    ShowCommonInvoice(row, invoice, priceFormat);
                }
            }
        }
Ejemplo n.º 2
0
        private void ShowSharedInvoice(InvoiceShared invoice, Price.ShowFormat priceFormat)
        {
            DataGridViewRow row = new DataGridViewRow();

            row.CreateCells(dataGridView);

            ShowCommonInvoice(row, invoice, priceFormat);
            dataGridView.Rows.Add(row);

            foreach (UserInvoice userInvoice in invoice.UserInvoices)
            {
                row = new DataGridViewRow();
                row.CreateCells(dataGridView);

                ShowUserInvoice(row, invoice, userInvoice, priceFormat);
                dataGridView.Rows.Add(row);
            }
        }
Ejemplo n.º 3
0
        private void ShowInvoiceHistory(InvoiceHistory invoiceHistory, Price.ShowFormat priceFormat)
        {
            dataGridView.Rows.Clear();

            if (invoiceHistory == null)
            {
                return;
            }

            foreach (InvoiceShared invoice in invoiceHistory.Invoices)
            {
                FeeConfig feeConfig = invoiceHistory.FeeConfigHistory.GetFeeConfigHistoryForPeriod(invoice).FirstOrDefault();
                invoice.SetFeeConfig(feeConfig);

                ShowSharedInvoice(invoice, priceFormat);
            }

            dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
        }
Ejemplo n.º 4
0
        private static void ShowUserInvoice(DataGridViewRow row, InvoiceShared invoice, UserInvoice userInvoice, Price.ShowFormat priceFormat)
        {
            Contract.Requires(row != null);
            Contract.Requires(invoice != null);
            Contract.Requires(userInvoice != null);

            row.Cells[0].Value           = userInvoice.InvoiceOwner;
            row.Cells[0].Tag             = invoice.Id;
            row.Cells[1].Style.BackColor = Color.LightGray;

            row.Cells[2].Value = userInvoice.InvoiceOwner;

            row.Cells[3].Value           = userInvoice.GetReadOut().ToString();
            row.Cells[3].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(inv => inv.GetReadOut().Sum(), userInv => userInv.GetReadOut().Sum()) ?
                                           Color.LightPink : row.Cells[3].Style.BackColor;

            row.Cells[4].Value           = userInvoice.GetConsumption().ToString();
            row.Cells[4].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(inv => inv.GetConsumption().Sum(), userInv => userInv.GetConsumption().Sum()) ?
                                           Color.LightPink : row.Cells[4].Style.BackColor;

            row.Cells[5].Value           = userInvoice.GetBasicFee().ToString(priceFormat);
            row.Cells[5].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(
                inv => (inv.GetBasicFee().GetTotalPrice().VATLess),
                userInv => (userInv.GetBasicFee().GetTotalPrice().VATLess)) ?
                                           Color.LightPink : row.Cells[5].Style.BackColor;

            row.Cells[6].Value           = userInvoice.GetUsageFee().ToString(priceFormat);
            row.Cells[6].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(
                inv => (inv.GetUsageFee().GetTotalPrice().VATLess),
                userInv => (userInv.GetUsageFee().GetTotalPrice().VATLess)) ?
                                           Color.LightPink : row.Cells[6].Style.BackColor;

            row.Cells[7].Value = invoice.Balanced;

            row.Cells[8].Value           = userInvoice.GetTotalPrice().ToString(Price.ShowFormat.both);
            row.Cells[8].Style.BackColor = invoice.IsSumOfUserInvoicesDifferent(
                inv => (inv.GetTotalPrice().VATLess + inv.GetTotalPrice().WithVAT),
                userInv => (userInv.GetTotalPrice().VATLess + userInv.GetTotalPrice().WithVAT)) ?
                                           Color.LightPink : row.Cells[8].Style.BackColor;

            row.Tag = userInvoice;
        }
Ejemplo n.º 5
0
        private static void ShowCommonInvoice(DataGridViewRow row, InvoiceShared invoice, Price.ShowFormat priceFormat)
        {
            Contract.Requires(row != null);
            Contract.Requires(invoice != null);

            row.DefaultCellStyle.BackColor = Color.LightCyan;

            row.Cells[0].Value = invoice.Id;
            row.Cells[0].Tag   = invoice.Id;
            row.Cells[1].Value = invoice.PeriodToString();
            row.Cells[2].Value = "Yhteinen";
            row.Cells[3].Value = invoice.GetReadOut().ToString();
            row.Cells[4].Value = invoice.GetConsumption().ToString();
            row.Cells[5].Value = invoice.GetBasicFee().ToString(priceFormat);
            row.Cells[6].Value = invoice.GetUsageFee().ToString(priceFormat);
            row.Cells[7].Value = invoice.Balanced;
            row.Cells[8].Value = invoice.GetTotalPrice().ToString(Price.ShowFormat.both);

            row.Tag = invoice.CommonInvoice;
        }
Ejemplo n.º 6
0
 public string ToString(Price.ShowFormat fmt)
 {
     return(String.Format(new NumberFormatInfo(),
                          $"{GetCleanWaterPrice().ToString(fmt)} / {GetWasteWaterPrice().ToString(fmt)} / {GetTotalPrice().ToString(fmt)}"));
 }