private void calcLimitesButton_Click(object sender, EventArgs e) { double volume = 0.0; try { volume = CalculateVolume(); } catch (Exception ex) { NotificationHelper.ShowError(ex.Message); return; } //if (volume.EQ(0.0)) //{ // if(NotificationHelper.AskYesNo("Об'єм закупівлі дорівнює нулю. Ви впевнені, що хочете продовжити?") == System.Windows.Forms.DialogResult.No) // { // return; // } //} if (NotificationHelper.AskYesNo("Розпочати розрахунок?") == System.Windows.Forms.DialogResult.Yes) { if (!metersList.IsEverythingReady) { if (NotificationHelper.AskYesNo( "Для деяких ЛПЗ не встановлені коефіцієнти. Встановити для них значення за-умовчанням?") == System.Windows.Forms.DialogResult.Yes) { WaitForm wf = new WaitForm(this); wf.Show(); wf.Refresh(); Enabled = false; try { metersList.PrepareNotReadyMeters(); } catch (Exception ex) { NotificationHelper.ShowError(ex.Message); } finally { wf.Close(); Enabled = true; } WriteLimitsToExcelFile(); return; } else { return; } } WriteLimitsToExcelFile(); } }
private void WaitingTask(object state) { CancellationToken token = (CancellationToken)state; if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } wf.Show(); while (!token.IsCancellationRequested) { wf.Refresh(); } wf.Close(); token.ThrowIfCancellationRequested(); }
private void saveSettingsButton_Click(object sender, EventArgs e) { if (metersList[0].GeneralCoefficient.NE(100.0)) { NotificationHelper.ShowError("Загальна сумма коефіцієнтів по закладам повинна бути рівна 100"); return; } if (CalculateCoeffsSum().NE(100.0)) { NotificationHelper.ShowError("Сумма коефіцієнтів повинная бути рівна 100"); return; } if (dataGridView1.SelectedCells.Count == 0 || ((dataGridView1.SelectedCells != null) && (dataGridView1.SelectedCells[0].RowIndex == 0))) { if (NotificationHelper.AskYesNo("Ви впевнені, що хочете встановити ці коефіцієнти для всіх ЛПЗ?") == System.Windows.Forms.DialogResult.Yes) { double[] coeffs = new double[12]; for (int i = 1; i <= 12; i++) { coeffs[i - 1] = Convert.ToDouble(Controls.Find("monthLimit" + i, true).First().Text); } WaitForm wf = new WaitForm(this); wf.Show(); wf.Refresh(); Enabled = false; try { metersList.SetDefaultCoeffs(coeffs); } catch (Exception ex) { NotificationHelper.ShowError(ex.Message); } finally { wf.Close(); Enabled = true; } } } else { if (NotificationHelper.AskYesNo( string.Format("Встановити данні коефіцієнти для {0}", metersList[dataGridView1.SelectedCells[0].RowIndex].Name) ) == System.Windows.Forms.DialogResult.Yes) { double[] coeffs = new double[12]; for (int i = 1; i <= 12; i++) { coeffs[i - 1] = Convert.ToDouble(Controls.Find("monthLimit" + i, true).First().Text); } metersList[dataGridView1.SelectedCells[0].RowIndex].MonthsCoefficients = coeffs; } } }