private void btnNovy_Click(object sender, EventArgs e) { FormEditUkol form = new FormEditUkol(); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { Ukol ukol = new Ukol(form.dtpDatum.Value, form.cbDulezity.Checked, form.cbUpozorneni.Checked, form.tbUkol.Text); PridejUkol(ukol); ZobrazUkoly(); } }
private void BtnEdit_Click(object sender, EventArgs e) { FormEditUkol form = new FormEditUkol(); int idx = SelectedIndex(); if ((idx >= 0) && (idx < ukolList.Count)) { form.dtpDatum.Value = ukolList[idx].Datum; form.cbDulezity.Checked = ukolList[idx].Dulezity; form.cbUpozorneni.Checked = ukolList[idx].Upozorneni; form.tbUkol.Text = ukolList[idx].Text; DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { Ukol ukol = new Ukol(form.dtpDatum.Value, form.cbDulezity.Checked, form.cbUpozorneni.Checked, form.tbUkol.Text); UpravUkol(idx, ukol); ZobrazUkoly(); } } }
private int CompareByDate(Ukol x, Ukol y) { if ((x == null) && (y == null)) return 0; else if (x == null) return -1; else if (y == null) return 1; return x.Datum.CompareTo(y.Datum); }
private void UpravUkol(int idx, Ukol ukol) { if ((idx >= 0) && (idx < ukolList.Count) && (ukol != null)) { ukolList[idx] = ukol; SetridAUlozUkoly(); } }
private void PridejUkol(Ukol ukol) { if (ukol != null) { ukolList.Add(ukol); SetridAUlozUkoly(); } }