Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                double reorderLimit;
                bool   isDoubleReorderLimit = double.TryParse(txtReorderLimit.Text, out reorderLimit);
                double replenishLimit;
                bool   isDoubleReplenish = double.TryParse(txtReplenishLimit.Text, out replenishLimit);
                double unitCost;
                bool   isDoubleCost = double.TryParse(txtUnitCost.Text, out unitCost);
                double quantity;
                bool   isDoubleQuantity = double.TryParse(txtQuantity.Text, out quantity);
                double vat;
                bool   isdoubleVat = double.TryParse(txtVat.Text, out vat);
                double discount;
                bool   isDoubleDiscount = double.TryParse(txtDiscount.Text, out discount);


                if (txtName.Text == "")
                {
                    MessageBox.Show("Invalid name.");
                }
                else if (txtBarcode.Text == "")
                {
                    MessageBox.Show("Please use the scanner to generate the barcode.");
                }
                else if (txtDescription.Text == "")
                {
                    MessageBox.Show("Invalid description.");
                }
                else if (!isDoubleCost)
                {
                    MessageBox.Show("Invalid unit cost input.");
                }
                else if (!isDoubleQuantity)
                {
                    MessageBox.Show("Invalid quantity input.");
                }
                else if (!isDoubleReorderLimit)
                {
                    MessageBox.Show("Invalid reorder limit input.");
                }
                else if (!isDoubleReplenish)
                {
                    MessageBox.Show("Invalid replenish limit input.");
                }
                else if (!isdoubleVat)
                {
                    MessageBox.Show("Invalid vat input.");
                }
                else if (!isDoubleDiscount)
                {
                    MessageBox.Show("Invalid discount input.");
                }
                else if (cmbUnitOfMeasurement.Text == "")
                {
                    MessageBox.Show("Invalid unit of measurement.");
                }
                else if (cmbCategory.Text == "")
                {
                    MessageBox.Show("Invalid category.");
                }
                else if (cmbSubCategory.Text == "")
                {
                    MessageBox.Show("Invalid sub category.");
                }
                else if (cmbSupplier.Text == "")
                {
                    MessageBox.Show("Invalid supplier.");
                }
                else if (cmbWarehouse.Text == "")
                {
                    MessageBox.Show("Invalid warehouse.");
                }
                else if (cmbStatus.Text == "")
                {
                    MessageBox.Show("Invalid status.");
                }
                else if (cmbStore.Text == "")
                {
                    MessageBox.Show("Invalid store.");
                }
                else
                {
                    pbProductImage.Image.Dispose();
                    pbBarcodeImage.Image.Dispose();

                    imageCheck();

                    ProductRepo.update(this.ProductId, txtName.Text, txtDescription.Text, txtBarcode.Text,
                                       lblBarcodeImage.Text, this.CategoryId, DateTime.Now.ToString("d"),
                                       double.Parse(txtDiscount.Text), lblProductImage.Text, double.Parse(txtQuantity.Text),
                                       double.Parse(txtReorderLimit.Text), double.Parse(txtReplenishLimit.Text), txtSku.Text,
                                       this.status, this.store, this.subcategory, this.supplier, double.Parse(txtUnitCost.Text),
                                       this.unitOfMeasurementId, double.Parse(txtVat.Text), this.warehouse, this.attributes
                                       );
                    MessageBox.Show("Product has been updated.");
                    clearAll();
                    Admin admin = new Admin();
                    admin.Show();
                    this.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error updating the product. \n" + ex.Message);
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            double reorderLimit;
            bool   isDoubleReorderLimit = double.TryParse(txtReorderLimit.Text, out reorderLimit);
            double replenishLimit;
            bool   isDoubleReplenish = double.TryParse(txtReplenishLimit.Text, out replenishLimit);
            double unitCost;
            bool   isDoubleCost = double.TryParse(txtUnitCost.Text, out unitCost);
            double quantity;
            bool   isDoubleQuantity = double.TryParse(txtQuantity.Text, out quantity);
            double vat;
            bool   isdoubleVat = double.TryParse(txtVat.Text, out vat);
            double discount;
            bool   isDoubleDiscount = double.TryParse(txtDiscount.Text, out discount);


            if (txtName.Text == "")
            {
                MessageBox.Show("Invalid name.");
            }
            else if (txtBarcode.Text == "")
            {
                MessageBox.Show("Please use the scanner to generate the barcode.");
            }
            else if (txtDescription.Text == "")
            {
                MessageBox.Show("Invalid description.");
            }
            else if (!isDoubleCost)
            {
                MessageBox.Show("Invalid unit cost input.");
            }
            else if (!isDoubleQuantity)
            {
                MessageBox.Show("Invalid quantity input.");
            }
            else if (!isDoubleReorderLimit)
            {
                MessageBox.Show("Invalid reorder limit input.");
            }
            else if (!isDoubleReplenish)
            {
                MessageBox.Show("Invalid replenish limit input.");
            }

            else if (!isdoubleVat)
            {
                MessageBox.Show("Invalid vat input.");
            }
            else if (!isDoubleDiscount)
            {
                MessageBox.Show("Invalid discount input.");
            }
            else if (cmbUnitOfMeasurement.Text == "")
            {
                MessageBox.Show("Invalid unit of measurement.");
            }
            else if (cmbCategory.Text == "")
            {
                MessageBox.Show("Invalid category.");
            }
            else if (cmbSubCategory.Text == "")
            {
                MessageBox.Show("Invalid sub category.");
            }
            else if (cmbSupplier.Text == "")
            {
                MessageBox.Show("Invalid supplier.");
            }
            else if (cmbWarehouse.Text == "")
            {
                MessageBox.Show("Invalid warehouse.");
            }
            else if (cmbStatus.Text == "")
            {
                MessageBox.Show("Invalid status.");
            }
            else if (cmbStore.Text == "")
            {
                MessageBox.Show("Invalid store.");
            }
            else
            {
                bool productExists = ProductRepo.checkIfProductNameExists(txtName.Text);
                if (productExists)
                {
                    MessageBox.Show("Product name already exists on the record, please try again.");
                }
                else
                {
                    imageCheck();
                    ProductRepo.insert(txtName.Text.ToLower(), txtDescription.Text.ToLower(), this.CategoryId, this.subcategory, unitCost,
                                       quantity, txtBarcode.Text, lblBarcodeImage.Text, txtSku.Text.ToLower(), vat,
                                       lblProductImage.Text, this.status, this.store, DateTime.Now.ToString("d"), replenishLimit,
                                       reorderLimit, discount, this.supplier, this.warehouse, this.attributes, this.unitOfMeasurementId
                                       );

                    MessageBox.Show("Product has been successfully inserted.");
                    Admin admin = new Admin();
                    admin.Show();
                    this.Hide();
                }
            }
        }