private void btAdd_Click(object sender, EventArgs e) { MDataSet.inventoryDetailsDataTable _details = new MDataSet.inventoryDetailsDataTable(); MDataSet.inventoryMasterRow mastRow = (this.inventoryMasterBindingSource.AddNew() as DataRowView).Row as MDataSet.inventoryMasterRow; mastRow.Date = DateTime.Today; mastRow.Note = "[новый документ]"; this.inventoryMasterBindingSource.EndEdit(); try { this.inventoryMasterTableAdapter.Update(mastRow); this.inventoryDetailsTableAdapter.Fill(_details); this.mDataSet.inventoryDetails.Merge(_details); } catch (Exception err) { this.mDataSet.inventoryMaster.RejectChanges(); this.inventoryMasterBindingSource.Position = 0; this.inventoryMasterBindingSource.ResetBindings(false); MessageBox.Show(err.Message); // this.inventoryMasterBindingSource.CancelEdit(); // mastRow.RejectChanges(); } }
private void btAdd_Click(object sender, EventArgs e) { MDataSet.inventoryDetailsDataTable _details = new MDataSet.inventoryDetailsDataTable(); MDataSet.inventoryMasterRow mastRow=(this.inventoryMasterBindingSource.AddNew() as DataRowView).Row as MDataSet.inventoryMasterRow; mastRow.Date = DateTime.Today; mastRow.Note = "[новый документ]"; this.inventoryMasterBindingSource.EndEdit(); try { this.inventoryMasterTableAdapter.Update(mastRow); this.inventoryDetailsTableAdapter.Fill(_details); this.mDataSet.inventoryDetails.Merge(_details); } catch (Exception err) { this.mDataSet.inventoryMaster.RejectChanges(); this.inventoryMasterBindingSource.Position = 0; this.inventoryMasterBindingSource.ResetBindings(false); MessageBox.Show(err.Message); // this.inventoryMasterBindingSource.CancelEdit(); // mastRow.RejectChanges(); } }
public virtual MDataSet.inventoryDetailsDataTable GetData() { this.Adapter.SelectCommand = this.CommandCollection[0]; MDataSet.inventoryDetailsDataTable dataTable = new MDataSet.inventoryDetailsDataTable(); this.Adapter.Fill(dataTable); return dataTable; }