private void btnHome_Click(object sender, RoutedEventArgs e)//redirect back to home page { Manage_Shop manage = new Manage_Shop(); manage.Show(); this.Close(); }
private void btnManage_Click(object sender, RoutedEventArgs e) { Manage_Shop manage = new Manage_Shop(); this.Close(); manage.Show(); }
private void btnContinue_Click(object sender, RoutedEventArgs e) { try { try //upload the picture { ImageSource imgsource = new BitmapImage(new Uri(filepath)); appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); string filename = System.IO.Path.GetFileName(open.FileName); string foldername = "Resources"; string resourcePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(appStartPath, @"..\..\..\..\")); appStartPath = String.Format(resourcePath + "\\{0}\\" + filename, foldername); File.Copy(filepath, appStartPath, true); } catch { } string sqlUpdateField = "INSERT INTO Coffee (Name, Strength, Grind, Origin, Stock, Trigger_Quantity, Price, Picture, Description, InternalComments)" + "VALUES (@Name, @Strength, @Grind, @Origin, @Available_Quantity, @Trigger_Quantity, @Price, @Picture, @Description, @InternalComments)"; var cmd = database.dataConnection(sqlUpdateField); cmd.Parameters.AddWithValue("@Name", OleDbType.VarChar).Value = txtName.Text; cmd.Parameters.AddWithValue("@Strength", OleDbType.VarChar).Value = txtStrength.Text; cmd.Parameters.AddWithValue("@Grind", OleDbType.VarChar).Value = txtGrind.Text; cmd.Parameters.AddWithValue("@Origin", OleDbType.VarChar).Value = txtOrigin.Text; cmd.Parameters.AddWithValue("@Available_quantity", OleDbType.VarChar).Value = txtAvailable.Text; cmd.Parameters.AddWithValue("@Trigger_Quantity", OleDbType.VarChar).Value = txtTrigger.Text; cmd.Parameters.AddWithValue("@Price", OleDbType.VarChar).Value = txtPrice.Text; cmd.Parameters.AddWithValue("@Picture", OleDbType.VarChar).Value = appStartPath; cmd.Parameters.AddWithValue("@Description", OleDbType.VarChar).Value = txtDescription.Text; cmd.Parameters.AddWithValue("@InternalComments", OleDbType.VarChar).Value = txtComments.Text; var data = database.parameters(); MessageBox.Show("Successfuly added new product!", "Success", MessageBoxButton.OK, MessageBoxImage.Information); Manage_Shop shop = new Manage_Shop(); this.Close(); shop.Show(); } catch { MessageBox.Show("Error occured while adding new Product!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }