private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                serviceDAA     = new DBControllerWSClient();
                p = serviceDAA.queryProductBySKUCode(txtProduct.Text);

                if (p.name != null)
                {
                    UpdateProductForm updateForm1 = new UpdateProductForm();
                    updateForm1.currentProduct = new product();

                    updateForm1.currentProduct = p;
                    updateForm1.SetParent(this);
                    updateForm1.ShowDialog();
                    updateDataGridView();
                }
                else
                {
                    MessageBox.Show("No existe el producto con ese elemento SKU");
                    updateDataGridView();
                }
            }
            catch
            {
                MessageBox.Show("No existe producto con ese elemento SKU no es correcta");
            }
        }
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            if (txtProductName.Text == "")
            {
                MessageBox.Show("Complete la información");
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;

                serviceDA = new DBControllerWSClient();
                String skucodee   = txtProductName.Text;
                int    idAlmacenn = int.Parse(txtWarehouseId.Text);
                detalleProducto = (serviceDA.queryWarehousedetailBySKUandWarehouseID(skucodee, idAlmacenn));

                producto = serviceDA.queryProductBySKUCode(skucodee);
                if (producto.name != null)
                {
                    dgvProducts.Rows.Clear();
                    dgvProducts.Rows.Add(new String[] {
                        "" + producto.SKUcode, producto.name, "" + producto.salePrice, "" + detalleProducto.quantity
                    });
                }
                else
                {
                    MessageBox.Show("Ingrese un código SKU válido");
                }


                Cursor.Current = Cursors.Arrow;
            }
        }
Beispiel #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!filledValues())
            {
                //MessageBox.Show("Complete la información");
            }
            else
            {
                //serviceDA = new DBControllerWSClient();
                purchase p = new purchase();
                p.state         = 1;
                p.serialCode    = txtSerialCode.Text;
                p.totalPurchase = float.Parse(txtTotal.Text);
                //para el supplier
                supplier c = new supplier();
                serviceDA  = new DBControllerWSClient();
                c          = serviceDA.querySupplierByCode(txtIdProv.Text);
                p.supplier = c;
                //para los purchase lanes
                purchaseLane[] salelanes;
                salelanes = new purchaseLane[dgvPurchaseDetails.RowCount - 1];
                for (int i = 0; i < dgvPurchaseDetails.RowCount - 1; i++)
                {
                    purchaseLane purchaselane = new purchaseLane();
                    purchaselane.subtotal = float.Parse(dgvPurchaseDetails.Rows[i].Cells[4].Value.ToString());
                    purchaselane.quantity = int.Parse(dgvPurchaseDetails.Rows[i].Cells[3].Value.ToString());
                    //purchaselane.purchase = p;
                    product pr = new product();
                    pr = serviceDA.queryProductBySKUCode(dgvPurchaseDetails.Rows[i].Cells[0].Value.ToString());
                    purchaselane.product = pr;
                    salelanes[i]         = purchaselane;
                }
                p.currency      = "Soles";
                p.purchaseLanes = salelanes;
                //Cursor.Current = Cursors.WaitCursor;
                int salio = serviceDA.insertPurchase(p);
                if (salio == 1)
                {
                    MessageBox.Show("Se ingresó la compra correctamente");
                }
                else
                {
                    MessageBox.Show("¡Hubo un problema!");
                }
                //Cursor.Current = Cursors.Arrow;

                this.Close();
            }
        }
        private void btnUpdateProduct_Click(object sender, EventArgs e)
        {
            int i = dgvProducts.CurrentCell.RowIndex;

            if (i >= 0)
            {
                UpdateProductForm updateForm1 = new UpdateProductForm();
                updateForm1.currentProduct = new product();
                product e1 = new product();
                e1 = serviceDAA.queryProductBySKUCode(dgvProducts.Rows[i].Cells[0].Value.ToString());
                updateForm1.currentProduct = e1;
                updateForm1.ShowDialog();
                updateDataGridView();
            }
            else
            {
                MessageBox.Show("Seleccione un producto");
            }
        }
        private bool filledValues()
        {
            if (txtSKUCode.Text == "" || txtSKUCode.Text.Length != 8)
            {
                MessageBox.Show("Ingrese un código válido. Los códigos SKU tienen 8 caracteres");
                return(false);
            }
            else if (txtName.Text == "" || txtName.Text.Length < 2)
            {
                MessageBox.Show("Ingrese el nombre del producto");
                return(false);
            }
            else if (txtDescription.Text == "")
            {
                MessageBox.Show("Ingrese la descripción del producto");
                return(false);
            }
            else if (txtCareDescription.Text == "")
            {
                MessageBox.Show("Ingrese la descripción del cuidado del producto");
                return(false);
            }
            else if (txtSalePrice.Text == "")
            {
                MessageBox.Show("Ingrese el precio de venta");
                return(false);
            }
            else if (txtPurchasePrice.Text == "")
            {
                MessageBox.Show("Ingrese el precio de compra");
                return(false);
            }
            else if (txtIGV.Text == "")
            {
                MessageBox.Show("Ingrese el IGV");
                return(false);
            }
            else if (txtStock.Text == "")
            {
                MessageBox.Show("Ingrese el stock");
                return(false);
            }
            else if (cboBrand.Text == "--Seleccione--")
            {
                MessageBox.Show("Seleccione la marca");
                return(false);
            }
            else if (cboFamily.Text == "--Seleccione--")
            {
                MessageBox.Show("Seleccione la familia");
                return(false);
            }
            else if (cboDiscount.Text == "--Seleccione--")
            {
                MessageBox.Show("Seleccione el descuento");
                return(false);
            }
            Cursor.Current = Cursors.WaitCursor;
            serviceDA      = new DBControllerWSClient();
            product p = serviceDA.queryProductBySKUCode(txtSKUCode.Text);

            Cursor.Current = Cursors.Arrow;
            if (p.SKUcode != null)
            {
                MessageBox.Show("Ya existe un producto con ese código SKU");
                return(false);
            }
            return(true);
        }