Exemplo n.º 1
0
        private void LoadCustomer()
        {
            if (customer != null)
            {
                transactions = new List <Trns>();
                String adjUnit = "Unit " + customer.accNumber.Replace(build.Abbr, "");
                txtUnit.Text   = adjUnit;
                txtSeller.Text = customer.description;
                os             = 0;

                DateTime trnDate = dtPicker.Value.AddMonths(-3);
                validDate = dtValid.Value;
                DateTime balDate = trnDate;
                //extract clearance fee from database

                if (customer != null)
                {
                    double             totalDue  = 0;
                    String             trnMsg    = "";
                    List <Transaction> transacts = (new Classes.LoadTrans()).LoadTransactions(build, customer, DateTime.Now, out totalDue, out trnMsg);
                    transactions = new List <Trns>();
                    foreach (Transaction t in transacts)
                    {
                        Trns tr = new Trns();
                        tr.Amount      = t.TrnAmt.ToString();
                        tr.Date        = t.TrnDate.ToString("yyyy/MM/dd");
                        tr.Description = t.Description;
                        tr.Reference   = t.Reference;
                        transactions.Add(tr);
                    }
                    if (id == 0)
                    {
                        clrTrans = new List <ClearanceTransactions>();
                        dgClearance.DataSource = null;
                        ClearanceTransactions clrTrn = new ClearanceTransactions
                        {
                            Description       = String.Format("OUTSTANDING BALANCE AT {0}", dtPicker.Value.ToString("yyyy/MM/dd")),
                            Qty               = 1,
                            Rate              = Math.Round(totalDue, 2),
                            Markup_Percentage = 0
                        };
                        clrTrans.Add(clrTrn);
                        bs.DataSource          = clrTrans;
                        dgClearance.DataSource = bs;
                    }
                }
                dgTransactions.DataSource = null;
                dgTransactions.DataSource = transactions;
            }
        }
Exemplo n.º 2
0
        private List <Trns> LoadBuildingTransactions(int sPeriod, int ePeriod, int fromMonth, string Trust)
        {
            String      wherearewe   = "start";
            List <Trns> transactions = new List <Trns>();

            try
            {
                double      trnBal = 0;
                double      remBal = 0;
                List <Trns> bTrans = LoadTransactions(sPeriod, ePeriod, Trust, out remBal, out trnBal);
                wherearewe = "loaded trans";
                double openingBalance = GetBalance(Trust, fromMonth - 1) + remBal; //- selectedBuilding.Period
                wherearewe = "loaded balance";
                Trns openingTrns = new Trns
                {
                    Amount      = openingBalance.ToString("#0.00"),
                    Date        = dtFrom.Value.AddDays(-1).ToString("yyyy/MM/dd"),
                    Description = "Opening Balance",
                    Reference   = ""
                };
                wherearewe = "openingtrans";
                transactions.Add(openingTrns);
                transactions.AddRange(bTrans);
                wherearewe = "buildtrans";
                Trns closingTrns = new Trns
                {
                    Amount      = (openingBalance + trnBal).ToString("#0.00"),
                    Date        = dtTo.Value.ToString("yyyy/MM/dd"),
                    Description = "Closing Balance",
                    Reference   = ""
                };
                wherearewe = "closingtrans";
                transactions.Add(closingTrns);
            }
            catch (Exception ex)
            {
                MessageBox.Show(wherearewe + " - " + ex.Message);
            }
            return(transactions);
        }
Exemplo n.º 3
0
        private void dgBuildings_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                try
                {
                    String bCode  = dgBuildings.Rows[e.RowIndex].Cells[0].Value.ToString();
                    int    column = e.ColumnIndex;
                    Dictionary <String, List <Trns> > transactions = new Dictionary <string, List <Trns> >();

                    switch (column)
                    {
                    case 2:
                        List <Trns>     customerTrns             = new List <Trns>();
                        List <Customer> tempCustomers            = customers[bCode];
                        Dictionary <String, List <Trns> > cTrans = new Dictionary <string, List <Trns> >();
                        foreach (Customer customer in tempCustomers)
                        {
                            Trns t = new Trns();
                            t.Amount      = customer.ageing[0].ToString("#,##0.00");
                            t.Date        = DateTime.Now.ToString("yyyy/MM/dd");
                            t.Description = customer.description;
                            t.Reference   = customer.accNumber;
                            customerTrns.Add(t);
                        }
                        cTrans.Add(bCode, customerTrns);
                        transactions = cTrans;
                        break;

                    case 3:
                    case 4:
                        transactions = transactions1;
                        break;

                    case 5:
                    case 6:
                        transactions = transactions0;
                        break;

                    case 7:
                    case 8:
                        transactions = transactions2;
                        break;

                    case 9:
                    case 10:
                        transactions = transactions3;
                        break;

                    default:
                        transactions = null;
                        break;
                    }
                    if (transactions != null)
                    {
                        Forms.frmBuildingTrans fTrans = new Forms.frmBuildingTrans(dgBuildings.Rows[e.RowIndex].Cells[1].Value.ToString(), transactions[bCode]);
                        fTrans.ShowDialog();
                    }
                }
                catch { }
            }
        }