public void UpdatePriceNodes() { _optionsTree.Nodes["PricesNode"].Nodes.Clear(); _optionsTree.Nodes["PricesNode"].Nodes.Add(_pricesGeneralNode); foreach (PaperFormat format in _priceManager.PaperFormats) { foreach (PaperType type in _priceManager.PaperTypes) { Product product; if (_config.EnablePhotoOrdering.Value) { product = _priceManager.GetProduct(format.Name + type.Name); if (product == null) { product = _priceManager.AddProduct(format, type, ""); } _optionsTree.Nodes["PricesNode"].Nodes.Add(product.ToString(), format.Name + " " + type.Name); } if (_priceManager.ContainsProduct(format.Name + type.Name + Constants.InstantKey) && _config.EnablePhotoPrinting.Value) { product = _priceManager.GetProduct(format.Name + type.Name + Constants.InstantKey); _optionsTree.Nodes["PricesNode"].Nodes.Add(product.ToString(), format.Name + " " + type.Name + RM.GetString("InstantPostfix")); } } } }
private void UpdatePapers() { _isUpdating = true; _channelsView.Rows.Clear(); foreach (PaperFormat format in PriceManager.PaperFormats) { foreach (PaperType type in PriceManager.PaperTypes) { var key = new KeyValuePair <PaperFormat, PaperType>(format, type); int index = _channelsView.Rows.Add(); if (PriceManager.ContainsProduct(GetProductKey(key))) { _channelsView["ChannelColumn", index].Value = PriceManager.GetProduct(GetProductKey(key)).Channel; } else { _channelsView["ChannelColumn", index].Value = ""; } _channelsView.Rows[index].Tag = key; _channelsView["PaperColumn", index].Value = format.Name + " " + type.Name; } } _isUpdating = false; }
private void _channelsView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!_isUpdating) { var key = (KeyValuePair <PaperFormat, PaperType>)_channelsView.Rows[e.RowIndex].Tag; string newChannel = _channelsView["ChannelColumn", e.RowIndex].Value != null ? _channelsView["ChannelColumn", e.RowIndex].Value.ToString() : string.Empty; _channelsView.Rows[e.RowIndex].ErrorText = ""; if (!string.IsNullOrEmpty(newChannel)) { foreach (DataGridViewRow row in _channelsView.Rows) { if (row.Index != e.RowIndex) { string name = _channelsView["ChannelColumn", row.Index].Value != null ? _channelsView["ChannelColumn", row.Index].Value.ToString() : string.Empty; if (name.Equals(newChannel)) { _channelsView.Rows[e.RowIndex].ErrorText = RM.GetString("ChannelError"); break; } } } } if (PriceManager.ContainsProduct(GetProductKey(key))) { PriceManager.GetProduct(GetProductKey(key)).Channel = newChannel; } } }
private void _printersView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!_isUpdating) { var key = (KeyValuePair <PaperFormat, PaperType>)_printersView.Rows[e.RowIndex].Tag; string newPrinter = (string)_printersView["PrinterColumn", e.RowIndex].Value; if (PriceManager.ContainsProduct(GetProductKey(key))) { if (string.IsNullOrEmpty(newPrinter)) { PriceManager.RemoveProduct(GetProductKey(key)); } else { PriceManager.GetProduct(GetProductKey(key)).Printer = newPrinter; } } else if (!string.IsNullOrEmpty(newPrinter)) { PriceManager.AddProduct(key.Key, key.Value, newPrinter); } if (Parent is MainForm) { (Parent as MainForm).UpdatePriceNodes(); } } }
private void UpdatePapers() { _isUpdating = true; _printersView.Rows.Clear(); try { foreach (PaperFormat format in PriceManager.PaperFormats) { if (!format.IsFree) { foreach (PaperType type in PriceManager.PaperTypes) { var key = new KeyValuePair <PaperFormat, PaperType>(format, type); int index = _printersView.Rows.Add(); if (PriceManager.ContainsProduct(GetProductKey(key))) { var printer = PriceManager.GetProduct(GetProductKey(key)).Printer; if (_availablePrinters.Contains(printer)) { _printersView["PrinterColumn", index].Value = printer; } else { _printersView["PrinterColumn", index].Value = ""; } } else { _printersView["PrinterColumn", index].Value = ""; } _printersView.Rows[index].Tag = key; _printersView["PaperColumn", index].Value = format.Name + " " + type.Name; } } } } catch (Exception) { } _isUpdating = false; }