Exemplo n.º 1
0
        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            int res;

            if (e.ColumnIndex == 4)
            {
                if (e.FormattedValue.ToString() == string.Empty)
                {
                    return;
                }
                else
                if (!int.TryParse(e.FormattedValue.ToString(), out res) || e.FormattedValue.ToString().Length > 10)
                {
                    dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 1;
                    MessageBox.Show("Потрібно ввести числове значення");
                    e.Cancel = true;
                    return;
                }
            }
        }
 private void JSCDataGrid1CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     try
     {
         switch (e.ColumnIndex)
         {
         case 2:
             if (e.FormattedValue.ToString() == "" || e.FormattedValue.ToString() == "0")
             {
                 jscDataGrid1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 1;
             }
             break;
         }
     }
     catch (Exception)
     {
         MessageBox.Show(@"خطا در حال اعتبارسنجی سلول", @"سامانه مدیریت سوپر مارکت");
         return;
     }
 }
Exemplo n.º 3
0
 private void sverPDataGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     try
     {
         try
         {
             FunctionUse.sverPDataGrid_CellValidating(sverPDataGrid, e, load);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             MessageBox.Show(ex.StackTrace);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemplo n.º 4
0
        private void grid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex != 0)
            {
                return;
            }

            for (int i = 0; i < grid.Rows.Count; ++i)
            {
                if (i != e.RowIndex &&
                    string.Compare(Convert.ToString(grid.Rows[i].Cells[0].Value).Trim(),
                                   Convert.ToString(e.FormattedValue).Trim()) == 0)
                {
                    e.Cancel         = true;
                    lblMessages.Text = "Another command is registered with the name \"" + e.FormattedValue + "\"";
                    Console.Beep();
                    break;
                }
            }
        }
Exemplo n.º 5
0
        private void OnCellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == cbType.Index)
            {
                switch ((CellTypeEnum)((ComboBox)dataGridView1.EditingControl).SelectedValue)
                {
                case CellTypeEnum.TextBox:
                    dataGridView1[tbValue.Index, e.RowIndex] = new DataGridViewTextBoxCell();
                    break;

                case CellTypeEnum.ComboBox:
                    dataGridView1[tbValue.Index, e.RowIndex] = new DataGridViewComboBoxCell();
                    break;

                case CellTypeEnum.Flag:
                    dataGridView1[tbValue.Index, e.RowIndex] = new DataGridViewCheckBoxCell();
                    break;
                }
            }
        }
        private void TablaIngreso_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == tablaIngreso.Columns["Cantidad"].Index)
            {
                tablaIngreso.Rows[e.RowIndex].ErrorText = "";
                int newInteger;

                if (tablaIngreso.Rows[e.RowIndex].IsNewRow)
                {
                    return;
                }
                if (!int.TryParse(e.FormattedValue.ToString(),
                                  out newInteger) || newInteger <= 0)
                {
                    SystemSounds.Beep.Play();
                    e.Cancel = true;
                    tablaIngreso.Rows[e.RowIndex].ErrorText = "El valor debe ser un entero positivo distinto de 0.";
                }
            }
        }
