private void init_combo() { try { comboBoxDivision.Items.Clear(); List <STDivision> lst = clDiv.GetListDivision(IS.idseason); foreach (STDivision item in lst) { comboBoxDivision.Items.Add(item.name); } if (comboBoxDivision.Items.Count == 1) { comboBoxDivision.Text = comboBoxDivision.Items[0].ToString(); comboBoxDivision.Enabled = false; currdiv = lst[0]; } else { comboBoxDivision.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void edit() { try { STDivision data = GetSelectionData(); DlgDivision wnd = new DlgDivision(connect, IS, data, mode); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { flawour = wnd.GetFl(); init_data(); if (gpos >= 0 && dataGridViewDivision.Rows.Count > 0) { dataGridViewDivision.Rows[gpos].Selected = true; dataGridViewDivision.FirstDisplayedScrollingRowIndex = gpos; } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
public DlgDivision(SqlConnection cn, STInfoSeason inf, STDivision st, ushort md) { InitializeComponent(); connect = cn; mode = md; gstDivision = st; IS = inf; caption = "–едактировать дивизион"; }
private void del() { try { STDivision data = GetSelectionData(); if (MessageBox.Show("¬ы действиетльно желаете удалить данную запись?", "¬нимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { clDivision.Delete(data); init_data(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private bool save() { bool ret = false; stC = read_data(); if (gstDivision.id != 0) { ret = clDivision.Update(stC); } else { ret = clDivision.Insert(stC); } return(ret); }
private void comboBoxDivision_SelectedIndexChanged(object sender, EventArgs e) { string text = null; try { if (comboBoxDivision.Text.Length > 0) { text = comboBoxDivision.Text.Trim(); clDiv = new CDivision(connect, IS.idseason, text); currdiv = clDiv.stDiv; init_data(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private STDivision GetSelectionData() { STDivision ret = new STDivision(); string n; try { foreach (DataGridViewRow item in dataGridViewDivision.SelectedRows) { n = item.Cells[1].Value.ToString(); CDivision sp = new CDivision(connect, (int)IS.idseason, n); ret = sp.stDiv; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private STDivision read_data() { STDivision ret = new STDivision(); try { /* основные параметры */ ret.idseason = (int)IS.idseason; if (gstDivision.id != 0) { ret.id = gstDivision.id; } else { ret.id = clDivision.GetFreeId((int)IS.idseason); } if (textBoxName.Text.Length > 0) { ret.name = textBoxName.Text.Trim(); } else { ret.name = null; } if (textBoxCntTeam.Text.Length > 0) { ret.cntteam = int.Parse(textBoxCntTeam.Text.Trim()); } else { ret.cntteam = 0; } if (textBoxCntPlayer.Text.Length > 0) { ret.cntplayer = int.Parse(textBoxCntPlayer.Text.Trim()); } else { ret.cntplayer = 0; } /* игры регул¤рки */ if (checkBoxReg.CheckState == CheckState.Checked) { ret.flag_reg = 1; if (textBoxCntStageReg.Text.Length > 0) { ret.cntstagereg = int.Parse(textBoxCntStageReg.Text.Trim()); } else { ret.cntstagereg = 0; } if (checkBoxWinsReg.CheckState == CheckState.Checked) { ret.flag_wins_reg = 1; } else { ret.flag_wins_reg = 0; } } else { ret.flag_reg = 0; ret.cntstagereg = 0; ret.flag_wins_reg = 0; } /* игры плей-офф */ if (checkBoxPO.CheckState == CheckState.Checked) { ret.flag_po = 1; if (textBoxCntStagePO.Text.Length > 0) { ret.cntstagepo = int.Parse(textBoxCntStagePO.Text.Trim()); } else { ret.cntstagepo = 0; } if (textBoxCntTeamPO.Text.Length > 0) { ret.cntteampo = int.Parse(textBoxCntTeamPO.Text.Trim()); } else { ret.cntteampo = 0; } } else { ret.flag_po = 0; ret.cntstagepo = 0; ret.cntteampo = 0; } /* стыковые игры */ if (checkBoxStyk.CheckState == CheckState.Checked) { ret.flag_styk = 1; if (textBoxCntTeamStyk.Text.Length > 0) { ret.cntteamstyk = int.Parse(textBoxCntTeamStyk.Text.Trim()); } else { ret.cntteamstyk = 0; } } else { ret.flag_styk = 0; ret.cntteamstyk = 0; } /* ротаци¤ */ if (checkBoxTeamIn.CheckState == CheckState.Checked) { ret.flag_in = 1; if (textBoxCntTeamIn.Text.Length > 0) { ret.cntteamin = int.Parse(textBoxCntTeamIn.Text.Trim()); } else { ret.cntteamin = 0; } } else { ret.flag_in = 0; ret.cntteamin = 0; } if (checkBoxTeamOut.CheckState == CheckState.Checked) { ret.flag_out = 1; if (textBoxCntTeamOut.Text.Length > 0) { ret.cntteamout = int.Parse(textBoxCntTeamOut.Text.Trim()); } else { ret.cntteamout = 0; } } else { ret.flag_out = 0; ret.cntteamout = 0; } ret.deadline = new DateTime(dateTimePickerDead.Value.Year, dateTimePickerDead.Value.Month, dateTimePickerDead.Value.Day, 0, 0, 0, 0); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } return(ret); }