Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MySqlConnection con = null;
                try
                {
                    string conStr = "SERVER=" + SIP.Text + ";" + "DATABASE=" +
                                    DBN.Text + ";" + "UID=" + UN.Text + ";" + "PASSWORD="******";";
                    con = new MySqlConnection(conStr);
                    con.Open(); //open the connection
                    MessageBox.Show("Connected Success!");
                    CMD_OK.Enabled    = true;
                    groupBox2.Enabled = false;
                    CMD_OK.Focus();

                    //Show station
                    lounge_site.DataSource = siteDao.SelectAdhoc(conStr);
                }
                catch (MySqlException err) //We will capture and display any MySql errors that will occur
                {
                    MessageBox.Show("Error: " + err.ToString());
                }
                finally
                {
                    if (con != null)
                    {
                        con.Close(); //safely close the connection
                    }
                } //remember to safely close the connection after accessing the database
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Conect Fail!");
                SIP.Focus();
            }
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     Cursor = Cursors.WaitCursor;
     if (ManageLOG.Formula(textBox1.Text + textBox2.Text + textBox3.Text + textBox4.Text))
     {
         pictureBox2.Image = Properties.Resources.CT;
         groupBox2.Enabled = true;
         textBox1.Enabled  = false;
         textBox2.Enabled  = false;
         textBox3.Enabled  = false;
         textBox4.Enabled  = false;
         SIP.Focus();
     }
     else
     {
         pictureBox2.Image = Properties.Resources.CF;
         groupBox2.Enabled = false;
         textBox1.Enabled  = true;
         textBox2.Enabled  = true;
         textBox3.Enabled  = true;
         textBox4.Enabled  = true;
     }
     Cursor = Cursors.Default;
 }