Пример #1
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            String sailorID = SIDTextBox.Text;
            String boatID   = BIDTextBox.Text;
            String date     = dateTextBox.Text;

            try
            {
                String     insertStmt = "insert into Reserves values(" + "'" + sailorID + "'" + "," + "'" + boatID + "'" + "," + "'" + date + "'" + ")";
                SqlCommand cmd        = new SqlCommand(insertStmt, DataBaseInfo.con);
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                String message = "Reservation was successfully added to database";
                MessageBox.Show(message, date, MessageBoxButtons.OK, MessageBoxIcon.Information);


                SIDTextBox.Clear();
                BIDTextBox.Clear();
                dateTextBox.Clear();
            }

            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error Adding Reservation", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            String boatID    = BIDTextBox.Text;
            String boatName  = bNameTextBox.Text;
            String boatColor = bColorTextBox.Text;

            try
            {
                String     insertStmt = "insert into BOATS values(" + "'" + boatID + "'" + "," + "'" + boatName + "'" + "," + "'" + boatColor + "'" + ")";
                SqlCommand cmd        = new SqlCommand(insertStmt, DataBaseInfo.con);
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                String message = "Boat was successfully added to database";
                MessageBox.Show(message, boatName, MessageBoxButtons.OK, MessageBoxIcon.Information);

                BIDTextBox.Clear();
                bNameTextBox.Clear();
                bColorTextBox.Clear();
            }

            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error adding Boat", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        } // end submit button