private void Clear_Input()
 {
     //Function to clear all text boxes of data
     txtBoxName.Clear();
     txtBoxSciName.Clear();
     RAsHrTxt.Clear();
     RAsMinTxt.Clear();
     RAsSecTxt.Clear();
     DecDTxt.Clear();
     DecMinTxt.Clear();
     DecSecTxt.Clear();
 }
        private void btnNebulaeSave_Click(object sender, EventArgs e)
        {
            //check Right Ascention is correct
            if (RAsHrTxt_Valid == false || RAsMinTxt_Valid == false || RAsSecTxt_Valid == false)
            {
                //reort error in Right ascention
                if (MessageBox.Show("Right Ascension is not correct. Please validate data.") ==
                    DialogResult.OK)
                {
                    RAsHrTxt.Select();
                }

                return;
            }

            //check that Declination is correct
            if (DecDTxt_Valid == false || DecMinTxt_Valid == false || DecSecTxt_Valid == false)
            {
                //report an error in declination
                if (MessageBox.Show("Declination is not correct. Please validate data.") ==
                    DialogResult.OK)
                {
                    DecDTxt.Select();
                }
                return;
            }

            // If all values valid, add to database
            else
            {
                // Open DB connection
                connect.Open();

                //Bind cmd to SQL commands
                SqlCommand cmd = connect.CreateCommand();
                cmd.CommandType = CommandType.Text;


                //SQL Command to update data if user wishes to edit data in DB
                if (editRow == true)
                {
                    //set editRow to false to prevent future save/delete issues
                    editRow         = false;
                    cmd.CommandText = "Update NebulaeFavorites Set CommonName = @commonName, ScientificName = @sciName, RAHr = @RAHr, RAMin = @RAMin, RASec = @RASec, DDeg = @DDeg, DMin = @DMin, DSec = @DSec WHERE (NebulaeID = @NebID)";
                    cmd.Parameters.AddWithValue("@NebID", nebulaID);
                }

                //SQL command to be entered into DB with Scientific Name
                else if (sciName_Valid == true)
                {
                    cmd.CommandText = "insert into NebulaeFavorites (CommonName, ScientificName, RAHr, RAMin, RASec, DDeg, DMin, DSec) VALUES (@commonName, @sciName, @RAHr, @RAMin, @RASec, @DDeg, @DMin, @DSec)";
                }

                //SQL command to be entered into DB without scientific name
                else
                {
                    cmd.CommandText = "insert into NebulaeFavorites (CommonName, RAHr, RAMin, RASec, DDeg, DMin, DSec) VALUES (@commonName,  @RAHr, @RAMin, @RASec, @DDeg, @DMin, @DSec)";
                }

                //Bind variables to SQL command names
                cmd.Parameters.AddWithValue("@commonName", commonName);
                cmd.Parameters.AddWithValue("@sciName", sciName);
                cmd.Parameters.AddWithValue("@RAHr", RAHr);
                cmd.Parameters.AddWithValue("@RAMin", RAMin);
                cmd.Parameters.AddWithValue("@RASec", RASec);
                cmd.Parameters.AddWithValue("@DDeg", DDeg);
                cmd.Parameters.AddWithValue("@DMin", DMin);
                cmd.Parameters.AddWithValue("@DSec", DSec);

                cmd.ExecuteNonQuery();

                //Close DB connection and reload datagrid
                connect.Close();
                MessageBox.Show("Submitted " + commonName.Trim() + " into database");

                //Clear data from Text boxes
                Clear_Input();

                //Reload Table
                LoadTable();

                //Reload combo box on nebulae user control
                nebulaePanel.LoadComboBox();

                //Set nebula ID to null to prevent unwanted editing or deleting
                nebulaID = null;
            }
        }