Ejemplo n.º 1
0
        public override void Run()
        {
            SalesReceiptForm     receiptForm = new SalesReceiptForm();
            SalesReceiptItemForm itemForm    = new SalesReceiptItemForm();

            ISalesReceiptRepository  receiptDao  = new NHibernateSalesReceiptRepository();
            IVehicleTripRepository   tripDao     = new NHibernateVehicleTripRepository();
            IAccountRepository       accountDao  = new NHibernateAccountRepository();
            ICustomerRepository      customerDao = new NHibernateCustomerRepository();
            IPaymentMethodRepository methodDao   = new NHibernatePaymentMethodRepository();
            IItemRepository          itemDao     = new NHibernateItemRepository();

            receiptForm.VehicleTripsList   += delegate { receiptForm.VehicleTrips = tripDao.FindAll(); };
            receiptForm.ListAccounts       += delegate { receiptForm.Accounts = accountDao.FindIncomeAccounts(); };
            receiptForm.PaymentMethodsList += delegate { receiptForm.PaymentMethods = methodDao.FindActive(); };
            receiptForm.CustomersList      += delegate { receiptForm.Customers = customerDao.FindActive(); };
            itemForm.ItemFind += delegate(object sender, ItemEventArgs e) {
                IList <Item> items = itemDao.FindByName(e.Item.Name);
                if (items.Count == 1)
                {
                    itemForm.ReceiptItem.Item = items[0];
                }
                else
                {
                }
            };
            receiptForm.ItemAdding += delegate(object sender, SalesReceiptItemEventArgs e) {
                itemForm.ReceiptItem = e.ReceiptItem;
                if (WorkbenchSingleton.AddDialog(itemForm) == DialogResult.OK)
                {
                    receiptForm.SalesReceipt.AddItem(itemForm.ReceiptItem);
                }
            };
            receiptForm.SalesReceiptSaveAndClose += delegate(object sender, SalesReceiptEventArgs e) {
                receiptDao.SaveOrUpdate(e.SalesReceipt);
                receiptForm.Close();
            };
            WorkbenchSingleton.AddChild(receiptForm);
        }
Ejemplo n.º 2
0
        public override void Run()
        {
            InvoiceForm     invoiceForm = new InvoiceForm();
            InvoiceItemForm itemForm    = new InvoiceItemForm();

            IInvoiceRepository     invoiceDao  = new NHibernateInvoiceRepository();
            IVehicleTripRepository tripDao     = new NHibernateVehicleTripRepository();
            ICustomerRepository    customerDao = new NHibernateCustomerRepository();
            IItemRepository        itemDao     = new NHibernateItemRepository();
            IAccountRepository     accountDao  = new NHibernateAccountRepository();

            invoiceForm.VehicleTripsList += delegate { invoiceForm.VehicleTrips = tripDao.FindAll(); };
            invoiceForm.AccountsList     += delegate { invoiceForm.Accounts = accountDao.FindAccountsReceivables(); };
            invoiceForm.CustomersList    += delegate { invoiceForm.Customers = customerDao.FindActive(); };
            itemForm.ItemFind            += delegate(object sender, ItemEventArgs e) {
                IList <Item> items = itemDao.FindByName(e.Item.Name);
                if (items.Count == 1)
                {
                    itemForm.InvoiceItem.Item = items[0];
                }
                else
                {
                    // TODO: Add item list of value!
                }
            };
            invoiceForm.ItemAdding += delegate(object sender, InvoiceItemEventArgs e) {
                itemForm.InvoiceItem = e.InvoiceItem;
                if (WorkbenchSingleton.AddDialog(itemForm) == DialogResult.OK)
                {
                    invoiceForm.Invoice.AddItem(itemForm.InvoiceItem);
                }
            };
            invoiceForm.InvoiceSaveAndClose += delegate(object sender, InvoiceEventArgs e) {
                invoiceDao.SaveOrUpdate(e.Invoice);
                invoiceForm.Close();
            };
            WorkbenchSingleton.AddChild(invoiceForm);
        }