Ejemplo n.º 1
0
        //Method for OK button to add new product to list and database
        private void btnOK_Click(object sender, EventArgs e)
        {
            string name = txtProdName.Text.ToString();                                //get text from textbox
            int    i    = ProductsDB.AddNewProduct(name.ToUpper());                   //change input to uppercase

            KeyValuePair <string, int> val = new KeyValuePair <string, int>(name, i); //create key value pair for databse

            ProductsDB.Products.Add(val);                                             //add new value pair to database

            MessageBox.Show("Created new product.", "Success");                       //popup confirmation
            this.Close();
        }