private void dgTariffView_CellValidating(object sender, System.Windows.Forms.DataGridViewCellValidatingEventArgs e) { try { if ((this.dgTariffView.Columns.get_Item(e.get_ColumnIndex()) == this.NewRateDataGridViewTextBoxColumn) && (((string) e.get_FormattedValue()) != string.Empty)) { decimal.Parse((string) ((string) e.get_FormattedValue())); } } catch (System.Exception exception) { Messages.ShowException(this, exception); e.set_Cancel(true); } }
private void dgvNotes_CellValidating(object sender, System.Windows.Forms.DataGridViewCellValidatingEventArgs e) { try { if (this.dgvNotes.Columns.get_Item(e.get_ColumnIndex()) == this.serviceCodeDataGridViewTextBoxColumn) { if (((string) e.get_FormattedValue()) != string.Empty) { int.Parse((string) ((string) e.get_FormattedValue())); } } else if (((this.dgvNotes.Columns.get_Item(e.get_ColumnIndex()) == this.counterIndDataGridViewTextBoxColumn) || (this.dgvNotes.Columns.get_Item(e.get_ColumnIndex()) == this.paidSummDataGridViewTextBoxColumn)) && ((((string) e.get_FormattedValue()) != string.Empty) && (decimal.Parse((string) ((string) e.get_FormattedValue())) < 0M))) { Messages.ShowMessage("Введите неотрицательное число"); e.set_Cancel(true); } } catch (System.Exception exception) { Messages.ShowException(this, exception); e.set_Cancel(true); } }
private void dgvTargetAccountServices_CellValidating(object sender, System.Windows.Forms.DataGridViewCellValidatingEventArgs e) { if (e.get_ColumnIndex() == this.dgvTargetAccountServices.Columns.get_Item("Summ").get_Index()) { decimal num; string str = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.get_NumberDecimalSeparator(); if (!decimal.TryParse(((string) e.get_FormattedValue()).Replace(".", str).Replace(",", str), ref num)) { e.set_Cancel(true); Messages.ShowWarning("Введенная сумма не является числом! Для отмены ввода нажмите ESCAPE."); } if (num < 0M) { e.set_Cancel(true); Messages.ShowWarning("Введенная сумма должна быть положительной! Для отмены ввода нажмите ESCAPE."); } } }
private void m_Grid_CellValidating(object sender, System.Windows.Forms.DataGridViewCellValidatingEventArgs e) { try { if (this.m_Grid.Columns.get_Item(e.get_ColumnIndex()) == this.fromDateDataGridViewTextBoxColumn) { if (((string) e.get_FormattedValue()) != string.Empty) { System.DateTime.Parse((string) ((string) e.get_FormattedValue())); } } else if (((this.m_Grid.Columns.get_Item(e.get_ColumnIndex()) == this.chargeSummDataGridViewTextBoxColumn) && this.chbxValidateNegativeSumm.get_Checked()) && (decimal.Parse((string) ((string) e.get_FormattedValue())) < 0M)) { Messages.ShowMessage("Ввод отрицательной суммы ограничен!"); e.set_Cancel(true); } } catch (System.Exception exception) { Messages.ShowException(this, exception); e.set_Cancel(true); } }
private void dgvServices_CellValidating(object sender, System.Windows.Forms.DataGridViewCellValidatingEventArgs e) { try { if ((this.dgvServices.Columns.get_Item(e.get_ColumnIndex()) == this.CurrentRateFromDate) || (this.dgvServices.Columns.get_Item(e.get_ColumnIndex()) == this.ServiceNormFromDate)) { if (((string) e.get_FormattedValue()) != string.Empty) { System.DateTime.Parse((string) ((string) e.get_FormattedValue())); } else { this.dgvServices.Rows.get_Item(e.get_RowIndex()).Cells.get_Item(e.get_ColumnIndex()).set_Value(Constants.NullDate); ServiceOld old = (ServiceOld) this.dgvServices.Rows.get_Item(e.get_RowIndex()).get_DataBoundItem(); if (this.dgvServices.Columns.get_Item(e.get_ColumnIndex()) == this.CurrentRateFromDate) { old.CurrentRateFromDate = Constants.NullDate; old.CurrentRate = 0M; } if (this.dgvServices.Columns.get_Item(e.get_ColumnIndex()) == this.ServiceNormFromDate) { old.ServiceNormFromDate = Constants.NullDate; old.ServiceNormRate = 0M; } this.bsServices.ResumeBinding(); } } else if (((this.dgvServices.Columns.get_Item(e.get_ColumnIndex()) == this.CurrentRate) || (this.dgvServices.Columns.get_Item(e.get_ColumnIndex()) == this.ServiceNormRate)) && (((string) e.get_FormattedValue()) != string.Empty)) { decimal.Parse((string) ((string) e.get_FormattedValue())); } } catch (System.Exception exception) { Messages.ShowException(this, exception); e.set_Cancel(true); } }