public override void Run() { Console.Clear(); Console.WriteLine(MenuSystem.Path); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine("Delete by:\n1. ID\n2. Cancel"); Int32.TryParse("" + Console.ReadKey(true).KeyChar, out choice); switch (choice) { case 1: int id = -1; Console.Write("ID: "); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out id); productManager.DeleteItem(x => x.ID == id); break; case 2: return; default: break; } Console.WriteLine(); }
public override void Run() { Console.Clear(); UserDatabase userManager = UserDatabase.GetInstance(); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine(MenuSystem.Path); Console.WriteLine("List of Products:"); productManager.PrintAll(); int id; do { Console.WriteLine("\nEnter the ID of the product to add to the cart:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out id); UserManagement.GetAsCustomer().CartSystem().AddToCart(id); Console.WriteLine("\nWant to add more, press 1 otherwise 0 or any other key:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out choice); } while (choice != 0); Console.WriteLine("Press any key to exit.."); Console.ReadKey(); }
public OrderSheet AddProducts(string referenceCode, IEnumerable <AddOrderProduct> products) { OrderSheet reference = Database.GetOrderSheet(r => r.ReferenceCode == referenceCode);; if (reference == null) { throw new OrderSheetNotFoundException("Comanda não encontrada"); } if (reference.Status == OrderSheetStatus.closed) { throw new OrderSheetInconsistencyException("Não é possível adicionar produtos a uma comanda fechada"); } foreach (var product in products) { var pdRef = ProductDatabase.GetProduct(product.ProductReferenceCode); if (pdRef == null) { throw new ProductNotFoundException($"O produto {product.ProductReferenceCode} não existe"); } reference.Products.Add(new OrderProduct() { ReferenceCode = product.ProductReferenceCode, Quantity = product.Quantity, Name = pdRef.Name, Price = pdRef.Price, DateTime = DateTime.Now }); } return(Database.UpsertOrderSheet(reference)); }
private async void Main_Load(object sender, EventArgs e) { textBox3.Text = File.ReadAllText(Path.Combine(FoldersFilesAndPaths.Logs, Logger.CurrentFile + ".txt")); _writer = new TextBoxStreamWriter(textBox3); Console.SetOut(_writer); LoadSettingsToGui(); metroLabel46.Text = Convert.ToString(await WebUtils.GetCurrentIpAddressAsync()); metroLabel49.Text = Convert.ToString(Settings.PremiumExpiryDate); ProductDatabase.Display(); MyReminder.Display(); LoadChangelogs(); if (Settings.IsPremium) { EnablePremium(); } else { DisablePremium(); } deleteOldLogs(this, null); metroTabControl1.SelectedTab = metroTabPage1; }
private void btnOrder_Click(object sender, EventArgs e) { Double.TryParse(txtPrice.Text.Trim(), out var price); string pickupAddress = boxWhichLocation.Text; bool successInsert = false; bool successUpdate = false; //ensure combo box options are valid, if not display error to user bool success = CheckUserOrder(); //if both combobox options have selected a valid option, then try to insert into orders and update game stock if (success) { var od = new OrderDatabase(); var pd = new ProductDatabase(); successInsert = od.InsertIntoOrders(CustomerID, GameID, Title, price, pickupAddress); successUpdate = pd.UpdateGameStockAfterOrder(GameID, QuantityInStock, QuantitySold, true); } //if database has been updated successfully then let user know and update their viewed data if (successInsert && successUpdate) { UserControls.ShowUserInfo(); MessageBox.Show( $"{txtName.Text} has ordered {Title} for pickup at {boxWhichLocation.Text}. You will get receive an email at {txtEmail.Text} when it's ready for pickup."); Close(); } }
public override void Run() { Console.Clear(); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine(MenuSystem.Path); Console.WriteLine("1. Enter a product\n2. List all products\n3. Delete a product\n4. Search a product\n5. Return to previous menu"); Console.WriteLine("Enter the choice: "); do { Int32.TryParse("" + Console.ReadKey(false).KeyChar, out choice); switch (choice) { case 1: menuSystem.AddScreen(new AddProductMenu()); break; case 2: menuSystem.AddScreen(new ListAllProductMenu()); break; case 3: menuSystem.AddScreen(new DeleteProductMenu()); break; case 4: menuSystem.AddScreen(new SearchProductMenu()); break; case 5: return; default: break; } } while (choice != noOfPaths); }
public override void Run() { Console.Clear(); UserDatabase userManager = UserDatabase.GetInstance(); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine(MenuSystem.Path); Console.WriteLine("1. Add To Cart\n2. Delete From Cart\n3. Return to previous screen"); Console.WriteLine("Enter the choice: "); do { Int32.TryParse("" + Console.ReadKey(false).KeyChar, out choice); switch (choice) { case 1: menuSystem.AddScreen(new AddToCartMenu()); break; case 2: menuSystem.AddScreen(new DeleteFromCartMenu()); break; case 3: return; default: break; } } while (choice != noOfPaths); }
public ProductViewModel() { _context = new ProductDatabase(); Product = new Product(); Products = new ObservableCollection <Product>(_context.GetProducts()); }
private void bttDelete_Click(object sender, EventArgs e) { try { string[] productArr = boxWhichProduct.Text.Split('~'); string gameId = productArr[0].Trim(); string title = productArr[1].Trim(); bool success = false; //if a product has been selected from combo box, try to delete from database var pd = new ProductDatabase(); if (boxWhichProduct.SelectedIndex != 0) { success = pd.DeleteGameInfo(Convert.ToInt32(gameId)); } //if removed successfully from database, then update data and inform admin if (success) { AdminControls.AdminSetup(); MessageBox.Show($"{gameId}: {title} was deleted successfully."); Close(); } else { MessageBox.Show("There was an issue while trying to delete this product."); } } catch { MessageBox.Show("You must choose a product to delete."); } }
//take the current product list and check for clearance items to inform admin notification panel public void CheckForClearance() { string type = "Clearance"; foreach (var p in ProductList) { if (!p.Clearance) //if item has not already been put on clearance { int months = MonthsSinceDate(p.ReleaseDate); //if a game is older then 4 years, has more then 30 left in stock, and has sold less then 80 in that time then put on clearance //if a game is older then 8 years, has less then 25 left in stock, and hasn't sold more then 300 during that time, then put on clearance if (months > 48 && p.QuantityInStock > 30 && p.QuantitySold < 80 || months > 96 && p.QuantityInStock < 25 && p.QuantitySold < 300) { //slash price, make clearance true and add alert message for admin panel double clearancePrice = Math.Round(p.Price / 1.8, 2); string message = $"On Clearance - {p.GameID}: {p.Title} has been put on clearance. Price slashed to {clearancePrice} from {p.Price}."; //func to check if message is new and if so then add it bool success = AddNewNotification(message, type, p.GameID); //if it was added as a new notification successfully, then we will change the price of the product if (success) { var pd = new ProductDatabase(); pd.UpdateGamePrice(p.GameID, clearancePrice, true); } } } } }
//if admin clicks add then get text box information, validate it and add it to the database private void btnAdd_Click(object sender, EventArgs e) { string title = txtTitle.Text; bool validQuantity = Int32.TryParse(txtQuantity.Text, out var quantity); bool validDate = DateTime.TryParse(txtReleaseDate.Text, out var releaseDate); string console = txtConsole.Text; bool validPrice = Double.TryParse(txtPrice.Text, out var price); bool success = false; //validate product input and get any error messages that may be relevant var pv = new ProductValidation(); bool validateInput = pv.ValidationMessages(title, validQuantity, validDate, console, validPrice); //only insert into database if all data has been validated if (validateInput) { var pd = new ProductDatabase(); success = pd.InsertGameInfo(title, quantity, releaseDate, console, price); } //if successfully inserted into the database, then let user know and reload data if (success) { AdminControls.AdminSetup(); //function that fills admin panel with newly updated data MessageBox.Show($"{quantity} of {title} added to the inventory."); Close(); } else if (!success && validateInput) { MessageBox.Show("There was an issue adding this product."); //show user a message if there's an error. } }
//if admin decides to edit, then validate the inputs, update in database and update data seen by admin private void bttEdit_Click(object sender, EventArgs e) { string[] productArr = boxWhichProduct.Text.Split('~'); string gameId = productArr[0].Trim(); string title = txtTitle.Text; bool validQuantity = Int32.TryParse(txtQuantity.Text, out var quantity); bool validDate = DateTime.TryParse(txtReleaseDate.Text, out var releaseDate); string console = txtConsole.Text; bool validPrice = Double.TryParse(txtPrice.Text, out var price); bool success = false; //validate product input and get any error messages that may be relevant var pv = new ProductValidation(); bool validateInput = pv.ValidationMessages(title, validQuantity, validDate, console, validPrice); //if inputs are valid then update the database if (validateInput) { var pd = new ProductDatabase(); success = pd.UpdateGameInfo(gameId, title, quantity, releaseDate, console, price); } //if the database has successfully updated then update admins data if (success) { AdminControls.AdminSetup(); MessageBox.Show($"{gameId} ~ {title} was edited successfully."); Close(); } else if (!success && validateInput) { MessageBox.Show("We are not able to update this product at this time."); } }
public override void Run() { Console.Clear(); UserDatabase userManager = UserDatabase.GetInstance(); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine(MenuSystem.Path); Console.WriteLine("Items in your cart:"); UserManagement.GetAsCustomer().CartSystem().PrintAll(); int sno; do { Console.WriteLine("\nEnter the serial number of the product to delete from the cart:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out sno); if (!UserManagement.GetAsCustomer().CartSystem().IsCartEmpty()) { try { UserManagement.GetAsCustomer().CartSystem().DeleteFromCart(sno); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine("\nWant to delete more or try again, press 1 otherwise 0 or any other key:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out choice); } while (choice != 0); }
public ChangeProductFieldValueCommandHandler(ProductDatabase database, ICategoryFieldService categoryFieldService, IProductFieldHelper productFieldHelper, IFieldValidatorFactory fieldValidatorFactory) { _database = database; _categoryFieldService = categoryFieldService; _productFieldHelper = productFieldHelper; _fieldValidatorFactory = fieldValidatorFactory; }
private void SetupDb() { var connection = Configuration["ConnectionString"]; var master = connection.GetMasterConnection(); var name = connection.GetDatabaseName(); Waiter.WaitDb(master); ProductDatabase.Create(master, name); ProductMigrations.Execute(connection); }
public static ProductDatabase TestDataBase() { ProductDatabase result = new ProductDatabase(); result.AddProduct(ProductFactory.CreateProduct("Компьютер", "Пронин")); result.AddProduct(ProductFactory.CreateProduct("Монитор", "Пелых")); result.AddProduct(ProductFactory.CreateProduct("Принтер", "Пронин")); return(result); }
public ProductsService(ProductDatabase database, ICategoryFieldService categoryFieldService, IProductFieldHelper productFieldHelper, IFieldValidatorFactory fieldValidatorFactory) { _database = database; _categoryFieldService = categoryFieldService; _productFieldHelper = productFieldHelper; _fieldValidatorFactory = fieldValidatorFactory; }
public override void Run() { Console.Clear(); Console.WriteLine(MenuSystem.Path); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine("Search by:\n1. ID\n2. Name\n3. Selling Price greater than entered price\n5. Selling Price less than entered price\n6. Selling Price equal to entered price"); Int32.TryParse("" + Console.ReadKey(true).KeyChar, out choice); switch (choice) { case 1: int id = -1; Console.Write("ID: "); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out id); Console.WriteLine(); var listFound = productManager.SearchItem(x => x.ID == id); //Console.WriteLine(productManager.ToString(ref listFound)); break; case 2: string name = ""; Console.Write("Name: "); name = Console.ReadLine(); listFound = productManager.SearchItem(x => x.Name.ToLower().Equals(name.ToLower()) || x.Name.ToLower().Contains(name.ToLower())); //Console.WriteLine(productManager.ToString(ref listFound)); break; case 3: int price = -1; Console.Write("Price: "); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out price); Console.WriteLine(); listFound = productManager.SearchItem(x => x.SellingPrice > price); //Console.WriteLine(productManager.ToString(ref listFound)); break; case 4: price = -1; Console.Write("Price: "); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out id); Console.WriteLine(); listFound = productManager.SearchItem(x => x.SellingPrice < price); //Console.WriteLine(productManager.ToString(ref listFound)); break; case 5: price = -1; Console.Write("Price: "); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out id); Console.WriteLine(); listFound = productManager.SearchItem(x => x.SellingPrice == price); //Console.WriteLine(productManager.ToString(ref listFound)); break; default: break; } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
private static void SelectOperation(ProductDatabase productDatabase) { Console.WriteLine(Environment.NewLine); Console.WriteLine("Type to select operation:"); Console.WriteLine("(I) - Install"); Console.WriteLine("(U) - Update"); OperationType operationType = productDatabase.GetOperationType(Console.ReadLine()); productDatabase.StartDatabaseOperation(operationType); }
public override void Run() { Console.Clear(); Console.WriteLine(MenuSystem.Path); ProductDatabase productManager = ProductDatabase.GetInstance(); productManager.PrintAll(); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
//--Main ENDE //--Produkt Datenbank START private async void metroButton5_Click(object sender, EventArgs e) { string[] stores = checkedListBox2.CheckedItems.OfType <string>().ToArray(); string asin_isbn = metroTextBox1.Text.Trim(); checkedListBox2.Enabled = metroTextBox1.Enabled = metroButton5.Enabled = false; metroProgressSpinner2.Visible = true; await ProductDatabase.Add(stores, asin_isbn); checkedListBox2.Enabled = metroTextBox1.Enabled = metroButton5.Enabled = true; metroProgressSpinner2.Visible = false; }
private void cm1_aktivieren_Click(object sender, EventArgs e) { Database.OpenConnection(); SQLiteCommand updateEntry = new SQLiteCommand( "UPDATE Products SET Status = '0' WHERE ID = @id", Database.Connection); updateEntry.Parameters.AddWithValue("@id", Convert.ToInt16(metroGrid1.Rows[metroGrid1.CurrentCell.RowIndex].Cells["DG1_ID"].Value)); updateEntry.ExecuteNonQuery(); ProductDatabase.Display(metroComboBox2.SelectedIndex == -1 ? "ALLE" : metroComboBox2.Text); }
//if the order is cancelled by the user then remove the order from the database and update the stock quantities accordingly private void btnCancel_Click(object sender, EventArgs e) { try { string[] boxArr = boxWhichOrder.Text.Split('-'); string[] orderArr = boxArr[0].Split('#'); int orderId = Convert.ToInt32(orderArr[1].Trim()); bool successUpdate = false; bool successDelete = false; //if a valid option has been selected from the combo box if (boxWhichOrder.SelectedIndex != 0) { var od = new OrderDatabase(); var pd = new ProductDatabase(); successDelete = od.DeleteUserOrder(orderId); //remove the users order successUpdate = pd.UpdateGameStockAfterOrder(GameID, QuantityInStock, QuantitySold, false); //add back to stock and remove from sold } else { MessageBox.Show("You must select an order to cancel it."); } //if database operations are successful then let the user know and update their data information viewed if (successUpdate && successDelete) { UserControls.ShowUserInfo(); //refresh inventory also if they are an admin if (AccessLevel == 1) { AdminControls.AdminSetup(); } MessageBox.Show( $"Order #{orderId} has been cancelled for pickup."); Close(); } else { MessageBox.Show("There was an issue while attempting to cancel this order."); } } catch { MessageBox.Show("You must choose a product to be cancelled."); } }
private static void SetConnectionStartDatabaseOperation(ProductDbType dbType, DatabaseProperties databaseProperties, string operation) { var productDatabase = new ProductDatabase(); if (productDatabase.SetConnection(dbType, databaseProperties)) { OperationType operationType = productDatabase.GetOperationType(operation); productDatabase.StartDatabaseOperation(operationType); } else { throw new Exception(Messages.ErrorMessage001); } }
static DataController() { archive = new ProductDatabase(); mainBase = new ProductDatabase(); dataContext = new BackEnd(); possibleStates = new List <string>(); possibleStates.Add("По умолчанию"); possibleStates.Add("Передано"); possibleStates.Add("Получено"); possibleStates.Add("Отправлено в сервис"); windowsCount = 0; // workWnd.Closed += workWnd_Closed; }
public IActionResult Index(string id) { logger.LogInformation("Searching for product {0}", id); var product = ProductDatabase.FindProduct(id); if (product == null) { logger.LogWarning("Product {0} not found", id); return(NotFound()); } logger.LogInformation("Displaying {0}", product.Name); return(View(product)); }
public Shop(Workspace workspace, PaymentProvider paymentProvider, Person customer) { System = workspace.Model.AddSoftwareSystem(Location.Internal, "Shop", "Online shopping system") !; System.Uses(paymentProvider.System, "process customer payments"); customer.Uses(System, "buy stuff"); Customer = customer; var productDatabase = new ProductDatabase(this); var paymentProviderIntegration = new PaymentProviderIntegration(this, paymentProvider, productDatabase); var website = new Website(this, productDatabase, paymentProviderIntegration); Containers = ( productDatabase, paymentProviderIntegration, website); }
public async Task Add(string store, Dictionary <string, string> entryList) { Main mf = Application.OpenForms["Main"] as Main; foreach (var item in entryList.ToList()) { Database.OpenConnection(); SQLiteCommand checkEntry = new SQLiteCommand( "SELECT COUNT(*) FROM Products WHERE Store = @store AND [ASIN / ISBN] = @asin_isbn", Database.Connection); checkEntry.Parameters.AddWithValue("@store", store); checkEntry.Parameters.AddWithValue("@asin_isbn", item.Key); int entryExist = Convert.ToInt32(checkEntry.ExecuteScalar()); if (entryExist > 0) { entryList.Remove(item.Key); } } if (!entryList.Any()) { metroLabel1.Text = @"Alle ausgewählten Produkte bereits in der Datenbank vorhanden."; return; } foreach (var item in entryList) { string asin_isbn = item.Key; string name = item.Value; var shortUrl = await URLShortener.Generate(Amazon.MakeReferralLink(store, asin_isbn), name, store); if (shortUrl == null) { continue; } Database.OpenConnection(); SQLiteCommand insertEntry = new SQLiteCommand( "INSERT INTO Products (Store, [ASIN / ISBN], Name, URL) Values (@store, @asin_isbn, @name, @shorturl)", Database.Connection); insertEntry.Parameters.AddWithValue("@store", store); insertEntry.Parameters.AddWithValue("@asin_isbn", asin_isbn); insertEntry.Parameters.AddWithValue("@name", name); insertEntry.Parameters.AddWithValue("@shorturl", shortUrl); insertEntry.ExecuteNonQuery(); } ProductDatabase.Display(mf.metroComboBox2.SelectedIndex == -1 ? "ALLE" : mf.metroComboBox2.Text); metroLabel1.Text = @"Alle ausgewählten Produkte Erfolgreich Hinzugefügt."; }
public ProductLocations() { try { ProductDatabase pdb = new ProductDatabase(); foreach (ProductInstall install in pdb.Data.ProductInstalls) { if (KnownUIDs.ContainsKey(install.Uid) && Directory.Exists(install.Settings.InstallPath)) { Add(new ProductLocation(KnownUIDs[install.Uid], Path.GetFullPath(install.Settings.InstallPath))); } } } catch { } }
private static void SelectDatabase(ProductDatabase productDatabase) { Console.WriteLine("Type to select database type:"); Console.WriteLine("(O) - Oracle"); Console.WriteLine("(S) - SQL Server"); ProductDbType dbType = productDatabase.GetDatabaseType(Console.ReadLine()); if (productDatabase.SetConnection(dbType)) { SelectOperation(productDatabase); } else { throw new Exception(Messages.ErrorMessage001); } }