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); } }
private Strelba GetSelectedStr() { // The "SelectionMode" property of the data grid view must be set to "FullRowSelect". if (StrGrid.SelectedRows.Count == 1) { Strelba strelba = StrGrid.SelectedRows[0].DataBoundItem as Strelba; return(strelba); } else { return(null); } }
protected void GetData() { Collection <Strelba> strelby = Strelba.SelectAll(); Collection <StrelbaDTO> vystup = new Collection <StrelbaDTO>(); foreach (Strelba strelba in strelby) { vystup.Add(new StrelbaDTO(strelba)); } BindingList <StrelbaDTO> bindingList = new BindingList <StrelbaDTO>(vystup); dataGridView1.DataSource = bindingList; }
protected void EditRecord() { Strelba selectedStr = GetSelectedStr(); if (selectedStr != null) { DetailStrelba form = new DetailStrelba(); if (form.OpenRecord(selectedStr.idStr)) { form.ShowDialog(); GetData(); } } }
public bool OpenRecord(object primaryKey) { if (primaryKey != null) { int idStr = (int)primaryKey; strelba = StrelbaTable.select(idStr); newRecord = false; } else { strelba = new Strelba(); strelba.Zacatek = new DateTime(2000, 01, 01); strelba.Konec = new DateTime(2000, 01, 01); newRecord = true; } BindData(); return(true); }
protected bool SaveRecord() { if (GetData()) { if (newRecord) { Strelba.insert(strelba); } else { Strelba.update(strelba); } return(true); } else { return(false); } }
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); }
// Use this for initialization void Start() { _strel = GetComponentInParent <Strelba>(); }