private void edit() { try { STVoteASG?data = GetSelectionData(); if (data != null) { DlgVoteASG wnd = new DlgVoteASG(connect, (STVoteASG)data); if (wnd.ShowDialog() == DialogResult.OK) { flawour = wnd.GetFl(); init_data(v_param); if (gpos >= 0 && dataGridViewVoteASG.Rows.Count > 0) { dataGridViewVoteASG.Rows[gpos].Selected = true; dataGridViewVoteASG.FirstDisplayedScrollingRowIndex = gpos; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
public DlgVoteASG(SqlConnection cn, STVoteASG st) { InitializeComponent(); connect = cn; gstDV = st; idseason = gstDV.idseason; caption = "Редактировать голосование"; mode = 1; }
private bool save() { bool ret = false; try { stC = new STVoteASG(); stC = read_data(); if (mode == 1) { ret = clWork.Update(stC, gstDV); } else { ret = clWork.Insert(stC); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private STVoteASG read_data() { int[] arr = new int[12]; STVoteASG ret = new STVoteASG(); int i; int cnt; try { ret.idseason = idseason; ret.name = textBoxName.Text.Trim(); ret.ip = textBoxIP.Text.Trim(); ret.email = textBoxEmail.Text.Trim(); cnt = 0; arr[0] = 0; arr[1] = 0; for (i = 0; i < checkedListBox1d.Items.Count; i++) { if (cnt == 2) { break; } if (checkedListBox1d.GetItemChecked(i)) { if (cnt == 0) { arr[0] = get_int(checkedListBox1d.Items[i].ToString()); cnt = 1; } else if (cnt == 1) { arr[1] = get_int(checkedListBox1d.Items[i].ToString()); cnt = 2; } } } cnt = 0; arr[2] = 0; arr[3] = 0; for (i = 0; i < checkedListBox1a.Items.Count; i++) { if (cnt == 2) { break; } if (checkedListBox1a.GetItemChecked(i)) { if (cnt == 0) { arr[2] = get_int(checkedListBox1a.Items[i].ToString()); cnt = 1; } else if (cnt == 1) { arr[3] = get_int(checkedListBox1a.Items[i].ToString()); cnt = 2; } } } cnt = 0; arr[4] = 0; for (i = 0; i < checkedListBox1c.Items.Count; i++) { if (cnt == 1) { break; } if (checkedListBox1c.GetItemChecked(i)) { if (cnt == 0) { arr[4] = get_int(checkedListBox1c.Items[i].ToString()); cnt = 1; } } } cnt = 0; arr[5] = 0; for (i = 0; i < checkedListBox1ch.Items.Count; i++) { if (cnt == 1) { break; } if (checkedListBox1ch.GetItemChecked(i)) { if (cnt == 0) { arr[5] = get_int(checkedListBox1ch.Items[i].ToString()); cnt = 1; } } } cnt = 0; arr[6] = 0; arr[7] = 0; for (i = 0; i < checkedListBox2d.Items.Count; i++) { if (cnt == 2) { break; } if (checkedListBox2d.GetItemChecked(i)) { if (cnt == 0) { arr[6] = get_int(checkedListBox2d.Items[i].ToString()); cnt = 1; } else if (cnt == 1) { arr[7] = get_int(checkedListBox2d.Items[i].ToString()); cnt = 2; } } } cnt = 0; arr[8] = 0; arr[9] = 0; for (i = 0; i < checkedListBox2a.Items.Count; i++) { if (cnt == 2) { break; } if (checkedListBox2a.GetItemChecked(i)) { if (cnt == 0) { arr[8] = get_int(checkedListBox2a.Items[i].ToString()); cnt = 1; } else if (cnt == 1) { arr[9] = get_int(checkedListBox2a.Items[i].ToString()); cnt = 2; } } } cnt = 0; arr[10] = 0; for (i = 0; i < checkedListBox2c.Items.Count; i++) { if (cnt == 1) { break; } if (checkedListBox2c.GetItemChecked(i)) { if (cnt == 0) { arr[10] = get_int(checkedListBox2c.Items[i].ToString()); cnt = 1; } } } cnt = 0; arr[11] = 0; for (i = 0; i < checkedListBox2ch.Items.Count; i++) { if (cnt == 1) { break; } if (checkedListBox2ch.GetItemChecked(i)) { if (cnt == 0) { arr[11] = get_int(checkedListBox2ch.Items[i].ToString()); cnt = 1; } } } ret.data = con_from_arr_to_string(arr); ret.ed = new DateTime(dateTimePickerDate.Value.Year, dateTimePickerDate.Value.Month, dateTimePickerDate.Value.Day, dateTimePickerTime.Value.Hour, dateTimePickerTime.Value.Minute, 0, 0); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }