Пример #1
0
        private void LayawayPaymentHistory_Load(object sender, EventArgs e)
        {
            lblTotalLayaway.Text = (Layaway.Amount + Layaway.SalesTaxAmount).ToString("c");

            try
            {
                _builder = new LayawayPaymentHistoryBuilder(Layaway);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error building the payment schedule");
                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "LayawayPaymentHistory_Load errored:  " + exc.Message);
                return;
            }

            lblAmountOutstanding.Text = _builder.GetBalanceOwed().ToString("c");
            lblPaidToDate.Text        = _builder.GetTotalPaid().ToString("c");

            gvPayments.AutoGenerateColumns = false;

            foreach (LayawayHistory history in _builder.ScheduledPayments)
            {
                if (history.Payments.Count == 0)
                {
                    int             idx = gvPayments.Rows.Add();
                    DataGridViewRow row = gvPayments.Rows[idx];
                    row.Cells[this.colPaymentDueDate.Index].Value   = history.PaymentDueDate.ToString("d");
                    row.Cells[this.colPaymentAmountDue.Index].Value = history.PaymentAmountDue.ToString("c");
                }
                else
                {
                    for (int i = 0; i < history.Payments.Count; i++)
                    {
                        LayawayHistoryPaymentInfo paymentInfo = history.Payments.OrderBy(p => p.PaymentMadeOn).ToArray()[i];

                        int             idx = gvPayments.Rows.Add();
                        DataGridViewRow row = gvPayments.Rows[idx];
                        if (i == 0)
                        {
                            row.Cells[this.colPaymentDueDate.Index].Value   = history.PaymentDueDate.ToString("d");
                            row.Cells[this.colPaymentAmountDue.Index].Value = history.PaymentAmountDue.ToString("c");
                        }
                        row.Cells[this.colPaymentMadeOn.Index].Value     = paymentInfo.PaymentMadeOn.ToString("d");
                        row.Cells[this.colPaymentAmountMade.Index].Value = paymentInfo.PaymentAmountMade.ToString("c");
                        row.Cells[this.colBalanceDue.Index].Value        = paymentInfo.BalanceDue.ToString("c");
                        row.Cells[this.colReceiptNumber.Index].Value     = paymentInfo.ReceiptNumber;
                        row.Cells[this.colStatus.Index].Value            = paymentInfo.Status;
                        row.Tag = paymentInfo;
                    }
                }
            }
        }
        private LayawayReportObject.LayawayHistoryAndScheduleMain GetHistoryAndScheduleReportData(LayawayPaymentHistoryBuilder layawayPaymentHistoryBuilder, LayawayVO layaway)
        {
            var main        = new LayawayReportObject.LayawayHistoryAndScheduleMain();
            var historyList = new List <LayawayReportObject.LayawaySchedule>();

            main.AmountOutstanding = layawayPaymentHistoryBuilder.GetBalanceOwed();
            foreach (var history in layawayPaymentHistoryBuilder.ScheduledPayments)
            {
                var paymentHistory = new LayawayReportObject.LayawaySchedule();
                var detailsList    = new List <LayawayReportObject.LayawayScheduleDetails>();
                var historyDetail  = new LayawayReportObject.LayawayScheduleDetails();
                if (history.Payments.Count == 0)
                {
                    historyDetail.PaymentDateDue   = history.PaymentDueDate;
                    historyDetail.PaymentAmountDue = history.PaymentAmountDue;
                    detailsList.Add(historyDetail);
                }
                else
                {
                    for (int i = 0; i < history.Payments.Count; i++)
                    {
                        if (i > 0)
                        {
                            historyDetail = new LayawayReportObject.LayawayScheduleDetails();
                        }

                        var paymentInfo = history.Payments.OrderBy(p => p.PaymentMadeOn).ToArray()[i];
                        if (i == 0)
                        {
                            historyDetail.PaymentDateDue   = history.PaymentDueDate;
                            historyDetail.PaymentAmountDue = history.PaymentAmountDue;
                        }
                        historyDetail.PaymentMadeOn     = paymentInfo.PaymentMadeOn;
                        historyDetail.PaymentAmountMade = paymentInfo.PaymentAmountMade;
                        historyDetail.BalanceDue        = paymentInfo.BalanceDue;
                        //historyDetail.PaymentType = paymentInfo.PaymentType;
                        historyDetail.ReceiptNumber = paymentInfo.ReceiptNumber;
                        historyDetail.Status        = paymentInfo.Status;
                        detailsList.Add(historyDetail);
                    }
                }
                paymentHistory.LayawayScheduleDetailsList = detailsList;
                historyList.Add(paymentHistory);
            }
            //layawayPaymentHistoryBuilder.
            main.LayawayScheduleList = historyList;
            main.Layaway             = layaway;
            return(main);
        }
Пример #3
0
        private void gvPayments_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex != 2)
            {
                return;
            }

            DataGridViewCell paymentAmountCell = gvPayments[2, e.RowIndex];
            LayawayVO        layaway           = gvPayments.Rows[e.RowIndex].Tag as LayawayVO;
            decimal          currentValue      = Utilities.GetDecimalValue(paymentAmountCell.EditedFormattedValue, -1);

            if (currentValue <= 0)
            {
                MessageBox.Show("Invalid payment amount.");
                gvPayments.CancelEdit();
                return;
            }

            LayawayPaymentHistoryBuilder builder;

            try
            {
                builder = new LayawayPaymentHistoryBuilder(layaway);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error building the payment schedule");
                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "gvPayments_CellLeave errored:  " + exc.Message);
                return;
            }

            if (currentValue > builder.GetBalanceOwed())
            {
                MessageBox.Show("Payment Cannot Exceed Total Owed");
                gvPayments.CancelEdit();
                return;
            }

            gvPayments.CommitEdit(DataGridViewDataErrorContexts.Commit);
        }