protected void DeleteRecord() { if (dataGridView1.SelectedRows.Count == 1) { StrelbaDTO strelba = dataGridView1.SelectedRows[0].DataBoundItem as StrelbaDTO; Strelba.delete(Strelba.getById(strelba.Id)); GetData(); } }
private Strelba GetSelectedStr() { // The "SelectionMode" property of the data grid view must be set to "FullRowSelect". if (dataGridView1.SelectedRows.Count == 1) { StrelbaDTO strelba = dataGridView1.SelectedRows[0].DataBoundItem as StrelbaDTO; return(Strelba.getById(strelba.Id)); } else { return(null); } }
public bool OpenRecord(object primaryKey) { if (primaryKey != null) { int idStr = (int)primaryKey; strelba = Strelba.getById(idStr); newRecord = false; } else { strelba = new Strelba(); newRecord = true; } TimeSpan span = strelba.Konec.Subtract(strelba.Zacatek); txtMin.Text = span.TotalMinutes.ToString(); BindData(); return(true); }