예제 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var    reports = new Reports.Reports();
            string file    = Reports.Reports.Sundries(dpSundry.Value);

            System.Diagnostics.Process.Start(file);
        }
예제 #2
0
        void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            var    month   = (DateTime)e.Argument;
            var    reports = new Reports.Reports();
            string pdfPath = reports.MonthAudit(month);

            Process.Start(pdfPath);
        }
예제 #3
0
        private void owingByCollectorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var reports = new Reports.Reports();
                var file    = reports.OwingByCollector();

                Process.Start(file);
            }
            catch (Exception exception)
            {
                Functions.ShowError(exception);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            int weeks;

            try
            {
                weeks = int.Parse(txtWeeks.Text);
            }
            catch (Exception)
            {
                return;
            }

            var    reports = new Reports.Reports();
            string file    = reports.NotPaid(weeks);

            System.Diagnostics.Process.Start(file);
        }
예제 #5
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgPayments.Rows)
            {
                var paymentCell = row.Cells["Payment"];
                if (paymentCell.Style.BackColor == Color.Red)
                {
                    MessageBox.Show("Fix invalid Payment data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            //Validate Amount Taken
            epAmountProvided.Clear();
            if (String.IsNullOrEmpty(txtAmountCollected.Text))
            {
                epAmountProvided.SetError(txtAmountCollected, "Enter a value");
                return;
            }
            if (!Functions.IsPosDbl(txtAmountCollected.Text))
            {
                epAmountProvided.SetError(txtAmountCollected, "Enter a positive numeric value");
                return;
            }

            //Validate Payments
            bool isValid = true;

            foreach (DataGridViewRow r in dgPayments.Rows)
            {
                DataGridViewCell paymentCell = r.Cells["Payment"];
                if (!paymentCell.ReadOnly)
                {
                    bool cellOk = true;
                    if (paymentCell.Value.ToString() == "")
                    {
                        paymentCell.Value = "0";
                    }
                    if (!Functions.IsDbl(paymentCell.Value.ToString()))
                    {
                        cellOk = false;
                    }
                    else
                    {
                        double val = Convert.ToDouble(paymentCell.Value);
                        if (val < 0)
                        {
                            cellOk = false;
                        }
                    }
                    if (!cellOk)
                    {
                        isValid = false;
                        paymentCell.Style.BackColor = Color.LightPink;
                        continue;
                    }

                    //Is this account being overpaid?
                    var payment     = float.Parse(paymentCell.Value.ToString());
                    var outstanding = float.Parse(r.Cells["Outstanding"].Value.ToString());
                    if ((outstanding < payment) && payment > 0)
                    {
                        isValid = false;
                        paymentCell.Style.BackColor = Color.LightPink;
                    }
                    else
                    {
                        paymentCell.Style.BackColor = Color.Khaki;
                    }
                }
            }
            if (!isValid)
            {
                MessageBox.Show("Check entered values", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            foreach (DataGridViewRow r in dgPayments.Rows)
            {
                DataGridViewCell paymentCell = r.Cells["Payment"];
                if (!paymentCell.ReadOnly)
                {
                    int   accountID = int.Parse(r.Cells[0].Value.ToString());
                    float payment   = float.Parse(paymentCell.Value.ToString());
                    if (payment > 0)
                    {
                        Account a = _db.Accounts.Find(accountID);
                        var     p = new Payment
                        {
                            Amount    = payment,
                            IsSundry  = false,
                            Note      = "",
                            Timestamp = dtCollection.Value
                        };
                        a.Payments.Add(p);
                        _db.SaveChanges();
                    }
                }
            }
            ShowPayments();

            //Print Report
            var collectorID = ((Collector)(cmbCollector.SelectedValue)).Id;
            var reports     = new Reports.Reports();
            var file        = reports.PaymentsTaken(collectorID, dtCollection.Value, Convert.ToDouble(txtAmountCollected.Text));

            Process.Start(file);

            Cursor.Current = Cursors.Default;
        }