private void ItemColumnChoose(string filter) { using (ChooseEditItem dialog = new ChooseEditItem(true, filter)) { if (dialog.Run() != ResponseType.Ok) { EditGridCell(grid.EditedCell.Row, 0); return; } for (int i = selectedDetails.Count - 1; i >= 0; i--) { if (selectedDetails [i].ItemId == -1) { selectedDetails.RemoveAt(i); } } foreach (Item item in dialog.SelectedItems) { OperationDetail saleDetail; if (grid.EditedCell.Row >= selectedDetails.Count) { saleDetail = new SaleDetail(); selectedDetails.Add((SaleDetail)saleDetail); } else { saleDetail = selectedDetails [grid.EditedCell.Row]; } saleDetail.ItemEvaluate(item, PriceGroup.RegularPrice); } } EditGridCell(grid.EditedCell.Row, 1); }
protected void ChooseItem_Clicked(object o, EventArgs args) { using (ChooseEditItem dialog = new ChooseEditItem(true, Item != null && Item.Name == txtItem.Text ? string.Empty : txtItem.Text)) { if (dialog.Run() != ResponseType.Ok || dialog.SelectedItems.Length <= 0) { return; } Item = dialog.SelectedItems [0]; txtItem.Text = Item.Name; sbAmount.GrabFocus(); } }
private void ProdItemChoose(string filter) { int row; bool itemAdded; using (ChooseEditItem dialog = new ChooseEditItem(true, filter)) { row = grdProducts.EditedCell.Row; if (dialog.Run() != ResponseType.Ok) { ProdEditGridField(row, colSecondItem.Index); return; } itemAdded = false; foreach (Item item in dialog.SelectedItems) { if (recipe.DetailsProd.Count <= row) { recipe.AddNewAdditionalDetail(); } if (ProdItemEvaluate(row, item, true)) { row++; itemAdded = true; } else { recipe.RemoveDetail(recipe.Details.Count - 1, false); } } } if (itemAdded) { ProdItemEditNext(grdProducts.EditedCell.Row, Gdk.Key.Return); } else { ProdEditGridField(row, colSecondItem.Index); } }
private void ItemColumnChoose(string filter) { if (!grid.EditedCell.IsValid) { return; } int row = itemShortcuts.Count - grid.EditedCell.Row; using (ChooseEditItem dialog = new ChooseEditItem(true, filter)) { if (dialog.Run() == ResponseType.Ok) { for (int i = itemShortcuts.Count - 1; i >= 0; i--) { if (itemShortcuts [i].ItemId == -1) { itemShortcuts.RemoveAt(i); } } List <Item> alreadyAddedItems = new List <Item> (); int currentRow = grid.EditedCell.Row; foreach (Item item in dialog.SelectedItems) { if (IsAlreadyAdded(item)) { alreadyAddedItems.Add(item); continue; } ItemShortcut itemShortcut; if (currentRow >= itemShortcuts.Count) { itemShortcut = new ItemShortcut(); itemShortcuts.Add(itemShortcut); } else { itemShortcut = itemShortcuts [currentRow]; } if (itemShortcut.ItemEvaluate(item, PriceGroup.RegularPrice)) { currentRow++; } } if (alreadyAddedItems.Count == 0) { ItemColumnEditNext(grid.EditedCell.Row, Key.Return); return; } string message; const int maximumItemsToShow = 15; if (alreadyAddedItems.Count > maximumItemsToShow) { message = Translator.GetString("Not all of the selected items can be added. 15 of the items which already have shortcuts are: {0}"); } else { message = Translator.GetString("Not all of the selected items can be added. The items which already have shortcuts are: {0}"); } string itemNames = GetItemNames(alreadyAddedItems, maximumItemsToShow); if (alreadyAddedItems.Count < dialog.SelectedItems.Length) { MessageError.ShowDialog(string.Format(message, itemNames)); return; } if (alreadyAddedItems.Count == dialog.SelectedItems.Length) { message = Translator.GetString("The selected items already have shortcuts!"); MessageError.ShowDialog(message); } } } EditGridCell(itemShortcuts.Count - row, 0); }