private void comboBoxProductos_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.textBoxCodigo.Text        = string.Empty;
            this.textBoxCantEtiquetas.Text = string.Empty;
            this.textBoxUniXBulto.Text     = string.Empty;
            this.labelDescripcionArt.Text  = string.Empty;

            if (this.comboBoxProductos.SelectedIndex > 0)
            {
                this.textBoxCodigo.Text = this.comboBoxProductos.SelectedValue.ToString();
                this.textBoxCantEtiquetas.Focus();
                this.labelDescripcionArt.Text = this.comboBoxProductos.Text.ToString();
                labelVto.Visible    = false;
                dateTimeVto.Visible = false;

                //VERIFICO SI ESTE ARTICULO LLEVA VTO.
                BLL.Tables.STKARTICULOS _vto = new BLL.Tables.STKARTICULOS();
                _vto.WhereParameter.Add(DAL.Tables.STKARTICULOS.ColumnEnum.articulo_id, DAL.SqlEnums.OperandEnum.Equal, textBoxCodigo.Text.ToString().Trim());
                _vto.ItemList();
                if (_vto.Resultset.Count > 0)
                {
                    bool _llevaVto = _vto.Resultset[0].LLEVAVENCIMIENTO;
                    if (_llevaVto)
                    {
                        labelVto.Visible    = true;
                        dateTimeVto.Visible = true;
                    }
                    else
                    {
                        labelVto.Visible    = false;
                        dateTimeVto.Visible = false;
                    }
                }

                //TRAIGO LA UNIDAD DE MEDIDA DE BEJERMAN
                textBoxUniMedBejerman.Text = _ItemsArticulos.Find(x => x.art_codgen.Contains(this.comboBoxProductos.SelectedValue.ToString())).unimed;
                labelDescripUniMed.Text    = _ItemsArticulos.Find(x => x.art_codgen.Contains(this.comboBoxProductos.SelectedValue.ToString())).cla_desc;
            }
        }
        private void comboBoxProductos_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxProductos.SelectedIndex != 0)
                {
                    BLL.Tables.STKARTICULOS _DescArt = new BLL.Tables.STKARTICULOS();
                    _DescArt.ItemList("EGES", this.comboBoxProductos.SelectedValue.ToString());

                    if (_DescArt.Result.Count > 0) //Verifico si tiene Algo cargado el producto
                    {
                        _updateProducto                           = 1;
                        this.textBoxTolerancia.Text               = _DescArt.Resultset[0].TOLERANCIAINGSTOCK.ToString().Replace(",", ".");
                        this.textBoxStockMinimo.Text              = _DescArt.Resultset[0].STOCKMINIMO.ToString().Replace(",", ".");
                        this.textBoxStockMaximo.Text              = _DescArt.Resultset[0].STOCKMAXIMO.ToString().Replace(",", ".");
                        comboBoxSubCuenta.SelectedValue           = _DescArt.Resultset[0].CODIGOSUBCUENTA;
                        this.comboBoxUniMedPrimaria.SelectedValue = _DescArt.Resultset[0].UNIMEDPPAL;
                        this.checkBoxNoRequerimiento.Checked      = (_DescArt.Resultset[0].MOSTRARENREQUERIMIENTO) ? false : true;
                        if (_DescArt.Resultset[0].UNIMEDSEC != null)
                        {
                            this.comboBoxUniMedSecundaria.SelectedValue = _DescArt.Resultset[0].UNIMEDSEC;
                            this.textBoxFactorConversion.Text           = _DescArt.Resultset[0].FACTORCONVERSION.ToString();
                        }


                        if (_DescArt.Resultset[0].VAASTOCK == 1)
                        {
                            this.checkBoxVa_a_Stock.Checked = true;
                        }

                        else
                        {
                            this.checkBoxVa_a_Stock.Checked = false;
                        }

                        if (_DescArt.Resultset[0].TRAZABLE)
                        {
                            this.checkBoxTrazable.Checked = true;
                        }
                        else
                        {
                            this.checkBoxTrazable.Checked = false;
                        }
                        checkBoxReceta.Checked      = (_DescArt.Resultset[0].LLEVARECETA) ? true : false;
                        checkBoxVencimiento.Checked = (_DescArt.Resultset[0].LLEVAVENCIMIENTO) ? true : false;
                    }


                    else // Vacio los campos en caso de no tener Valores
                    {
                        _updateProducto                             = 0;
                        this.textBoxTolerancia.Text                 = string.Empty;
                        this.textBoxStockMinimo.Text                = string.Empty;
                        this.textBoxStockMaximo.Text                = string.Empty;
                        this.textBoxFactorConversion.Text           = string.Empty;
                        checkBoxReceta.Checked                      = false;
                        this.checkBoxVa_a_Stock.Checked             = false;
                        this.comboBoxUniMedPrimaria.SelectedIndex   = 0;
                        this.comboBoxUniMedSecundaria.SelectedIndex = 0;
                        comboBoxSubCuenta.SelectedIndex             = 0;
                        this.checkBoxNoRequerimiento.Checked        = false;
                        this.checkBoxTrazable.Checked               = false;
                        textBoxTolerancia.Focus();
                        checkBoxVencimiento.Checked = false;
                        checkBoxReceta.Checked      = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (VerificarDatos())
                {
                    {
                        Entities.Tables.STKARTICULOS _item     = new Entities.Tables.STKARTICULOS();
                        BLL.Tables.STKARTICULOS      _articulo = new BLL.Tables.STKARTICULOS();

                        CultureInfo culture = new CultureInfo("en-US");

                        _item.CODEMP                 = "EGES";//  SIEMPRE VA CON UNA SOLA EMPRESA ****OJO NO CAMBIAR *******************    Clases.Usuario.EmpresaLogeada.EmpresaIngresada;
                        _item.ARTICULO_ID            = this.comboBoxProductos.SelectedValue.ToString();
                        _item.TOLERANCIAINGSTOCK     = (this.textBoxTolerancia.Text == string.Empty) ? 0: Convert.ToDecimal(this.textBoxTolerancia.Text, culture);
                        _item.STOCKMINIMO            = (this.textBoxStockMinimo.Text == string.Empty) ? 0: Convert.ToDecimal(this.textBoxStockMinimo.Text, culture);
                        _item.STOCKMAXIMO            = (this.textBoxStockMaximo.Text == string.Empty) ? 0: Convert.ToDecimal(this.textBoxStockMaximo.Text, culture);
                        _item.UNIMEDPPAL             = this.comboBoxUniMedPrimaria.SelectedValue.ToString();
                        _item.UNIMEDSEC              = this.comboBoxUniMedSecundaria.SelectedValue.ToString();
                        _item.CODIGOSUBCUENTA        = Convert.ToInt32(comboBoxSubCuenta.SelectedValue);
                        _item.MOSTRARENREQUERIMIENTO = (this.checkBoxNoRequerimiento.Checked) ? false : true;
                        if (this.checkBoxVa_a_Stock.Checked)
                        {
                            _item.VAASTOCK = 1;
                        }
                        else
                        {
                            _item.VAASTOCK = 0;
                        }

                        if (this.textBoxFactorConversion.Text.Trim() == string.Empty)
                        {
                            _item.FACTORCONVERSION = 0;
                        }
                        else
                        {
                            _item.FACTORCONVERSION = Convert.ToDecimal(this.textBoxFactorConversion.Text);
                        }

                        if (this.comboBoxUniMedSecundaria.SelectedIndex == 0)
                        {
                            _item.UNIMEDSEC = "0";
                        }
                        else
                        {
                            _item.UNIMEDSEC = this.comboBoxUniMedSecundaria.SelectedValue.ToString();
                        }

                        if (this.checkBoxTrazable.Checked)
                        {
                            _item.TRAZABLE = true;
                        }
                        else
                        {
                            _item.TRAZABLE = false;
                        }
                        if (checkBoxReceta.Checked)
                        {
                            _item.LLEVARECETA = true;
                        }
                        else
                        {
                            _item.LLEVARECETA = false;
                        }
                        //LLEVA VENCIMIENTO
                        if (checkBoxVencimiento.Checked)
                        {
                            _item.LLEVAVENCIMIENTO = true;
                        }
                        else
                        {
                            _item.LLEVAVENCIMIENTO = false;
                        }

                        //Actualizo los datos Ingresados Si la variable UpadteProducto es 1
                        if (_updateProducto == 1)
                        {
                            _articulo.Update(_item);
                            this.textBoxTolerancia.Text                 = string.Empty;
                            this.textBoxStockMaximo.Text                = string.Empty;
                            this.textBoxStockMinimo.Text                = string.Empty;
                            this.textBoxFactorConversion.Text           = string.Empty;
                            checkBoxReceta.Checked                      = false;
                            this.comboBoxProductos.SelectedIndex        = 0;
                            this.comboBoxCodigosProd.SelectedIndex      = 0;
                            this.checkBoxVa_a_Stock.Checked             = false;
                            this.comboBoxUniMedPrimaria.SelectedIndex   = 0;
                            this.comboBoxUniMedSecundaria.SelectedIndex = 0;
                            comboBoxSubCuenta.SelectedIndex             = 0;
                            this.checkBoxNoRequerimiento.Checked        = false;
                            this.checkBoxTrazable.Checked               = false;
                            this.checkBoxVencimiento.Checked            = false;
                            MessageBox.Show("La Operación se realizó correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            _updateProducto = 0;
                        }
                        else
                        {
                            _articulo.Add(_item);
                            this.textBoxTolerancia.Text                 = string.Empty;
                            this.textBoxStockMaximo.Text                = string.Empty;
                            this.textBoxStockMinimo.Text                = string.Empty;
                            this.textBoxFactorConversion.Text           = string.Empty;
                            checkBoxReceta.Checked                      = false;
                            this.comboBoxProductos.SelectedIndex        = 0;
                            this.comboBoxCodigosProd.SelectedIndex      = 0;
                            this.checkBoxVa_a_Stock.Checked             = false;
                            this.comboBoxUniMedPrimaria.SelectedIndex   = 0;
                            this.comboBoxUniMedSecundaria.SelectedIndex = 0;
                            comboBoxSubCuenta.SelectedIndex             = 0;
                            this.checkBoxNoRequerimiento.Checked        = false;
                            this.checkBoxTrazable.Checked               = false;
                            this.checkBoxVencimiento.Checked            = false;
                            MessageBox.Show("La Operación se realizó correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            _updateProducto = 0;
                        }
                    }
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }