private void PrepareMenuForCustomerOrdersItem(CustomerOrderFullPOCO item) { Order_OrderNumberLabel.Content = $"Заказ #{item.Id}"; Order_ClientIdLabel.Content = $"Id клиента: {item.Customer.Id}"; Order_JobIdLabel.Content = $"Id работы: {item.Job.Id}"; Order_OrderComplete.IsChecked = item.Completed; Order_OrderComplete.IsEnabled = !item.Completed; Order_OrderDateLabel.Content = item.OrderDate.ToString("g"); Order_OrderDescriptionTextBox.Text = item.OrderDetals; Order_OrderTypeTextBox.Text = item.OrderType; }
private async void Customers_CustomerFullNameTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { var itemEntry = (CustomerPOCO)CustomersDatagrid.SelectedItem; var customerEntry = await DatabaseProvider.Database.GetCustomer(itemEntry.Id); customerEntry.FullName = Customers_CustomerFullNameTextBox.Text; await DatabaseProvider.Database.UpdateCustomer(customerEntry); var entry = AllCustomers.Find(x => x.Id == itemEntry.Id); entry.FullName = Customers_CustomerFullNameTextBox.Text; var customerId = entry.Id; var shortcutName = CustomerOrderFullPOCO.ShortcutCustomerName(entry.FullName); AllOrders.Where(x => x.Customer.Id == customerId).ToList().ForEach(x => x.Customer.FullName = shortcutName); RefreshCustomersDataGrid(); RefreshOrdersDataGrid(); } }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (CustomerComboBox.SelectedItem != null) { var newJob = new JobPOCO { Complete = false, ComponentsUsed = new Dictionary <long, int>(), Description = "" }; await DatabaseProvider.Database.AddJob(newJob); var newCustomerOrder = new CustomerOrderPOCO { LinkedJobId = newJob.Id, CustomerId = MainWindow.AllCustomers.Find(x => $"{x.Id}: {x.FullName}" == (string)CustomerComboBox.SelectedItem).Id, OrderDate = OrderDatePicker.SelectedDate.Value, OrderType = OrderTypeTextBox.Text, OrderDetals = OrderDescriptionTextBox.Text, Completed = false }; await DatabaseProvider.Database.AddCustomerOrder(newCustomerOrder); newJob.Description = $"Относится к заказу #{newCustomerOrder.Id}"; await DatabaseProvider.Database.UpdateJob(newJob); MainWindow.AllJobs.Add(await FullJobPOCO.BuildFullJobDTO(newJob)); MainWindow.AllOrders.Add(await CustomerOrderFullPOCO.BuildCustomerOrderFullDTO(newCustomerOrder)); ((MainWindow)this.Owner).RefreshJobsDataGrid(); ((MainWindow)this.Owner).JobsDataGrid_SelectionChanged(null, null); ((MainWindow)this.Owner).RefreshOrdersDataGrid(); ((MainWindow)this.Owner).CustomerOrdersDatagrid_SelectionChanged(null, null); this.Close(); } }
private async void FillCustomerOrders() { AllOrders = (await Task.WhenAll((await DatabaseProvider.Database.GetAllCustomerOrders()).Select(async x => await CustomerOrderFullPOCO.BuildCustomerOrderFullDTO(x)))).ToList(); var _itemSourceList = new CollectionViewSource() { Source = AllOrders }; ICollectionView orderDatagridItemList = _itemSourceList.View; orderDatagridItemList.Filter = CustomerOrdersDatagridFilter; CustomerOrdersDatagrid.ItemsSource = orderDatagridItemList; }