private void GenerateReport() { System.Windows.Forms.Cursor cursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { using (RepositoryFactory factory = new RepositoryFactory()) { using (IProductionQueryRepository repository = factory.CreateProductionQueryRepository()) { ProductionQuery query = new ProductionQuery().AddDateRange(dtPeriodStart.Value, dtPeriodEnd.Value); if (!string.IsNullOrEmpty(txtProduct.Text)) query = query.AddProduct(new ProductNumber(txtProduct.Text)); if (!string.IsNullOrEmpty(txtOrder.Text)) query = query.AddOrder(new OrderNumber(txtOrder.Text)); if (cbMachine.SelectedItem != null) query = query.AddMachine(cbMachine.SelectedItem.ToString()); if (cbTeam.SelectedItem != null) query = query.AddTeam((ProductionTeam) cbTeam.SelectedItem); ShowResults(query, repository.LoadProductions(query)); } } } finally { Cursor.Current = cursor; } }
private Production LoadProduction(string orderNumber) { using (RepositoryFactory factory = new RepositoryFactory()) { using (IProductionQueryRepository repository = factory.CreateProductionQueryRepository()) { return repository.LoadProduction(new OrderNumber(orderNumber)); } } }
private void Update() { graphItems = new List<GraphItem>(); using (RepositoryFactory factory = new RepositoryFactory()) { using (IProductionQueryRepository repository = factory.CreateProductionQueryRepository()) { ProductionQuery query = GenerateQuery(); foreach (var production in repository.LoadProductions(query)) { foreach (var shift in production.Shifts) { graphItems.Add(new GraphItem(production.Machine, shift.ProductionStart, shift.Team, shift.ProductionStopRegistrations)); } } } } UpdateGraph(); UpdateStatusBox(); }