private void edit() { try { STRegion data = GetSelectionData(); DlgRegions wnd = new DlgRegions(connect, data, mode); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { flawour = wnd.GetFl(); init_list(); if (gpos >= 0 && dataGridViewRegion.Rows.Count > 0) { dataGridViewRegion.Rows[gpos].Selected = true; dataGridViewRegion.FirstDisplayedScrollingRowIndex = gpos; } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
public DlgRegions(SqlConnection cn, STRegion st, ushort md) { InitializeComponent(); connect = cn; mode = md; gstRegion = st; caption = "Редактировать регион"; init_combo(); set_data(); }
private STRegion read_data() { STRegion ret = new STRegion(); CCountry country; try { if (gstRegion.id != 0) { ret.id = gstRegion.id; } else { ret.id = clRegion.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; } string str = comboBoxCountry.Text.Trim(); if (str.Length > 0) { country = new CCountry(connect, str); ret.idcountry = country.stCountry.id; } else { ret.idcountry = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } return(ret); }
private void del() { try { STRegion data = GetSelectionData(); if (MessageBox.Show("Вы действиетльно желаете удалить запись?", "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { clRegion.Delete(data); init_list(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private bool save() { bool ret = false; stC = new STRegion(); stC = read_data(); if (gstRegion.id != 0) { ret = clRegion.Update(stC); } else { ret = clRegion.Insert(stC); } return(ret); }
private STRegion GetSelectionData() { STRegion ret = new STRegion(); string n; try { foreach (DataGridViewRow item in dataGridViewRegion.SelectedRows) { n = item.Cells[1].Value.ToString(); CRegion ct = new CRegion(connect, n); ret = ct.stReg; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }