Пример #1
0
 private void _discountsView_Validating(object sender, CancelEventArgs e)
 {
     if (!BasePanel.HasErrors(_discountsView, true))
     {
         _product.Discounts.Clear();
         foreach (DataGridViewRow row in _discountsView.Rows)
         {
             _product.AddDiscount(new Discount(
                                      int.Parse(row.Cells["FromColumn"].Value.ToString(), CultureInfo.CurrentCulture),
                                      row.Cells["ToColumn"].Value.ToString().Equals("-") ? int.MaxValue : int.Parse(row.Cells["ToColumn"].Value.ToString(), CultureInfo.CurrentCulture),
                                      float.Parse(row.Cells["PriceColumn"].Value.ToString(), CultureInfo.CurrentCulture)));
         }
     }
     else
     {
         e.Cancel = true;
     }
 }
Пример #2
0
        private void ValidateCells(CancelEventArgs e)
        {
            for (int i = _servicesView.Rows.Count - 1; i >= 0; i--)
            {
                DataGridViewRow curRow = _servicesView.Rows[i];
                if (!curRow.IsNewRow)
                {
                    curRow.ErrorText = string.Empty;

                    string curName = curRow.Cells["ServiceNameColumn"].Value != null ? curRow.Cells["ServiceNameColumn"].Value.ToString() : string.Empty;
                    if (!string.IsNullOrEmpty(curName))
                    {
                        foreach (DataGridViewRow row in _servicesView.Rows)
                        {
                            if (row != curRow && string.IsNullOrEmpty(row.ErrorText) && curName.Equals(row.Cells["ServiceNameColumn"].Value))
                            {
                                curRow.ErrorText = RM.GetString("ServiceNameDuplicateError");
                            }
                        }
                    }
                    else
                    {
                        curRow.ErrorText = RM.GetString("ServiceNameEmptyError");
                    }
                }
            }

            if (!BasePanel.HasErrors(_servicesView, false))
            {
                if (Parent is MainForm)
                {
                    (Parent as MainForm).UpdateServiceNodes();
                }
            }
            else if (e != null)
            {
                e.Cancel = true;
            }
        }
Пример #3
0
        private void ValidateCells(CancelEventArgs e)
        {
            for (int i = _formatsView.Rows.Count - 1; i >= 0; i--)
            {
                DataGridViewRow curRow = _formatsView.Rows[i];
                if (!curRow.IsNewRow)
                {
                    curRow.ErrorText = string.Empty;
                    curRow.Cells["WidthColumn"].ErrorText  = string.Empty;
                    curRow.Cells["HeightColumn"].ErrorText = string.Empty;
                    curRow.Cells["DpiColumn"].ErrorText    = string.Empty;

                    string curName = curRow.Cells["NameColumn"].Value != null ? curRow.Cells["NameColumn"].Value.ToString() : string.Empty;
                    if (!string.IsNullOrEmpty(curName))
                    {
                        foreach (DataGridViewRow row in _formatsView.Rows)
                        {
                            if (row != curRow && string.IsNullOrEmpty(row.ErrorText) && curName.Equals(row.Cells["NameColumn"].Value))
                            {
                                curRow.ErrorText = RM.GetString("PaperFormatDuplicateError");
                            }
                        }
                    }
                    else
                    {
                        curRow.ErrorText = RM.GetString("PaperFormatEmptyError");
                    }

                    float width = 0.0f;
                    if (curRow.Cells["WidthColumn"].Value == null || !float.TryParse(curRow.Cells["WidthColumn"].Value.ToString(), out width) || width < 0)
                    {
                        curRow.Cells["WidthColumn"].ErrorText = RM.GetString("PaperWidthError");
                    }

                    float height = 0.0f;
                    if (curRow.Cells["HeightColumn"].Value == null || !float.TryParse(curRow.Cells["HeightColumn"].Value.ToString(), out height) || height < 0)
                    {
                        curRow.Cells["HeightColumn"].ErrorText = RM.GetString("PaperHeightError");
                    }

                    int dpi = 0;
                    if (curRow.Cells["DpiColumn"].Value == null || !int.TryParse(curRow.Cells["DpiColumn"].Value.ToString(), out dpi) || dpi < 0)
                    {
                        curRow.Cells["DpiColumn"].ErrorText = RM.GetString("PaperDpiError");
                    }

                    if ((width == 0 || height == 0 || dpi == 0) && (width > 0 || height > 0 || dpi > 0))
                    {
                        curRow.ErrorText = RM.GetString("FreeFormatError");
                    }
                }
            }

            if (!BasePanel.HasErrors(_formatsView, false))
            {
                if (Parent is MainForm)
                {
                    (Parent as MainForm).UpdatePriceNodes();
                }
            }
            else if (e != null)
            {
                e.Cancel = true;
            }
        }