public static void AmountOnClick(string number, int selectedIndex) { if (selectedIndex == -1) { return; } if (number.Length == 0) { (ItemsPositions[selectedIndex] as CheckLine).Amount++; } else { double amount = double.Parse(number, CultureInfo.InvariantCulture); string units = (ItemsPositions[selectedIndex] as CheckLine).Data.Units; if (amount <= 0) { ItemsPositions.RemoveAt(selectedIndex); } else if ((ItemsPositions[selectedIndex] as CheckLine).Amount < amount) { (ItemsPositions[selectedIndex] as CheckLine).Amount = units == "шт." ? Math.Round(amount, mode: MidpointRounding.AwayFromZero) : amount; } else if (MessageBox.Show(LanguageEngine.Language["FastInvoiceActivity Decreasing"], LanguageEngine.Language["FastInvoiceActivity DecreasingTitle"], MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) { (ItemsPositions[selectedIndex] as CheckLine).Amount = units == "шт." ? Math.Round(amount, mode: MidpointRounding.AwayFromZero) : amount; } } }
public static void DeleteFromDB(int selectedIndex) { if (ItemsPositions.Count == 0) { MessageBox.Show(LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingError"], LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingErrorTitle"], MessageBoxButton.OK, MessageBoxImage.Error); } else if (selectedIndex == -1) { if (MessageBox.Show(LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingPositions"], LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingPositionsTitle"], MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { foreach (DBProductData position in ItemsPositions) { if (position.IsInDB) { WareHouseDBController.Remove(position.Data.EAN13); } } ItemsPositions.Clear(); } } else { if ((ItemsPositions[selectedIndex] as DBProductData).IsInDB) { if (MessageBox.Show(LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingPosition"], LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingPositionTitle"], MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { var code = (ItemsPositions[selectedIndex] as DBProductData).Data.EAN13; WareHouseDBController.Remove(code); ItemsPositions.RemoveAt(selectedIndex); } } else { MessageBox.Show(LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingNotInDB"], LanguageEngine.Language["WareHouseActivity DeleteFromDB DeletingNotInDBTitle"], MessageBoxButton.OK, MessageBoxImage.Information); } } }
public static void DeleteUserFromDB(int selectedIndex) { if (ItemsPositions.Count == 0) { MessageBox.Show(LanguageEngine.Language["UserControlServiceActivity NothingToRemove"], LanguageEngine.Language["UserControlServiceActivity NothingToRemoveTitle"], MessageBoxButton.OK, MessageBoxImage.Error); } else if (ItemsPositions.Select(x => (x as User).Id).Contains(CurrentUser.Id)) { MessageBox.Show(LanguageEngine.Language["UserControlServiceActivity SelfRemoveDisallowed"], LanguageEngine.Language["UserControlServiceActivity SelfRemoveDisallowedTitle"], MessageBoxButton.OK, MessageBoxImage.Error); } else if (selectedIndex == -1) { if (MessageBox.Show(LanguageEngine.Language["UserControlServiceActivity DeletingAll"], LanguageEngine.Language["UserControlServiceActivity DeletingAllTitle"], MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { foreach (User user in ItemsPositions) { UserDBController.Remove(user.Id); } ItemsPositions.Clear(); } } else { if (MessageBox.Show(LanguageEngine.Language["UserControlServiceActivity ConfirmUserRemoving"], LanguageEngine.Language["UserControlServiceActivity ConfirmUserRemovingTitle"], MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { var id = (ItemsPositions[selectedIndex] as User).Id; UserDBController.Remove(id); ItemsPositions.RemoveAt(selectedIndex); } } }