private STCoach GetSelectionData() { STCoach ret = new STCoach(); int id; try { if (g_f) { foreach (DataGridViewRow item in dataGridViewCoach.SelectedRows) { id = int.Parse(item.Cells[6].Value.ToString()); foreach (STCoach s in list) { if (id == s.idcoach) { ret = s; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(ret); }
public DlgCoach(SqlConnection cn, ushort md, STCoach st) { InitializeComponent(); connect = cn; mode = md; gstCoach = st; gid = gstCoach.idcoach; clCoach = new CCoach(connect); clParam = new CParamApp(); caption = "–едактировать данные тренера"; }
private void del() { STCoach data = GetSelectionData(); if (data.idcoach > 0) { string text = string.Format("Вы действительно желаете удалить тренера: {0} {1} {2}", data.family, data.name, data.payname); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { if (clCoach.Delete(data)) { init_data(); } } } }
private bool save() { bool ret = false; STCoach data = new STCoach(); data = read_data(); if (gstCoach.idcoach != 0) { ret = clCoach.Update(data, gstCoach.idcoach); } else { ret = clCoach.Insert(data); } return(ret); }
private void edit() { STCoach data = GetSelectionData(); if (data.idcoach > 0) { DlgCoach wnd = new DlgCoach(connect, mode, data); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { init_data(); if (dataGridViewCoach.Rows.Count > 0) { int x = get_num_row(wnd.RetId()); dataGridViewCoach.Rows[x].Selected = true; dataGridViewCoach.FirstDisplayedScrollingRowIndex = x; } } } }
private STCoach read_data() { STCoach ret = new STCoach(); CCountry clCo; try { ret.idcoach = gid; if (textBoxFamily.Text.Length > 0) { ret.family = textBoxFamily.Text; } else { ret.family = null; } if (textBoxName.Text.Length > 0) { ret.name = textBoxName.Text; } else { ret.name = null; } if (textBoxSecondName.Text.Length > 0) { ret.payname = textBoxSecondName.Text; } else { ret.payname = null; } ret.datebirth = new DateTime(dateTimePickerDateBirth.Value.Year, dateTimePickerDateBirth.Value.Month, dateTimePickerDateBirth.Value.Day, 0, 0, 0, 0); if (textBoxPersonalNum.Text.Length > 0) { ret.personalnum = textBoxPersonalNum.Text; } else { ret.personalnum = null; } if (comboBoxCountry.Text.Length > 0) { string c = comboBoxCountry.Text; clCo = new CCountry(connect, c); ret.idcountry = clCo.stCountry.id; } else { ret.idcountry = 0; } if (labelNameFoto.Text.Length > 0) { ret.namefoto = labelNameFoto.Text.Trim(); } else { ret.namefoto = null; } if (textBoxDescript.Text.Length > 0) { ret.descript = textBoxDescript.Text; } else { ret.descript = null; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } return(ret); }