/// <summary>
 /// Constructor for form, is passed the database and 2 delegates as fields
 /// </summary>
 /// <param name="model">the transaction database model passed to this form</param>
 /// <param name="mt">the delegate to add a transaction to the model</param>
 /// <param name="ai">the delegate to add an item to a transaction</param>
 public CashierUI(TransactionDatabase model, MakeTransaction mt, AddItem ai)
 {
     InitializeComponent();
     database       = model;
     AddItem        = ai;
     AddTransaction = mt;
 }
Exemple #2
0
 public RebateUI(RebateDatabase rb, RebateController rc, TransactionDatabase tb)
 {
     rd      = rb;
     this.rc = rc;
     this.tb = tb;
     InitializeComponent();
 }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ///models constructed here
            TransactionDatabase tb = new TransactionDatabase();
            RebateDatabase      rb = new RebateDatabase();

            ///Controllers constructed here
            TransactionController mt = new TransactionController();
            ReturnController      rt = new ReturnController();
            RebateController      rc = new RebateController();

            ///views and threads constructed here
            ConsoleUI console = new ConsoleUI(tb, mt.MakeTransaction, mt.AddItem);

            new Thread(ConsoleThreader).Start(console);

            RebateUI RebateForm = new RebateUI(rb, rc, tb);

            new Thread(RebateFormStartFunctionThatStartsTheRebateForm).Start(RebateForm);

            CashierUI CashierForm = new CashierUI(tb, mt.MakeTransaction, mt.AddItem);

            new Thread(CashierFormStartingFunctionThatStartsTheCashierForm).Start(CashierForm);

            /// Declares a Customer Service Form, and passes it to a thread which runs the application
            CustomerServiceUI CSForm = new CustomerServiceUI(tb, rt);

            new Thread(CustomerServiceFormStartingfunctionThatStartsTheCustomerServiceForm).Start(CSForm);

            /// Populate some transactions
            /// side node: CashierUI/Console won't work with these... only rebate/Service desk.

            /*
             * List<Product> p = new List<Product>();
             * p.Add(new Product("Melk", 1.23));
             * p.Add(new Product("Not Melk", 2.69));
             * tb.transactions.Add(1, new BasicTransaction("June", 14, "Customer 1", 1, p));
             *
             * p = new List<Product>();
             * p.Add(new Product("A brand new pony", 1.24));
             * p.Add(new Product("Glue making machine", 6.54));
             * tb.transactions.Add(2, new BasicTransaction("June", 14, "Customer 2", 2, p));
             */
        }
Exemple #4
0
 public string IReturnItem(Transaction returnTransaction, TransactionDatabase TransactionDatabase, int TransactionNumber, string itemName)
 {
     for (int i = 0; i < returnTransaction.products.Count; i++)
     {
         if (returnTransaction.products[i].name.Equals(itemName))
         {
             returnTransaction.products.Remove(returnTransaction.products[i]);
             string s = ListBoxPopulator(returnTransaction);
             TransactionDatabase.transactions.Remove(TransactionNumber);
             if (TransactionDatabase.transactions.Count != 0)
             {
                 TransactionDatabase.transactions.Add(TransactionNumber, returnTransaction);
             }
             MessageBox.Show("Return Successful");
             return(s);
         }
     }
     MessageBox.Show("Return Unsuccessful");
     return("");
 }
 public CustomerServiceUI(TransactionDatabase tb, ReturnController rt)
 {
     TransactionDatabase = tb;
     returnItem          = rt;
     InitializeComponent();
 }
Exemple #6
0
        /// <summary>
        /// the delegate implementation to add a Transaction to the Transaction Database Model
        /// </summary>
        /// <param name="nameOfCustomer">name of customer</param>
        /// <param name="monthOfPurchase">month of transaction</param>
        /// <param name="transnumber">transaction number</param>
        /// <param name="dateOfPurchase">date of transaction</param>
        /// <param name="tb">the model</param>
        /// <param name="items">the products in the transaction</param>
        public void MakeTransaction(string nameOfCustomer, string monthOfPurchase, int transnumber, int dateOfPurchase, TransactionDatabase tb, List <Product> items)
        {
            Transaction t = new BasicTransaction(monthOfPurchase, dateOfPurchase, nameOfCustomer, transnumber, items);

            tb.transactions.Add(transnumber, t);
        }
Exemple #7
0
 public ConsoleUI(TransactionDatabase transactionModel, MakeTransaction mt, AddItem ai)
 {
     TDB            = transactionModel;
     AddItem        = ai;
     AddTransaction = mt;
 }