示例#1
0
 void insertbutton_Click(object sender, EventArgs e)
 {
     try
     {
         age = Int32.Parse(textBox2.Text);
     }
     catch (FormatException)
     {
         MessageBox.Show("Age should be integer");
     }
     db.Insert(textBox1.Text, age, textBox3.Text);
 }
示例#2
0
        private void textBoxServer_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (dbc.sqlConnect.State == ConnectionState.Closed)
                {
                    dbc = new DBConnect(textBoxServer.Text, textBoxDB.Text, textBoxUID.Text, textBoxPassword.Text, tbTable.Text);
                    if (dbc.OpenConnection())
                    {
                        this.Width  = 385;
                        this.Height = 330;
                        SwitchComponents();
                    }
                }
                else if (dbc.sqlConnect.State == ConnectionState.Open)
                {
                    if (tbAge.TextLength > 0)
                    {
                        dbc.Insert(textBoxServer.Text, Int32.Parse(tbAge.Text));
                    }
                    else
                    {
                        dbc.Insert(textBoxServer.Text, 0);
                    }
                }


                ClearBoxes();
            }
        }