Exemplo n.º 1
0
        /// <summary>
        /// Lists all transactions in the application data store
        /// according to the filter set by the ModeSelect drop down listbox
        /// </summary>
        private void ListTransactions()
        {
            //
            //	remove previous transactions from list
            //
            TransList.Rows.Clear();

            //
            //	Create the header row of the table
            //
            TableRow trow = new TableRow();

            trow.BackColor = System.Drawing.Color.LightSteelBlue;
            trow.Font.Bold = true;
            TableCell tcell = new TableCell();

            tcell.Text = "Select an expense";
            trow.Cells.Add(tcell);
            tcell      = new TableCell();
            tcell.Text = "Status";
            trow.Cells.Add(tcell);
            TransList.Rows.Add(trow);

            //
            //	Get the number of transactions in the
            //	application data store
            //
            int numTrans = ExpenseCommon.GetNextTransaction();

            //
            //	Check for a valid number of transactions
            //
            if (numTrans > 0)
            {
                //
                //	Check the transaction status filter
                //
                if (mode.Text == "ALL")
                {
                    //
                    // Show all transactions
                    //
                    for (int i = 1; i <= numTrans; i++)
                    {
                        //
                        //	Create a new transaction entry
                        //
                        TableRow  row  = new TableRow();
                        TableCell cell = new TableCell();

                        //
                        //	Display a link to the transaction data
                        //
                        cell.Text = string.Concat("<a href='display.aspx?transactionId=",
                                                  i.ToString(), "'>Expense ", i.ToString());
                        row.Cells.Add(cell);
                        cell = new TableCell();

                        //
                        //	Display the transaction status
                        //
                        cell.Text = string.Concat(ExpenseCommon.GetTransactionStatus(i), " ", ExpenseCommon.GetTransactionDecisionTime(i));
                        row.Cells.Add(cell);
                        TransList.Rows.Add(row);
                    }
                }
                else
                {
                    //
                    //	Only show transactions that match the status filter
                    //
                    for (int i = 1; i <= numTrans; i++)
                    {
                        //
                        //	only show transactions of the specified type
                        //	(ie approved, denied, pending)
                        if (string.Concat(ExpenseCommon.GetTransactionStatus(i), "") == mode.Text)
                        {
                            //
                            //	Create a new transaction entry
                            //
                            TableRow  row  = new TableRow();
                            TableCell cell = new TableCell();

                            //
                            //	Display a link to the transaction data
                            //
                            cell.Text = string.Concat("<a href='display.aspx?transactionId=",
                                                      i.ToString(), "'>Expense ", i.ToString());
                            row.Cells.Add(cell);
                            cell = new TableCell();

                            //
                            //	Display the transaction status
                            //
                            cell.Text = string.Concat(ExpenseCommon.GetTransactionStatus(i), " ", ExpenseCommon.GetTransactionDecisionTime(i));
                            row.Cells.Add(cell);
                            TransList.Rows.Add(row);
                        }
                    }
                }
            }
        }