Exemplo n.º 1
0
        private void buttonSaveCompany_Click(object sender, EventArgs e)
        {
            connectionDB.ConnectionMySql();

            try
            {
                if (textBoxNameCompany.Text != "" && comboBoxSector.Text != "")  // create the company into the database
                {
                    connectionDB.addNewCompany(connectionDB.getIdSectorFromName(comboBoxSector.Text), textBoxNameCompany.Text, textBoxEmailCompany.Text, textBoxNumero.Text, textBoxAddressCompany.Text);
                    MessageBox.Show("Database updated !");
                }
                else
                {
                    if (textBoxNameCompany.Text == "")
                    {
                        MessageBox.Show("Add at least a company name !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        MessageBox.Show("You must choose a sector !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Error, database is not updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }