private void BtnAddClick(object sender, EventArgs e) { if (chbListOnDuty.CheckedItems.Count > 0) { var stData = new ClimatData(); DateTime dtItemDate = dtDate.Value; DateTime dtItemTime = dtTime.Value; var dt = new DateTime(dtItemDate.Year, dtItemDate.Month, dtItemDate.Day, dtItemTime.Hour, dtItemTime.Minute, 0); stData.Date = dt; stData.Index = _bEditMode ? _formParent.CurData.Index : _formParent.Workspace.NewIndex(); if (btnCalc.Enabled) BtnCalcClick(sender, e); double dblTempOut; if (!Utils.SafeParseDouble(txtPressureMM.Text, out dblTempOut)) { ShowParseError(1); return; } stData.Pressure = dblTempOut; if (!Utils.SafeParseDouble(txtResHum.Text, out dblTempOut)) { ShowParseError(2); return; } stData.Humidity = dblTempOut; if (!Utils.SafeParseDouble(txtResSat.Text, out dblTempOut)) { ShowParseError(2); return; } stData.Saturation = dblTempOut; stData.TempDry = (double)nudTempDry.Value; stData.TempWet = (double)nudTempWet.Value; stData.Ice = chbIce.Checked; if (chbTermometr.Checked) stData.TempDry = (double)nudTemp.Value; stData.WindSpeed = (double)nudWindSpeed.Value; if (chbAnemometr.Checked) stData.WindDirect = cmbWindDirect.SelectedIndex; else stData.WindDirect = -1; int i; for (i = 0; i < chbListOnDuty.CheckedItems.Count - 1; i++) stData.Duty += chbListOnDuty.CheckedItems[i] + ", "; stData.Duty += chbListOnDuty.CheckedItems[i].ToString(); _formParent.CurData = stData; DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show(@"Выберите дежурных, сделавших наблюдение.", @"Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Редактирование данных проекта. /// </summary> /// <param name="stData">Структура данных наблюдения.</param> public void EditData(ClimatData stData) { int nPos = FindItem(stData.Index); _project.StData[nPos] = stData; SortList(); }
/// <summary> /// Добавление данных в список данных проекта. /// </summary> /// <param name="stData">Структура данных наблюдения.</param> public void AddData(ClimatData stData) { _project.StData.Add(stData); SortList(); }
/// <summary> /// Редактировать данные наблюдений. /// </summary> private void EditItem() { int nIndex = int.Parse(WorkSpace.SelectedRows[0].Cells["colIndex"].Value.ToString()); _stCurData = _workspace.GetDatabyIndex(nIndex); var formAdd = new AddItemForm(this, true); if (formAdd.ShowDialog() == DialogResult.OK) { _workspace.EditData(_stCurData); ReloadData(); SaveStatusChange(true); RefreshWorkspace(); } }