protected void setUpValues() { this._temp = Settings.Config.getTempOrder(); Dictionary<int, string> dict = Settings.Config.getProducts().Where(x => x.id > 0).ToDictionary(x => x.id, x => x.name + " (" + x.code + ")"); this.products.ItemsSource = dict.OrderBy(x => x.Value); this.products.DisplayMemberPath = "Value"; this.products.SelectedValuePath = "Key"; this.products.SelectedIndex = 0; CollectionViewSource itemCollectionViewSource; itemCollectionViewSource = (CollectionViewSource)(FindResource("ItemCollectionViewSource")); itemCollectionViewSource.Source = this._temp.products; this.AddedItem += onAddItem; }
protected void setUpValues() { this._temp = Settings.Config.getOrders().FirstOrDefault(x => x.id == this.cislo); Dictionary<int, string> dict = Settings.Config.getOrderItems().Where(x => x.orderId == this.cislo ).ToDictionary(x => x.id, x => x.id + " (" + x.name + ")"); if (dict.Count == 0) { Settings.Config.getOrders().RemoveAll(x => x.id == this.cislo); Settings.Config.saveOrders(); onCanceled(new EventArgs()); } this.tovar.ItemsSource = dict.OrderBy(x => x.Value); this.tovar.DisplayMemberPath = "Value"; this.tovar.SelectedValuePath = "Key"; this.tovar.SelectedIndex = 0; }
private void submit_Click(object sender, RoutedEventArgs e) { this._temp.id = Settings.Config.getOrders().LastOrDefault(x => x.id > 0) == null ? 1 : Settings.Config.getOrders().LastOrDefault(x => x.id > 0).id + 1; this._temp.numberInYear = Settings.Config.getOrders().LastOrDefault(x => x.id > 0 && x.year == DateTime.Today.Year) == null ? 1 : Settings.Config.getOrders().LastOrDefault(x => x.id > 0 && x.year == DateTime.Today.Year).numberInYear + 1; this._temp.variableSymbol = RandomString(8); int lastOrderItemId = Settings.Config.getOrderItems().LastOrDefault(x => x.id > 0) == null ? 1 : Settings.Config.getOrderItems().LastOrDefault(x => x.id > 0).id; foreach (var p in this._temp.products) { p.orderId = this._temp.id; p.id = lastOrderItemId++; } Settings.Config.getOrders().Add(this._temp); this._temp = null; Settings.Config.saveOrders(); onCanceled(new EventArgs()); }
public static void setTempOrder(Interface.IOrder tempOrder) { _order = tempOrder; }