Esempio n. 1
0
        private void dgvTovars_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (!isEditCell)
            {
                return;
            }
            Decimal decimaltest = 0;

            if (
                e.ColumnIndex == 3 &&
                (!decimal.TryParse(e.FormattedValue.ToString(), out decimaltest) ||
                 decimal.Parse(e.FormattedValue.ToString()) >= 1000000000))
            {
                MessageBox.Show("Неверно указано значение поля!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Cancel = true;
            }

            if (e.ColumnIndex == tvRcena.Index)
            {
                decimal minPrice, maxPrice, prc;
                minPrice = (decimal)dtTovars.DefaultView[e.RowIndex]["minPrice"];
                maxPrice = (decimal)dtTovars.DefaultView[e.RowIndex]["maxPrice"];
                prc      = (decimal)dtTovars.DefaultView[e.RowIndex]["prnc"];
                if (decimaltest > maxPrice || decimaltest < minPrice)
                {
                    MessageBox.Show(TempValues.centralText($"Введённая цена выходит за\nдиапазон цены, определяемой\nпроцентом наценки {prc.ToString("0.00")}%\n"), "Проверка цены", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
        }
Esempio n. 2
0
        public bool getPriceTovarWithPrcn(int id_tovar, DateTime date, decimal decimaltest)
        {
            ap.Clear();
            ap.Add(id_tovar);
            ap.Add(date);
            DataTable dtResult = executeProcedure("[spisanie].[getPriceTovarWithPrcn]",
                                                  new string[2] {
                "@id_tovar", "@date"
            },
                                                  new DbType[2] {
                DbType.Int32, DbType.Date
            }, ap);

            if (dtResult != null && dtResult.Rows.Count > 0)
            {
                decimal minPrice, maxPrice, prc;
                minPrice = (decimal)dtResult.Rows[0]["minPrice"];
                maxPrice = (decimal)dtResult.Rows[0]["maxPrice"];
                prc      = (decimal)dtResult.Rows[0]["prnc"];

                if (decimaltest > maxPrice || decimaltest < minPrice)
                {
                    MessageBox.Show(TempValues.centralText($"Введённая цена выходит за\nдиапазон цены, определяемой\nпроцентом наценки {prc.ToString("0.00")}%\n"), "Проверка цены", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    return(false);
                }
            }
            return(true);
        }