Example #1
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            MySqlConnection dbConnection = new MySqlConnection(MySqlConnectionString);
            string          query        = "INSERT INTO `products`(`name`, `mark`, `model`, `doors`, `engines`, `hp`, `cubic`, `gearbox`, `typeCar`, `serialNumber`, `category`, `subCategory`)" +
                                           " VALUES('" + txbproductName.Text + "','" + cmbMarka.Text + "','" + cmbmodel.Text + "','" + cmbdoor.Text + "','" + cmbengine.Text + "','" + txbhp.Text + "','" + txbcubic.Text + "','" + cmbgearbox.Text + "','" + cmbtypeCar.Text + "','" + txbserialNumber.Text + "','" + cmbcategory.Text + "','" + cmbSubCategory.Text + "')";
            MySqlCommand cmd = new MySqlCommand(query, dbConnection);

            dbConnection.Open();
            int check = cmd.ExecuteNonQuery();

            if (check > 0)
            {
                MessageBox.Show("Добавянето е успешно");
            }
            dbConnection.Close();
            txbproductName.Text    = "";
            txbcubic.Text          = "";
            txbhp.Text             = "";
            txbserialNumber.Text   = "";
            cmbcategory.Text       = "";
            cmbdoor.Text           = "";
            cmbengine.Text         = "";
            cmbgearbox.Text        = "";
            cmbMarka.Text          = "";
            cmbmodel.Text          = "";
            cmbtypeCar.Text        = "";
            cmbSubCategory.Text    = "";
            last_product_insert_id = cmd.LastInsertedId;
            dbConnection.Close();
            if (MetroFramework.MetroMessageBox.Show(this, "Желаете ли да добавите изображения към този продукт?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                uploadImages();
            }
            else
            {
                Form1 frm1 = new Form1();
                frm1.Activate();
            }
        }
Example #2
0
        private void Form2_FormClosed(object sender, FormClosedEventArgs e)
        {
            Form1 frm1 = new Form1();

            frm1.Activate();
        }