コード例 #1
0
        private void DeleteACompanyForm_Load(object sender, EventArgs e)
        {
            connectionMySql connectionDB = new connectionMySql();

            connectionDB.ConnectionMySql();

            comboBoxCompany.Items.Clear();
            comboBoxEmail.Items.Clear();
            string sqlQuery = "SELECT DISTINCT name FROM company";

            connectionDB.PutQueryIntoComboBox(sqlQuery, comboBoxCompany, "name");
        }
コード例 #2
0
        private void comboBoxCompany_SelectedIndexChanged(object sender, EventArgs e)
        {
            connectionMySql connectionDB = new connectionMySql();

            connectionDB.ConnectionMySql();

            comboBoxEmail.Items.Clear();
            comboBoxEmail.Text = "";
            string sqlQuery = "SELECT email FROM company WHERE name='" + comboBoxCompany.Text + "'";

            connectionDB.PutQueryIntoComboBox(sqlQuery, comboBoxEmail, "email");
            comboBoxEmail.Text = comboBoxEmail.Items[0].ToString();
        }
コード例 #3
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            connectionMySql connectionDB = new connectionMySql();

            connectionDB.ConnectionMySql();

            try
            {
                if (comboBoxCompany.Text != null && comboBoxEmail.Text != null)
                {
                    connectionDB.deleteCompany(comboBoxCompany.Text, comboBoxEmail.Text);
                }
                MessageBox.Show("Company deleted");
                DeleteACompanyForm_Load(null, null);
                comboBoxCompany.Text = null;
                comboBoxEmail.Text   = null;
            }
            catch
            {
                MessageBox.Show("Error : Can't delete from Database");
            }
        }
コード例 #4
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(textBoxSignature.Text) || string.IsNullOrWhiteSpace(textBoxName.Text)) // Checking if all textboxes are filled
                {
                    MessageBox.Show("You have to fill everything !");
                }
                else
                {
                    connectionMySql connectionDB = new connectionMySql();

                    connectionDB.createNewSignature(textBoxName.Text, textBoxSignature.Text);  // create the new signature with infos in textboxes
                    MessageBox.Show("New signature added !");

                    textBoxName.Text      = null;
                    textBoxSignature.Text = null;
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.ToString());
            }
        }