Ejemplo n.º 1
0
        private Product GetProductInfo(ref DataGridViewRow currentRow)
        {
            ProductEntitiesIDsVM productViewModel = new ProductEntitiesIDsVM()
            {
                ProductID   = productController.GetProductIdByName(currentRow.Cells["Наименование"].Value.ToString()),
                CategoryID  = categoryController.GetCategoryIdByName(currentRow.Cells["Категория"].Value.ToString()),
                TrademarkID = trademarkController.GetTrademarkIdByName(currentRow.Cells["Бренд"].Value.ToString())
            };

            if (GetInfoHandleNotOK(productViewModel))
            {
                return(null);
            }

            Product product = new Product
            {
                ID          = (int)currentRow.Cells["ID"].Value,
                Name        = currentRow.Cells["Наименование"].Value.ToString(),
                Amount      = (int)currentRow.Cells["Кол-во на складе"].Value,
                Unit        = currentRow.Cells["Ед.изм."].Value.ToString(),
                Cost        = (decimal)currentRow.Cells["Стоимость"].Value,
                Description = currentRow.Cells["Описание"].Value.ToString(),
                CategoryID  = productViewModel.CategoryID,
                TrademarkID = productViewModel.TrademarkID
            };

            if (CellsIsNull(product))
            {
                MessageBox.Show("Заполните все поля!");
                return(null);
            }

            return(product);
        }
Ejemplo n.º 2
0
        private bool GetInfoHandleNotOK(ProductEntitiesIDsVM productViewModel)
        {
            bool handleNotOK = false;
            int  categoryId  = productViewModel.CategoryID;
            int  trademarkId = productViewModel.TrademarkID;

            if (categoryId == 0)
            {
                MessageBox.Show("Категория не найдена", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                handleNotOK = true;
                return(handleNotOK);
            }
            if (trademarkId == 0)
            {
                MessageBox.Show("Бренд не найден", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                handleNotOK = true;
                return(handleNotOK);
            }

            return(handleNotOK);
        }