public override void Run() { PaymentForm form = new PaymentForm(); IPaymentRepository paymentDao = new NHibernatePaymentRepository(); ICustomerRepository customerDao = new NHibernateCustomerRepository(); IPaymentMethodRepository methodDao = new NHibernatePaymentMethodRepository(); form.CustomersList += delegate { form.Customers = customerDao.FindActive(); }; form.PaymentMethodsList += delegate { form.PaymentMethods = methodDao.FindActive(); }; form.PaymentSaveAndClose += delegate(object sender, PaymentEventArgs e) { paymentDao.SaveOrUpdate(e.Payment); form.Close(); }; WorkbenchSingleton.AddChild(form); }
public override void Run() { SalesReceiptForm form = new SalesReceiptForm(); ISalesReceiptRepository receiptDao = new NHibernateSalesReceiptRepository(); IVehicleTripRepository tripDao = new NHibernateVehicleTripRepository(); ICustomerRepository customerDao = new NHibernateCustomerRepository(); IPaymentMethodRepository methodDao = new NHibernatePaymentMethodRepository(); form.VehicleTripsList += delegate { form.VehicleTrips = tripDao.FindAll(); }; form.PaymentMethodsList += delegate { form.PaymentMethods = methodDao.FindActive(); }; form.CustomersList += delegate { form.Customers = customerDao.FindActive(); }; form.SalesReceiptSaveAndClose += delegate(object sender, SalesReceiptEventArgs e) { receiptDao.SaveOrUpdate(e.SalesReceipt); form.Close(); }; WorkbenchSingleton.AddChild(form); }
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); }