private void btnESamo_Click(object sender, EventArgs e) { int Id = 0; DataTable g = dgvSamo.DataSource as DataTable; DataRow row = ((DataRowView)dgvSamo.SelectedRows[0].DataBoundItem).Row; Id = row.Field <int>("IdSam"); DataTable rr = wypSamochodTableAdapter.GetDataBy(Id); Samochod SamoEdyt = new Samochod(rr); frmDodSamo SamEdyt = new frmDodSamo(SamoEdyt); SamEdyt.dodano += Main_Load; SamEdyt.ShowDialog(); }
private void btnUSamo_Click(object sender, EventArgs e) { DataTable g = dgvSamo.DataSource as DataTable; DataRow row = ((DataRowView)dgvSamo.SelectedRows[0].DataBoundItem).Row; int Id = row.Field <int>("IdSam"); DataTable rr = wypSamochodTableAdapter.GetDataBy(Id); Samochod samo = new Samochod(rr); DialogResult wynik = MessageBox.Show("Czy na pewno usunąć ten samochód?", "Usuwanie", MessageBoxButtons.YesNo, MessageBoxIcon.Question); switch (wynik) { case DialogResult.Yes: samo.Usun(); Main_Load(this, e); break; } }
public frmDodSamo(Samochod samochd) { InitializeComponent(); this.samochod = samochd; samochodBindingSource.DataSource = this.samochod; }