//////////////////////////////////////////////////////events for components/////////////////////////////////////////////////////////////////// private void treeViewAdminNav_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode treeNode = treeViewAdminNav.SelectedNode; if (treeNode.Name.Equals("nodeProduct") && !(this.Name.Equals("ProductViewForm"))) { ProductViewForm viewProductPage = new ProductViewForm(); this.Hide(); viewProductPage.ShowDialog(); this.Close(); //close previous form } else if (treeNode.Name.Equals("nodeUser") && !(this.Name.Equals("UserViewForm"))) { UserViewForm viewUserPage = new UserViewForm(); this.Hide(); viewUserPage.ShowDialog(); this.Close(); //close previous form } else if (treeNode.Name.Equals("nodeStock") && !(this.Name.Equals("StockViewForm"))) { StockViewForm viewStockPage = new StockViewForm(); this.Hide(); viewStockPage.ShowDialog(); this.Close(); //close previous form } }
private void lblProductTable_Click(object sender, EventArgs e) { ProductViewForm productViewPage = new ProductViewForm(); this.Hide(); productViewPage.ShowDialog(); this.Close(); //close previous form }
private void btnAdd_Click(object sender, EventArgs e) { string itemName = txtItemName.Text; decimal price = 0; string category = "Food"; string type = cboCategory.Text; int ingredients = (cboIngredient.SelectedItem as ComboboxItem).value; string description = txtDescription.Text; if (rdoFood.Checked) { category = "Food"; } else if (rdoBeverage.Checked) { category = "Beverage"; } decimal value = 0; //checks if entered value can be decimal or not if (decimal.TryParse(txtPrice.Text, out value)) { txtPrice.Text = String.Format("{0:0.00}", value); //setting price amount price = Math.Round(value, 2); } if ((itemName != "") && (price != 0) && (category != "") && (type != "") && (ingredients != 0) && (itemImagePath != "")) { try { string RunningPath = AppDomain.CurrentDomain.BaseDirectory; picItem.BackgroundImage.Save(Path.GetFullPath(Path.Combine(RunningPath, @"..\..\Resource\Images\MenuItems\")) + itemImagePath, ImageFormat.Png); } catch (Exception ex) { MessageBox.Show(ex.Message); } db.Sqlite_cmd = db.SqlConn.CreateCommand();//ask database what to query db.Sqlite_cmd.CommandText = "INSERT INTO item (name, price, description, image, category, type) " + "VALUES('" + itemName + "', '" + price + "', '" + description + "', '" + itemImagePath + "', '" + category + "', '" + type + "')"; db.Sqlite_datareader = db.Sqlite_cmd.ExecuteReader();//reads the database db.Sqlite_cmd.Dispose(); db.CloseDBConnection(); ProductViewForm viewProductPage = new ProductViewForm(); this.Hide(); viewProductPage.ShowDialog(); this.Close(); //close previous form } else { if (itemName == "") { MessageBox.Show("Please fill in item name"); } if (price == 0) { MessageBox.Show("Please fill in price"); } if (category == "") { MessageBox.Show("Please select a category"); } if (type == "") { MessageBox.Show("Please select a type"); } if (ingredients == 0) { MessageBox.Show("Please select an ingredients"); } if (itemImagePath == "") { MessageBox.Show("Please upload a picture"); } } }