private STGameDays GetSelectionData() { STGameDays ret = new STGameDays(); CPlace clPlace; int n; int idplace = 0; try { foreach (DataGridViewRow item in dataGridViewGameDays.SelectedRows) { if (item.Cells[0].Value != null) { n = int.Parse(item.Cells[0].Value.ToString()); if (item.Cells[2].Value.ToString() != null) { clPlace = new CPlace(connect, item.Cells[2].Value.ToString()); idplace = clPlace.stPlace.id; } ret = clWork.GetRecord(IS.idseason, n, idplace); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private void edit() { try { STGameDays data = GetSelectionData(); if (data.nday > 0) { DlgGameDays wnd = new DlgGameDays(connect, IS, data); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { flawour = wnd.GetFl(); init_data(); if (gpos >= 0 && dataGridViewGameDays.Rows.Count > 0) { dataGridViewGameDays.Rows[gpos].Selected = true; dataGridViewGameDays.FirstDisplayedScrollingRowIndex = gpos; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void set_data(STGameDays data) { try { textBoxNDay.Text = data.nday.ToString(); dateTimePickerDate.Value = data.date; textBoxCntGame.Text = data.cntgames.ToString(); clPlace = new CPlace(connect, data.idplace); comboBoxPlace.Text = clPlace.stPlace.name; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void del() { string text = null; try { STGameDays data = GetSelectionData(); if (data.nday > 0) { text = string.Format("Вы действиетльно желаете удалить игровой день {0}?", data.nday); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { clWork.Delete(data); init_data(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void buttonOK_Click(object sender, EventArgs e) { try { rData = read_data(); if (mode == 1) { if (clWork.Update(rData, (STGameDays)oldData)) { DialogResult = DialogResult.OK; } } if (mode == 0) { if (clWork.Insert(rData)) { DialogResult = DialogResult.OK; } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private STGameDays read_data() { STGameDays ret = new STGameDays(); List <int> arr = new List <int>(); string text = null; string family = null; string name = null; string[] words; try { ret.idseason = IS.idseason; if (textBoxNDay.Text.Length > 0) { ret.nday = int.Parse(textBoxNDay.Text.Trim()); } else { ret.nday = 0; } ret.date = new DateTime(dateTimePickerDate.Value.Year, dateTimePickerDate.Value.Month, dateTimePickerDate.Value.Day, 0, 0, 0, 0); if (textBoxCntGame.Text.Length > 0) { ret.cntgames = int.Parse(textBoxCntGame.Text.Trim()); } else { ret.cntgames = 0; } for (int i = 0; i < checkedListBoxAdmin.Items.Count; i++) { if (checkedListBoxAdmin.GetItemChecked(i)) { text = checkedListBoxAdmin.Items[i].ToString(); if (text.Length > 0) { char[] del = { ' ' }; words = text.Split(del); family = words[0]; name = words[1]; clPart = new CParticipant(connect, family, name); } arr.Add(clPart.stPart.idpart); } } if (arr.Count > 0) { ret.adminline = clWork.GetStringData(arr); } else { ret.adminline = null; } arr = new List <int>(); for (int i = 0; i < checkedListBoxWasher.Items.Count; i++) { if (checkedListBoxWasher.GetItemChecked(i)) { text = checkedListBoxWasher.Items[i].ToString(); if (text.Length > 0) { char[] del = { ' ' }; words = text.Split(del); family = words[0]; name = words[1]; clPart = new CParticipant(connect, family, name); } arr.Add(clPart.stPart.idpart); } } if (arr.Count > 0) { ret.washerline = clWork.GetStringData(arr); } else { ret.washerline = null; } if (comboBoxPlace.Text.Length > 1) { clPlace = new CPlace(connect, comboBoxPlace.Text.Trim()); ret.idplace = clPlace.stPlace.id; } else { ret.idplace = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } return(ret); }