private void edit() { try { STCountry data = GetSelectionData(); DlgCountrys wnd = new DlgCountrys(connect, data, mode); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { flawour = wnd.GetFl(); init_list(); if (gpos >= 0 && dataGridViewCountry.Rows.Count > 0) { dataGridViewCountry.Rows[gpos].Selected = true; dataGridViewCountry.FirstDisplayedScrollingRowIndex = gpos; } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
public DlgCountrys(SqlConnection cn, STCountry st, ushort md) { InitializeComponent(); connect = cn; mode = md; gstCountry = st; caption = "Редактировать страну"; }
private void del() { try { STCountry data = GetSelectionData(); if (MessageBox.Show("Вы действиетльно желаете удалить запись?", "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { clCountry.Delete(data); init_list(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private bool save() { bool ret = false; stC = new STCountry(); stC = read_data(); if (gstCountry.id != 0) { ret = clCountry.Update(stC); } else { ret = clCountry.Insert(stC); } return(ret); }
private STCountry GetSelectionData() { STCountry ret = new STCountry(); string n = null;; try { foreach (DataGridViewRow item in dataGridViewCountry.SelectedRows) { n = item.Cells[2].Value.ToString(); CCountry ct = new CCountry(connect, n); ret = ct.stCountry; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private STCountry read_data() { STCountry ret = new STCountry(); try { if (gstCountry.id != 0) { ret.id = gstCountry.id; } else { ret.id = clCountry.GetFreeId(); } if (textBoxName.Text.Length > 0) { ret.name = textBoxName.Text.Trim(); } else { ret.name = null; } if (textBoxShortName.Text.Length > 0) { ret.shortname = textBoxShortName.Text.Trim(); } else { ret.shortname = null; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } return(ret); }