Exemplo n.º 7
0
    //couldn't use base.dataGridView_CellValidating as the values have to be validated per column individually
    protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
      if (dataGridView.ReadOnly) return;
      if (Content == null) return;
      if (Content.Rows == 0 || Content.Columns == 0) return;

      string errorMessage;
      if (!String.IsNullOrEmpty(e.FormattedValue.ToString())) {
        if (dataGridView.IsCurrentCellInEditMode && Content.PreprocessingData.IsFiltered) {
          errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";
        } else {
          Content.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex);
        }

        if (!String.IsNullOrEmpty(errorMessage)) {
          e.Cancel = true;
          dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
        }

      }
    }
 /// <summary>
 /// 单元格校验
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgv_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     if (e.ColumnIndex == 2) // 校验条文列
     {
         string currentCellValue = e.FormattedValue.ToString();
         if (!string.IsNullOrEmpty(currentCellValue))
         {
             List <string> list = currentCellValue.Split(ItemSplitStyles,
                                                         StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
             string errorItem = string.Empty;
             if (!IsValidedItems(list, out errorItem))
             {
                 MessageBox.Show("条文【" + errorItem + "】格式错误,请修改为正确格式", "错误",
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
                 e.Cancel = true;
                 return;
             }
         }
     }
 }
Exemplo n.º 9
0
        private void grdAttributes_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (0 <= e.ColumnIndex && e.ColumnIndex < grdAttributes.Columns.Count && 0 <= e.RowIndex && e.RowIndex < grdAttributes.Rows.Count)
            {
                var col = grdAttributes.Columns[e.ColumnIndex];
                var row = grdAttributes.Rows[e.RowIndex];

                if (col.Name == "attValue")
                {
                    var    type   = (string)row.Cells[3].Value;
                    var    value  = (string)e.FormattedValue;
                    string format = null;
                    if (!ValidateValue(type, value, out format))
                    {
                        row.ErrorText = string.Format("'{0}' is not a valid value for the type {1}. Expected format: '{2}'", value, type, format);
                        e.Cancel      = true;
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void enumDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            void SetErrorText(string text)
            {
                enumDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = text;
            }

            SetErrorText(null);

            var formattedValue = Convert.ToString(e.FormattedValue);

            if (e.ColumnIndex == 0 && !long.TryParse(formattedValue, out _))
            {
                SetErrorText($"'{formattedValue}' is not a valid value.");
            }
            else if (e.ColumnIndex == 1 && string.IsNullOrWhiteSpace(formattedValue))
            {
                SetErrorText("Empty names are not allowed.");
            }
        }
Exemplo n.º 11
0
        private void dataGridViewRouteSystems_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                string sysname = e.FormattedValue.ToString();
                var    row     = dataGridViewExplore.Rows[e.RowIndex];
                var    cell    = dataGridViewExplore[e.ColumnIndex, e.RowIndex];

                ISystem sys = SystemClassDB.GetSystem(sysname);

                if (sysname != "" && sys == null && !edsm.IsKnownSystem(sysname))
                {
                    row.ErrorText = "System not known to EDSM";
                }
                else
                {
                    row.ErrorText = "";
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Handles the CellValidating event of the dataGridView_ProjCritProdFulf control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridViewCellValidatingEventArgs"/> instance containing the event data.</param>
        /// Erstellt von Veit Berg, am 27.01.16
        private void dataGridView_ProjCritProdFulf_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            try{
                if (e.ColumnIndex == 5)
                {
                    dataGridView_ProjCritProdFulf.Rows[e.RowIndex].ErrorText = "";
                    if (CommonMethods.CheckIfForbiddenDelimiterInDb(e.FormattedValue.ToString()))
                    {
                        MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
                    }

                    {
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
Exemplo n.º 13
0
 private void InventoryItemGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     if (InventoryItemGrid.CurrentCell.ColumnIndex == InventoryItemGrid.Columns[InventoryItemGrid_ActualQuantity.Name].Index)
     {
         if (InventoryItemGrid.CurrentCell.EditedFormattedValue.ToString().AsInt() == null)
         {
             SaveInventoryItemButton.Enabled = false;
             e.Cancel = true;
         }
         else
         {
             InventoryItemGrid.CurrentCell.ErrorText = string.Empty;
             if (InventoryItemGrid.CurrentCell.Value.ToString() != InventoryItemGrid.CurrentCell.EditedFormattedValue.ToString())
             {
                 InventoryItemGrid.CurrentCell.Style.ForeColor = Color.Red;
                 IsInventoryItemChanged |= true;
             }
         }
     }
 }
        private void Grid_SplitSettings_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == COLUMNINDEX_DELAY)
            {
                if (string.IsNullOrWhiteSpace(e.FormattedValue.ToString()))
                {
                    return;
                }

                try
                {
                    TimeSpanParser.Parse(e.FormattedValue.ToString());
                }
                catch
                {
                    e.Cancel = true;
                    grid_SplitSettings.Rows[e.RowIndex].ErrorText = "Invalid Time";
                }
            }
        }
Exemplo n.º 15
0
        private void DG_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            //if (e.ColumnIndex == 0) // 1 should be your column index
            //{
            //    int i;
            //    double dblFormAmnt = 0, dblToAmnt = 0;
            //    if (DG[1, e.RowIndex].Value != null)
            //    {
            //        dblFormAmnt = Convert.ToDouble(Utility.Val(DG[0, e.RowIndex].Value.ToString()));
            //    }
            //    if (DG[1, e.RowIndex].Value != null)
            //    {
            //        dblToAmnt = Convert.ToDouble(Utility.Val(DG[1, e.RowIndex].Value.ToString()));
            //    }
            //    if (dblFormAmnt > dblToAmnt)
            //    {
            //        MessageBox.Show("f");
            //    }
            //    if (dblToAmnt > dblFormAmnt)
            //    {
            //        MessageBox.Show("c");
            //    }



            //}
            //if (e.ColumnIndex == 1) // 1 should be your column index
            //{
            //    int i;

            //    if (!int.TryParse(Convert.ToString(e.FormattedValue), out i))
            //    {
            //        e.Cancel = true;
            //        MessageBox.Show("please enter numeric");
            //    }
            //    else
            //    {
            //        // the input is numeric
            //    }
            //}
        }
Exemplo n.º 16
0
        private void dgvUrunler_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            Urun urun = (Urun)dgvUrunler.Rows[e.RowIndex].DataBoundItem;

            string mevcutDeger = dgvUrunler.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            // Mevcut hücrede değişiklik yapılmadıysa ya da yapıldıysa ancak değer aynı kaldıysa
            if (!dgvUrunler.IsCurrentCellDirty || e.FormattedValue.ToString() == mevcutDeger)
            {
                return;
            }

            if (e.ColumnIndex == 0)
            {
                if (e.FormattedValue.ToString() == "")
                {
                    MessageBox.Show("Ürün adı boş geçilemez.");
                    e.Cancel = true;
                }

                if (BaskaUrunVarMi(e.FormattedValue.ToString(), urun))
                {
                    ;
                }
                {
                    MessageBox.Show("Ürün zaten mevcut.");
                    e.Cancel = true;
                }
            }
            else if (e.ColumnIndex == 1)
            {
                decimal birimFiyat;
                bool    gecerliMi = decimal.TryParse(e.FormattedValue.ToString(), out birimFiyat);

                if (!gecerliMi || birimFiyat < 0)
                {
                    MessageBox.Show("Geçersiz fiyat.");
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 17
0
        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            int    newInteger;
            string header = dataGridView1.Columns[dataGridView1.CurrentCellAddress.X].HeaderText;

            for (int i = 0; i < Design.Properties[dataGridView1.CurrentCellAddress.X].CheckCons.Count; i++)
            {
                if (Design.Properties[dataGridView1.CurrentCellAddress.X].CheckCons[i] != "")
                {
                    string str = Design.Properties[dataGridView1.CurrentCellAddress.X].CheckCons[i].Remove(0, header.Count() + 1);
                    // check the value that written in cell
                    if (e.FormattedValue.ToString() != "")
                    {
                        if (str[0] == '>')
                        {
                            if (!int.TryParse(e.FormattedValue.ToString(), out newInteger) || newInteger < int.Parse(str.Substring(2, str.Count() - 2)))
                            {
                                dataGridView1.Rows[e.RowIndex].ErrorText = "no it's smaller than the cons";
                                e.Cancel = true;
                            }
                        }
                        else if (str[0] == '<')
                        {
                            if (!int.TryParse(e.FormattedValue.ToString(), out newInteger) || newInteger > int.Parse(str.Substring(2, str.Count() - 2)))
                            {
                                dataGridView1.Rows[e.RowIndex].ErrorText = "no it's greater than the cons";
                                e.Cancel = true;
                            }
                        }
                        else if (str[0] == '!')
                        {
                            if (!int.TryParse(e.FormattedValue.ToString(), out newInteger) || newInteger == int.Parse(str.Substring(3, str.Count() - 3)))
                            {
                                dataGridView1.Rows[e.RowIndex].ErrorText = "no it's equal";
                                e.Cancel = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        private void Grid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            CheckDataGridView();

            var grid = (DataGridView)sender;

            try
            {
                if (grid.Columns[e.ColumnIndex].Name == "_txtValue")
                {
                    var comboBoxCellOperator = (DataGridViewComboBoxCell)FilterGrid["_cboOperator", e.RowIndex];
                    if (!_operatorsWithNoValue.Contains(comboBoxCellOperator.Value))
                    {
                        grid.CurrentCell.ErrorText      = "";
                        grid.Rows[e.RowIndex].ErrorText = "";

                        var value = (string)e.FormattedValue;
                        var index = -1;
                        var comboBoxCellColumn = (DataGridViewComboBoxCell)FilterGrid["_cboColumn", e.RowIndex];
                        if (comboBoxCellColumn.Value != null)
                        {
                            index = comboBoxCellColumn.Items.IndexOf(comboBoxCellColumn.Value);
                        }

                        var errorText = CheckValue(index, value);
                        if (!string.IsNullOrEmpty(errorText))
                        {
                            errorText = "     " + errorText;                              // add 5 spaces for visibility
                            grid.CurrentCell.ErrorText      = errorText;
                            grid.Rows[e.RowIndex].ErrorText = errorText;
                            e.Cancel = true;
                        }
                    }
                }
            }
            catch
            {
                grid.CurrentCell.ErrorText = "Something is wrong!";
                e.Cancel = true;
            }
        }
Exemplo n.º 19
0
        private void gridAdmissionFeeType_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == gridAdmissionFeeType.Columns["colAmount"].Index || e.ColumnIndex == gridAdmissionFeeType.Columns["colMonthNo"].Index)
            {
                TextBox cellText = ((TextBox)gridAdmissionFeeType.EditingControl);

                if (cellText != null)
                {
                    string cellValue = cellText.Text;

                    if (e.ColumnIndex == 3)
                    {
                        if (string.IsNullOrEmpty(cellValue))
                        {
                            MessageBox.Show("Amount is required.");
                            e.Cancel = true;
                        }
                    }

                    if (e.ColumnIndex == 4)
                    {
                        if (string.IsNullOrEmpty(cellValue))
                        {
                            MessageBox.Show("Month is required.");
                            e.Cancel = true;
                        }
                        else if (Convert.ToInt32(cellValue) > 12 || Convert.ToInt32(cellValue) < 1)
                        {
                            MessageBox.Show("Month should be between 1 to 12.");
                            e.Cancel = true;
                        }
                    }
                }
            }

            //e.FormattedValue.ToString()
            // gridAdmissionFeeType.ClearSelection();
            //gridAdmissionFeeType.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true;
            //gridAdmissionFeeType.CurrentCell = gridAdmissionFeeType["colAmount", e.RowIndex];
            // cellText.Focus();
        }
Exemplo n.º 20
0
        private void resCellValidating(object sender,
                                       DataGridViewCellValidatingEventArgs e)
        {
            if (e.RowIndex < this.mResources.Length)
            {
                uint            val32;
                ulong           val64;
                DataGridViewRow row = this.resDGV.Rows[e.RowIndex];
                row.ErrorText = "";
                string str = e.FormattedValue.ToString();
                switch ((ColumnName)e.ColumnIndex)
                {
                case ColumnName.TID:
                    if (!RK.TryParseUInt32(str, out val32))
                    {
                        e.Cancel      = true;
                        row.ErrorText = "Type ID " +
                                        "must be a 32-bit unsigned integer";
                    }
                    break;

                case ColumnName.GID:
                    if (!RK.TryParseUInt32(str, out val32))
                    {
                        e.Cancel      = true;
                        row.ErrorText = "Group ID " +
                                        "must be a 32-bit unsigned integer";
                    }
                    break;

                case ColumnName.IID:
                    if (!RK.TryParseUInt64(str, out val64))
                    {
                        e.Cancel      = true;
                        row.ErrorText = "Type ID " +
                                        "must be a 64-bit unsigned integer";
                    }
                    break;
                }
            }
        }
Exemplo n.º 21
0
        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            string colText = dataGridView1.Columns[e.ColumnIndex].HeaderText;

            bool DOBError    = false;
            bool widgetError = false;

            if (colText == "DOB")
            {
                DateTime temp;
                if (!DateTime.TryParse(e.FormattedValue.ToString(), out temp))
                {
                    dataGridView1.Rows[e.RowIndex].ErrorText = "The string entered is not a valid date.";
                    e.Cancel         = true;
                    label1.ForeColor = Color.Red;
                    label1.Text      = "The string entered is not a valid date.";
                    DOBError         = true;
                }
            }
            if (colText == "NumberOfWidgets")
            {
                int testInt;
                if (!int.TryParse(e.FormattedValue.ToString(), out testInt))
                {
                    dataGridView1.Rows[e.RowIndex].ErrorText = "Content must be numeric";
                    e.Cancel         = true;
                    label1.ForeColor = Color.Red;
                    label1.Text      = "Content must be numeric";
                    widgetError      = true;
                }
            }

            if (widgetError || DOBError)
            {
                dataError = true;
            }
            else
            {
                dataError = false;
            }
        }
Exemplo n.º 22
0
        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            var selectedCells = (sender as DataGridView).SelectedCells;

            if (selectedCells.Count > 0)
            {
                try
                {
                    if (e.ColumnIndex == 0)
                    {
                        productTableAdapter.UpdateQuery(e.FormattedValue.ToString(), selectedCells[1].Value.ToString(), Convert.ToDecimal(selectedCells[3].Value), selectedCells[4].Value.ToString(), selectedCells[0].Value.ToString());
                    }
                    else if (e.ColumnIndex == 1)
                    {
                        productTableAdapter.UpdateQuery(selectedCells[0].Value.ToString(), e.FormattedValue.ToString(), Convert.ToDecimal(selectedCells[3].Value), selectedCells[4].Value.ToString(), selectedCells[0].Value.ToString());
                    }
                    else if (e.ColumnIndex == 3)
                    {
                        productTableAdapter.UpdateQuery(selectedCells[0].Value.ToString(), selectedCells[1].Value.ToString(), Convert.ToDecimal(e.FormattedValue), selectedCells[4].Value.ToString(), selectedCells[0].Value.ToString());
                    }
                    else if (e.ColumnIndex == 4)
                    {
                        productTableAdapter.UpdateQuery(selectedCells[0].Value.ToString(), selectedCells[1].Value.ToString(), Convert.ToDecimal(selectedCells[3].Value), e.FormattedValue.ToString(), selectedCells[0].Value.ToString());
                    }
                    else if (e.ColumnIndex == 2)
                    {
                        productInStockTableAdapter.UpdateQuery(selectedCells[0].Value.ToString(), Convert.ToDouble(e.FormattedValue), Convert.ToInt32(selectedCells[5].Value), selectedCells[0].Value.ToString(), Convert.ToInt32(selectedCells[5].Value));
                    }
                    else if (e.ColumnIndex == 5)
                    {
                        productInStockTableAdapter.UpdateQuery(selectedCells[0].Value.ToString(), Convert.ToDouble(selectedCells[2].Value), Convert.ToInt32(e.FormattedValue), selectedCells[0].Value.ToString(), Convert.ToInt32(selectedCells[5].Value));
                    }
                }
                catch {  }
                productInStockTableAdapter.Fill(databaseForLabDataSet.ProductInStock);
                productTableAdapter.Fill(databaseForLabDataSet.Product);
                dataGridView1.DataSource = databaseForLabDataSet.View2;
                view2TableAdapter.Fill(databaseForLabDataSet.View2);
                dataGridView1.DataSource = databaseForLabDataSet.View2.Select(expression);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tanitsuDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            //新しい行のセルでなく、セルの内容が変更されている時だけ検証する
            if (e.RowIndex == dgv.NewRowIndex || !dgv.IsCurrentCellDirty)
            {
                return;
            }

            if (dgv.Columns[e.ColumnIndex].Name == "butsuri_name" &&
                string.IsNullOrWhiteSpace(e.FormattedValue.ToString()))
            {
                dgv.Rows[e.RowIndex].Cells["butsuri_name"].ErrorText = "値が入力されていません。";
            }
            if (dgv.Columns[e.ColumnIndex].Name == "butsuri_name" &&
                !string.IsNullOrWhiteSpace(e.FormattedValue.ToString()))
            {
                dgv.Rows[e.RowIndex].Cells["butsuri_name"].ErrorText = "";
            }
            if (dgv.Columns[e.ColumnIndex].Name == "data_type" &&
                string.IsNullOrWhiteSpace(e.FormattedValue.ToString()))
            {
                dgv.Rows[e.RowIndex].Cells["data_type"].ErrorText = "値が入力されていません。";
            }
            if (dgv.Columns[e.ColumnIndex].Name == "data_type" &&
                !string.IsNullOrWhiteSpace(e.FormattedValue.ToString()))
            {
                dgv.Rows[e.RowIndex].Cells["data_type"].ErrorText = "";
            }
            if (dgv.Columns[e.ColumnIndex].Name == "data_type" &&
                !this.isCorrectDataType(e.FormattedValue.ToString()))
            {
                dgv.Rows[e.RowIndex].Cells["data_type"].ErrorText = "データ型が不正です。";
            }
            if (dgv.Columns[e.ColumnIndex].Name == "data_type" &&
                this.isCorrectDataType(e.FormattedValue.ToString()))
            {
                dgv.Rows[e.RowIndex].Cells["data_type"].ErrorText = "";
            }
        }
        //private void dtgvDs_CellClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    if (dtgvDs.SelectedRows.Count == 1)
        //    {
        //        txtMaso.Text = dtgvDs.SelectedRows[0].Cells[0].Value.ToString();
        //        txtHoTen.Text = dtgvDs.SelectedRows[0].Cells[1].Value.ToString();
        //    }
        //}

        private void dtgvDs_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            float text;

            if (GlobalVariable.GVMaSo != 0)
            {
                try
                {
                    text = Convert.ToInt32(e.FormattedValue);

                    if (text > 10)
                    {
                        dtgvDs.Rows[e.RowIndex].ErrorText = "Điểm không thể lớn hơn 10";
                        e.Cancel = true;
                    }
                }
                catch
                {
                }
            }
        }
        /// <summary>
        /// Validate the cells in Inventory.
        /// Edit is cancelled if any field is empty or color for car
        /// has already been allocated to another car
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void DataGridViewFlowers_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            DataGridView    gridView   = sender as DataGridView;
            DataGridViewRow row        = gridView.Rows[e.RowIndex];
            string          columnName = gridView.Columns[e.ColumnIndex].DataPropertyName;
            string          cellValue  = e.FormattedValue.ToString().Trim();

            // only validate if we are editing

            if (row.Cells[e.ColumnIndex].IsInEditMode == false && cellValue.Length > 0)
            {
                return;
            }

            if (cellValue.Length == 0)
            {
                MessageBox.Show("Inventory field [" + columnName + "] is missing");
                CellCancelNew(gridView, e);
                return;
            }
        }
Exemplo n.º 26
0
 private void dgvArgs_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     this.dgvArgs.Rows[e.RowIndex].ErrorText = "";
     if (e.ColumnIndex == this.clnArgs.DisplayIndex)
     {
         if ((e.FormattedValue == null) || (e.FormattedValue.ToString() == ""))
         {
             this.dgvArgs.Rows[e.RowIndex].ErrorText = "请设置参数值";
             e.Cancel = true;
         }
         else if (e.FormattedValue.ToString() != "|空值|")
         {
             BaseCondition tag = this.dgvArgs.Rows[e.RowIndex].Tag as BaseCondition;
             if ((tag != null) && this.method_1(e.FormattedValue.ToString(), tag.ValueType))
             {
                 this.dgvArgs.Rows[e.RowIndex].ErrorText = "设置参数值无效";
                 e.Cancel = true;
             }
         }
     }
 }
        private void dgvMappings_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            Guid   dummy;
            string column = dgvMappings.Columns[e.ColumnIndex].Name;

            // Abort validation if cell is not in the CompanyName column.
            if (column.Equals("clEntity"))
            {
                if (e.FormattedValue == null)
                {
                    dgvMappings.Rows[e.RowIndex].ErrorText = "Entity must not be empty";
                    e.Cancel = true;
                }
            }
            else if (!Guid.TryParse(e.FormattedValue.ToString(), out dummy))
            {
                // Check on valid GUID
                dgvMappings.Rows[e.RowIndex].ErrorText = string.Format("{0} is not a valid GUID", dgvMappings.Columns[e.ColumnIndex].HeaderText);
                e.Cancel = true;
            }
        }
Exemplo n.º 28
0
 private void cyclesGridView_CellValidating_1(object sender, DataGridViewCellValidatingEventArgs e)
 {
     if (e.ColumnIndex > 0)
     {
         string text = e.FormattedValue.ToString();
         if (!string.IsNullOrEmpty(text))
         {
             Format.WTF q = Format.ToUInt64(ref text, low: 0, high: 100000000001);
             if (q == Format.WTF.NonNumeric)
             {
                 cyclesGridView.Rows[e.RowIndex].ErrorText = "Entry must be a non-negative integer";
                 e.Cancel = true;
             }
             else if (q == Format.WTF.Range)
             {
                 cyclesGridView.Rows[e.RowIndex].ErrorText = "Entry must be >= " + 0.ToString() + " and <= " + 100000000000.ToString();
                 e.Cancel = true;
             }
         }
     }
 }
Exemplo n.º 29
0
        private void ValuesDV_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            try
            {
                if (this.Visible && e.ColumnIndex == 3)
                {
                    DataRowView source = ValuesDV.Rows[e.RowIndex].DataBoundItem as DataRowView;
                    AccessInfo  info   = (AccessInfo)source.Row[0];

                    if (IsSimpleValue(info))
                    {
                        TypeInfo.Cast(e.FormattedValue, info.TypeInfo.BuiltInType);
                    }
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
                e.Cancel = true;
            }
        }
        private void dgvLine_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            double newInteger;

            if (e.ColumnIndex == 0)
            {
                if (!double.TryParse(e.FormattedValue.ToString(), out newInteger) || newInteger < 0)
                {
                    MessageBox.Show("Invalid input number.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true;
                }

                double receivedQty = newInteger;
                double onhandQty   = dgvLine[17, e.RowIndex].Value.AsDouble();
                if (newInteger > onhandQty)
                {
                    MessageBox.Show("Issue qty. must less than or equal Balance Qty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true;
                }
            }
        }