Exemplo n.º 1
0
 private void searchProduct()
 {
     if (!(this.SearchTxt.Text != ""))
     {
         return;
     }
     if (!this.isNumber(this.SearchTxt.Text))
     {
         DataTable table = Producto.SearchValueGetTable(this.SearchTxt.Text);
         if (table.Rows.Count == 0)
         {
             int num = (int)MessageBox.Show("No se encontraron coincidencias");
             this.SearchTxt.Select();
         }
         else if (table.Rows.Count == 1)
         {
             this.product = new Producto(table.Rows[0]["Código de Barras"].ToString());
             this.setProduct();
         }
         else
         {
             ChooseProductForm chooseProductForm = new ChooseProductForm(table);
             if (chooseProductForm.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             this.product = new Producto(chooseProductForm.selectedItem[0]);
             this.setProduct();
         }
     }
     else
     {
         Producto producto = new Producto(this.SearchTxt.Text);
         if (producto.Description == null)
         {
             int num = (int)MessageBox.Show("No se encontraron coincidencias");
             this.SearchTxt.Select();
         }
         else
         {
             this.product = producto;
             this.setProduct();
         }
     }
 }
        private void showNextPanel()
        {
            if (!isNumber(BarCodeTxt.Text))
            {
                var supplier = new Proveedor(SupplierID);
                var results  = supplier.searchForNewProduct(BarCodeTxt.Text);

                if (results.Rows.Count == 1)
                {
                    if (supplier.getProductInfo(BarCodeTxt.Text).Rows.Count == 0 || editingMode)
                    {
                        barcode = results.Rows[0]["código de barras"].ToString();
                        var p = checkformainproduct(barcode);
                        barcode = p.Barcode;
                        if (supplier.getProductInfo(barcode).Rows.Count > 0)
                        {
                            MessageBox.Show("El producto ya se encuentra registrado para este proveedor");
                            return;
                        }

                        BarCodeTxt.Text     = barcode;
                        descriptionLbl.Text = p.Description;
                        MarcaLbl.Text       = p.Brand;
                        StockLbl.Text       = p.CurrentStock.ToString("n2");
                        MinStockLbl.Text    = p.minStock.ToString("n2");
                        this.NextButton.Hide();
                        this.Height = 540;
                        this.panel.Show();
                        this.CenterToScreen();
                        precioTxt.Select();
                        precioTxt.Focus();
                    }
                    else
                    {
                        var barcode = Producto.SearchValueGetTable(BarCodeTxt.Text);
                        if (barcode.Rows.Count == 0)
                        {
                            MessageBox.Show("No se encontraron productos");
                        }
                        else
                        {
                            MessageBox.Show("El producto ya se encuentra registrado para este proveedor");
                        }
                    }
                }
                else if (results.Rows.Count > 1)
                {
                    ChooseProductForm form = new ChooseProductForm(results);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        barcode = form.selectedItem[0];
                        var p = checkformainproduct(barcode);
                        barcode = p.Barcode;

                        if (supplier.getProductInfo(barcode).Rows.Count > 0)
                        {
                            MessageBox.Show("El producto ya se encuentra registrado para este proveedor");
                            return;
                        }

                        BarCodeTxt.Text     = p.Barcode;
                        descriptionLbl.Text = p.Description;
                        MarcaLbl.Text       = p.Brand;
                        StockLbl.Text       = p.CurrentStock.ToString("n2");
                        MinStockLbl.Text    = p.minStock.ToString("n2");
                        precioTxt.Select();

                        this.NextButton.Hide();
                        this.Height = 540;
                        this.panel.Show();
                        this.CenterToScreen();
                    }
                }
                else
                {
                    var barcode = Producto.SearchValueGetTable(BarCodeTxt.Text);
                    if (barcode.Rows.Count == 0)
                    {
                        if (Producto.SearchProduct(BarCodeTxt.Text) && checkformainproduct(BarCodeTxt.Text).Barcode == BarCodeTxt.Text)
                        {
                            MessageBox.Show("El producto principal ya se encuentra registrado para este proveedor");
                        }
                        else
                        {
                            MessageBox.Show("No se encontraron productos");
                        }
                    }
                    else
                    {
                        MessageBox.Show("El producto ya se encuentra registrado para este proveedor");
                    }
                    BarCodeTxt.Text = "";
                }
            }
            else
            {
                if (Producto.SearchProduct(BarCodeTxt.Text) && new Proveedor(SupplierID).getProductInfo(BarCodeTxt.Text).Rows.Count == 0 || editingMode)
                {
                    barcode = BarCodeTxt.Text;
                    var p = checkformainproduct(barcode);
                    barcode = p.Barcode;
                    if (!editingMode && new Proveedor(SupplierID).getProductInfo(barcode).Rows.Count > 0)
                    {
                        MessageBox.Show("El producto ya se encuentra registrado para este proveedor");
                        return;
                    }
                    BarCodeTxt.Text     = barcode;
                    descriptionLbl.Text = p.Description;
                    MarcaLbl.Text       = p.Brand;
                    StockLbl.Text       = p.CurrentStock.ToString("n2");
                    MinStockLbl.Text    = p.minStock.ToString("n2");
                    this.NextButton.Hide();
                    this.Height = 540;
                    this.panel.Show();
                    this.CenterToScreen();
                    precioTxt.Focus();
                    precioTxt.Select();
                }
                else
                {
                    var barcode = Producto.SearchValueGetTable(BarCodeTxt.Text);
                    if (barcode.Rows.Count == 0)
                    {
                        if (Producto.SearchProduct(BarCodeTxt.Text) && checkformainproduct(BarCodeTxt.Text).Barcode == BarCodeTxt.Text)
                        {
                            MessageBox.Show("El producto principal ya se encuentra registrado para este proveedor");
                        }

                        else
                        {
                            MessageBox.Show("No se encontraron productos");
                        }
                    }
                    else
                    {
                        MessageBox.Show("El producto ya se encuentra registrado para este proveedor");
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void ProductTxt_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode != Keys.Return || !(this.ProductTxt.Text != ""))
     {
         return;
     }
     if (!this.isNumber(this.ProductTxt.Text))
     {
         DataTable table = Producto.SearchValueGetTable(this.ProductTxt.Text);
         if (table.Rows.Count == 0)
         {
             MessageBox.Show("No se encontró el producto", "Sin coincidencias", MessageBoxButtons.OK);
         }
         else if (table.Rows.Count == 1)
         {
             this.product = new Producto(table.Rows[0]["Código de Barras"].ToString());
             this.setReceiverDepotCard();
             if (this.donatingDepot == null || this.receiverDepot == null)
             {
                 return;
             }
             this.transferCount = 0;
             this.setDonatingDepotCard();
             textBox1.Select();
         }
         else
         {
             DarkForm          darkForm          = new DarkForm();
             ChooseProductForm chooseProductForm = new ChooseProductForm(table);
             darkForm.Show();
             if (chooseProductForm.ShowDialog() == DialogResult.OK)
             {
                 this.product = new Producto(chooseProductForm.selectedItem[0]);
                 this.setReceiverDepotCard();
                 if (this.donatingDepot != null && this.receiverDepot != null)
                 {
                     this.transferCount = 0;
                     this.setDonatingDepotCard();
                 }
                 textBox1.Select();
             }
             darkForm.Close();
         }
     }
     else
     {
         Producto producto = new Producto(this.ProductTxt.Text);
         if (producto.Description == null)
         {
             MessageBox.Show("No se encontró el producto", "Sin coincidencias", MessageBoxButtons.OK);
         }
         else
         {
             this.product = producto;
             this.setReceiverDepotCard();
             if (this.donatingDepot == null || this.receiverDepot == null)
             {
                 return;
             }
             this.transferCount = 0;
             this.setDonatingDepotCard();
         }
     }
 }
Exemplo n.º 4
0
        private void addProductToRow(object sender, EventArgs e)
        {
            var control     = sender as Control;
            int rowIndex    = Convert.ToInt32(control.Name.Substring(control.Name.IndexOf("_") + 1));
            var productText = (tableLayoutPanel1.GetControlFromPosition(1, rowIndex) as TextBox);
            var barcode     = tableLayoutPanel1.GetControlFromPosition(1, rowIndex).Text.Trim();
            var amount      = tableLayoutPanel1.GetControlFromPosition(2, rowIndex).Text.Trim();

            if (barcode == "" || amount == "")
            {
                return;
            }
            if (checkForDuplicates(barcode))
            {
                MessageBox.Show("Ya se encuentra este producto en la lista.");
                return;
            }

            Producto p = isNumber(barcode) && Producto.SearchProduct(barcode) ? new Producto(barcode) : null;

            if (p == null)
            {
                DataTable dt = Producto.SearchValueGetTable(barcode);

                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("No se encontró el producto");
                    productText.Focus();
                    productText.SelectAll();
                    return;
                }
                else if (dt.Rows.Count == 1)
                {
                    p = new Producto(dt.Rows[0]["Código de Barras"].ToString());
                }
                else
                {
                    ChooseProductForm choose = new ChooseProductForm(dt);
                    DarkForm          dk     = new DarkForm();

                    dk.Show();
                    if (choose.ShowDialog() == DialogResult.OK)
                    {
                        p = new Producto(choose.selectedItem[0]);
                    }
                    else
                    {
                        return;
                    }
                }
            }

            productText.Name = p.Barcode + "_" + rowIndex.ToString();
            productText.Dock = DockStyle.Fill;

            var amountTxt = tableLayoutPanel1.GetControlFromPosition(2, rowIndex) as TextBox;

            try { double d = Convert.ToDouble(amount); }
            catch (FormatException)
            {
                MessageBox.Show("La Cantidad no tiene el formato adecuado");
                amountTxt.Focus();
                amountTxt.SelectAll();
                return;
            }

            amountTxt.Enabled = false;
            amountTxt.Dock    = DockStyle.Fill;

            productText.Enabled = false;
            productText.Text    = string.Format("{0}, {1}", p.Description, p.Brand);

            tableLayoutPanel1.Controls.RemoveByKey("addProduct_" + rowIndex.ToString());

            tableLayoutPanel1.Controls.Add(new Bunifu.Framework.UI.BunifuImageButton()
            {
                BackColor = Color.Transparent,
                Image     = Properties.Resources.close,
                Size      = new Size(25, 25),
                Anchor    = AnchorStyles.None,
                Name      = "removeProductBtn_" + rowIndex.ToString()
            }, 0, rowIndex);;

            var removeBtn = tableLayoutPanel1.GetControlFromPosition(0, rowIndex) as Bunifu.Framework.UI.BunifuImageButton;

            removeBtn.Click += new EventHandler(removeBtn_click);
            newRow();
        }