Is the form corresponding to the following code, including subsequent updates and inserts.
Test_dbDataSet.courseRow cnewrow; // the course and faculty here are the names of the two data tables under test_dbDataSet.
Test_dbDataSet.facultyRow fnewrow;
If (courseid. text = "") | (course. text = "") | (facultyid. text = "") | (this. name. text = "") | (this. num. text = "") // the Text box contains the data to be inserted.
MessageBox. Show ("one or more items are not filled in. Please enter them before submitting them! ");
Else
{
/// The first method is to create an insert method for each of the two tables in the data editor of the current data source, and then call the two methods respectively to implement the insert, the following insertfaculty and insertcourse parameters are the values to be inserted.
If (cb. Text = "tableAdapter. insert ")
{
Int check = facultyTableAdapter. Insertfaculty (this. facultyid. Text, this. name. Text, this. num. Text );
Int check1 = courseTableAdapter. Insertcourse (this. courseid. Text, this. course. Text, this. facultyid. Text );
If (check> 0) & (check1> 0 ))
{
MessageBox. Show ("data update successful! ");
Facultyid. Text = "";
This. insert. Enabled = false;
}
Else
{
MessageBox. Show ("data update failed! ");
}
Course. Text = "";
Courseid. Text = "";
This. name. Text = "";
This. num. Text = "";
Courseid. Focus ();
}
/// The second method is to create a new row for both tables, insert data into the new row, add the new row to the corresponding data table, and finally update the database.
Else
{
Fnewrow = test_dbDataSet.faculty.NewfacultyRow ();
Fnewrow. faculty_id = this. facultyid. Text;
Fnewrow. name = this. name. Text;
Fnewrow. num = this. num. Text;
Test_dbDataSet.faculty.Rows.Add (fnewrow );
Int I = facultyTableAdapter. Update (test_dbDataSet.faculty); // Update the database
Cnewrow = test_dbDataSet.course.NewcourseRow ();
Cnewrow. course_id = courseid. Text;
Cnewrow. course = this. course. Text;
Cnewrow. faculty_id = this. facultyid. Text;
Test_dbDataSet.course.Rows.Add (cnewrow );
Int t = courseTableAdapter. Update (test_dbDataSet.course );
If (t> 0) & (I> 0 ))
{
MessageBox. Show ("the second method successfully inserts data! ");
This. facultyid. Text = "";
Insert. Enabled = false;
}
Else
{
MessageBox. Show ("the second method failed to insert data! ");
}
Course. Text = "";
Courseid. Text = "";
This. name. Text = "";
This. num. Text = "";
}