private void AddACompany_Load(object sender, EventArgs e)
        {
            connectionDB.ConnectionMySql();

            string sqlQuery = "SELECT name FROM sector";

            connectionDB.PutQueryIntoComboBox(sqlQuery, comboBoxSector, "name");  // Use method to add query into the comboBoxSector
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Height = Screen.PrimaryScreen.WorkingArea.Height;
            this.Width  = Screen.PrimaryScreen.WorkingArea.Width;

            dataGridViewList.DataSource = bindingSourceList;

            try
            {
                connectionDB.ConnectionMySql();



                dataGridViewList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                //dataGridViewList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;



                comboBoxChooseList.Items.Clear();
                string sqlCommand = "SELECT TABLE_NAME as available FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'dbepm' AND TABLE_NAME LIKE 'list%'";
                connectionDB.PutQueryIntoComboBox(sqlCommand, comboBoxChooseList, "available");


                comboBoxSector.Items.Clear();
                comboBoxSector.Items.Add("All companies");
                sqlCommand = "SELECT name FROM sector ORDER BY name";
                connectionDB.PutQueryIntoComboBox(sqlCommand, comboBoxSector, "name");

                comboBoxCompany.Items.Clear();
                sqlCommand = "SELECT DISTINCT name from company ORDER BY name";
                connectionDB.PutQueryIntoComboBox(sqlCommand, comboBoxCompany, "name");

                comboBoxSignature.Items.Clear();
                sqlCommand = "SELECT name FROM user";
                connectionDB.PutQueryIntoComboBox(sqlCommand, comboBoxSignature, "name");

                comboBoxSignature.Text = Properties.Settings.Default.Signature;


                comboBoxEmail.Visible = false;
            }
            catch (Exception er)
            {
                MessageBox.Show(er.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void ViewList_Load(object sender, EventArgs e)
        {
            dataGridViewList.DataSource = bindingSourceList;
            try
            {
                connectionDB.ConnectionMySql();
                comboBoxList.Items.Clear();


                dataGridViewList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

                string sqlCommand = "SELECT TABLE_NAME as available FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'dbepm' AND TABLE_NAME LIKE 'list%'";
                connectionDB.PutQueryIntoComboBox(sqlCommand, comboBoxList, "available");  // Use method to add the query to the comboBoxList
            }
            catch (Exception er)
            {
                MessageBox.Show(er.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
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");
        }
Beispiel #5
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();
        }
Beispiel #6
0
        private void CompanyListForm_Load(object sender, EventArgs e)
        {
            connectionDB.ConnectionMySql();
            dataGridViewCompanies.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            comboBoxSector.Items.Clear();
            comboBoxSector.Items.Add("All companies");

            comboBoxCompany.Items.Clear();
            comboBoxEmail.Items.Clear();


            ds.Clear();


            try
            {
                string sqlQuery = "SELECT DISTINCT name FROM company";
                connectionDB.PutQueryIntoComboBox(sqlQuery, comboBoxCompany, "name");

                string sqlCommand = "SELECT name FROM sector";
                connectionDB.PutQueryIntoComboBox(sqlCommand, comboBoxSector, "name");

                sqlCommand  = "SELECT * FROM company ORDER BY name";
                dataAdapter = new MySqlDataAdapter(sqlCommand, connectionDB.getMyconnectionString());
                // 3. fill in insert, update, and delete commands
                MySqlCommandBuilder cmdBldr = new MySqlCommandBuilder(dataAdapter);
                dataAdapter.Fill(ds, "bddmontijotest");
                dataGridViewCompanies.DataSource = ds;
                dataGridViewCompanies.DataMember = "bddmontijotest";
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #7
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");
            }
        }