Hello,
I did all the steps in the documentation, I do not load the selected resource of the appointment, but if they are saving in the database the 3 tables
I need help, what am I doing wrong
I leave the code and attach images
public radForm1()
{
InitializeComponent();
AppointmentsTableAdapter appointmentsTableAdapter = new AppointmentsTableAdapter();
appointmentsTableAdapter.Fill(testDataSet.Appointments);
ResourcesTableAdapter resourcesTableAdapter = new ResourcesTableAdapter();
resourcesTableAdapter.Fill(testDataSet.Resources);
AppointmentsResourcesTableAdapter appointmentsResourcesTableAdapter = new AppointmentsResourcesTableAdapter();
appointmentsResourcesTableAdapter.Fill(testDataSet.AppointmentsResources);
}
private void radButtonSave_Click(object sender, EventArgs e)
{
AppointmentsTableAdapter appointmentsTableAdapter = new AppointmentsTableAdapter();
AppointmentsResourcesTableAdapter appointmentsResourcesTableAdapter = new AppointmentsResourcesTableAdapter();
TestDataSet.AppointmentsResourcesDataTable deletedChildRecords =
this.testDataSet.AppointmentsResources.GetChanges(DataRowState.Deleted)
as TestDataSet.AppointmentsResourcesDataTable;
TestDataSet.AppointmentsResourcesDataTable newChildRecords =
this.testDataSet.AppointmentsResources.GetChanges(DataRowState.Added)
as TestDataSet.AppointmentsResourcesDataTable;
TestDataSet.AppointmentsResourcesDataTable modifiedChildRecords =
this.testDataSet.AppointmentsResources.GetChanges(DataRowState.Modified)
as TestDataSet.AppointmentsResourcesDataTable;
try
{
if (deletedChildRecords != null)
{
appointmentsResourcesTableAdapter.Update(deletedChildRecords);
}
appointmentsTableAdapter.Update(this.DataSet.Appointments);
if (newChildRecords != null)
{
appointmentsResourcesTableAdapter.Update(newChildRecords);
}
if (modifiedChildRecords != null)
{
appointmentsResourcesTableAdapter.Update(modifiedChildRecords);
}
this.DataSet.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (deletedChildRecords != null)
deletedChildRecords.Dispose();
if (newChildRecords != null)
newChildRecords.Dispose();
if (modifiedChildRecords != null)
modifiedChildRecords.Dispose();
}
}