private void dgvWypozyczenie_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int numerwypozyczenia = Convert.ToInt32(dgvWypozyczenie.CurrentRow.Cells[0].Value); SzczegolyWypozyczenia szczegoly = new SzczegolyWypozyczenia(database, Decimal.ToInt32(numerwypozyczenia)); szczegoly.Show(); }
private void button1_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Czy chcesz usunąć narzedzie?", "Usuwanie narzedzia", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { SzczegolyWypozyczenia frm = (SzczegolyWypozyczenia)Application.OpenForms["SzczegolyWypozyczenia"]; int id = Convert.ToInt32(this.dgv.CurrentRow.Cells[0].Value); DM_Szczegoly_wypozyczenia_narzedzia toRemove = this.database.DM_Szczegoly_wypozyczenia_narzedzia.Where(id_narz => id_narz.Id_narzedzia == id).First(); this.database.DM_Szczegoly_wypozyczenia_narzedzia.Remove(toRemove); // DELETE this.database.SaveChanges(); this.Close(); } else { DialogResult dialog1Result = MessageBox.Show("Nie udało się usunąć narzędzia"); } }