Exemple #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) //event handle when picking an item
        {
            try
            {
                MySqlConnection connection = new MySqlConnection("Datasource=localhost;port=3306;username=root;password="******"\"{comboBox1.SelectedItem.ToString()}\"";
                string query        = "SELECT * FROM bookstore.books WHERE title = " + selectedItem;
                connection.Open();
                MySqlCommand    command = new MySqlCommand(query, connection);
                MySqlDataReader reader  = command.ExecuteReader();
                if (reader.Read())
                {
                    AuthorText.Text = reader["author"].ToString();
                    PriceText.Text  = reader["price"].ToString();
                    IsbnText.Text   = reader["ISBN"].ToString();
                }
                connection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //clear form
                AuthorText.Clear();
                IsbnText.Clear();
                PriceText.Clear();
            }

            QuantityText.Focus();
        }
Exemple #2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) //event handle when picking an item
        {
            string SelectedItem = (string)comboBox1.SelectedItem;

            try
            {
                //access books
                string  BookJSON = File.ReadAllText(@"C:\Users\RMBonMAC\Documents\GitHub\BookStore\BookStore\BookStore\bin\Debug\Books.json");
                JObject json     = JObject.Parse(BookJSON);

                JObject BookTarget = (JObject)json[SelectedItem];

                string book_target = BookTarget.ToString();

                Book foundBook = new Book();
                Newtonsoft.Json.JsonConvert.PopulateObject(book_target, foundBook);
                AuthorText.Text = foundBook.author;;
                IsbnText.Text   = foundBook.ISBN;
                PriceText.Text  = foundBook.price.ToString();
            }
            catch {
                AuthorText.Clear();
                IsbnText.Clear();
                PriceText.Clear();
            }

            QuantityText.Focus();
        }
Exemple #3
0
        /// <summary>
        /// This creates the book and if a certain book is picked, the corresponding text boxes will update with the
        /// correct information in each box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string SelectedItem = (string)comboBox1.SelectedItem;

            try
            {
                string  jsonBook     = File.ReadAllText(@"Z:\Desktop\Fourth Year (F18-S19)\CompE561\Lab1\Lab1\bin\Debug\BookList.json");
                JObject JSON         = JObject.Parse(jsonBook);
                JObject targetBook   = (JObject)JSON[SelectedItem];
                string  s_targetBook = targetBook.ToString();
                Book    found        = new Book();
                Newtonsoft.Json.JsonConvert.PopulateObject(s_targetBook, found);
                AuthorText.Text = found.author;;
                IsbnText.Text   = found.ISBN;
                PriceText.Text  = found.price.ToString();
            }

            catch
            {
                AuthorText.Clear();
                IsbnText.Clear();
                PriceText.Clear();
            }
            QuantityText.Focus();
        }
Exemple #4
0
        private void SubmitSaleButton_Click(object sender, RoutedEventArgs e)
        {
            string[] Data = new string[5];
            Data[0] = VehicleText.GetLineText(0);
            Data[1] = CustomerText.GetLineText(0);
            Data[2] = EmployeeText.GetLineText(0);
            Data[3] = DateText.GetLineText(0);
            Data[4] = PriceText.GetLineText(0);

            MakeSale S = new MakeSale(Data, cn);

            try
            {
                S.CreateSale();
            }
            catch (OleDbException ex)
            {
                ErrorWindow Error = new ErrorWindow(ex.Message);
                Error.ShowDialog();
                return;
            }

            VehicleText.Clear();
            CustomerText.Clear();
            EmployeeText.Clear();
            DateText.Clear();
            PriceText.Clear();
        }