private void btnEdit2_Click(object sender, EventArgs e) { try { if (!(string.IsNullOrWhiteSpace(cmbService.Text)))//makes sure that the service is not empty { connection.Open(); MySqlCommand command = new MySqlCommand(); command.Connection = connection; command.CommandText = "Select Servicenum FROM tblservice WHERE ServiceName='" + cmbService.Text + "'"; MySqlDataReader reader = command.ExecuteReader(); int servNum = 0; while (reader.Read()) { servNum = Convert.ToInt16(reader["ServiceNum"].ToString());//gets the service num } reader.Close(); connection.Close(); AdminEdit AdminEdit = new AdminEdit(cmbService.Text, servNum);//passes the name and the number so it can be edited in to other form so it can be displayed there AdminEdit.ShowDialog(); } else { MessageBox.Show("Choose Service Name"); } } catch (Exception a) { MessageBox.Show(a.ToString()); connection.Close(); } }
private void btnAdd_Click(object sender, EventArgs e) { AdminEdit AdminEdit = new AdminEdit();//takes you to the other form with no information because the user willl input new infomation there AdminEdit.ShowDialog(); }