Example #1
0
        private void txtRecibo_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            if (string.IsNullOrEmpty(txtRecibo.Text) || string.IsNullOrWhiteSpace(txtRecibo.Text))
            {
                return;
            }

            string sCve  = txtRecibo.Text.ToString().Trim();
            string sTipo = string.Empty;

            if (sCve.IndexOf("REC") != -1)
            {
                sTipo = "R";
            }
            if (sCve.IndexOf("ORD") != -1)
            {
                sTipo = "O";
            }


            try
            {
                ReciboLogica rec = new ReciboLogica();
                rec.Recibo = sCve;
                DataTable dt = new DataTable();
                if (sTipo == "R")
                {
                    dt = ReciboLogica.ConsultaRecibo(rec);
                }
                else
                {
                    rec.Orden = sCve;
                    dt        = ReciboLogica.ConsultaOrden(rec);
                }


                if (dt.Rows.Count > 0)
                {
                    cbbbArticulo.DataSource    = dt;
                    cbbbArticulo.ValueMember   = "no_art";
                    cbbbArticulo.DisplayMember = "no_art";
                    cbbbArticulo.SelectedIndex = -1;
                }
                else
                {
                    //buscar dentro de Innova
                    InnovaLogica inn = new InnovaLogica();
                    inn.Recibo = sCve;
                    if (sTipo == "R")
                    {
                        dt = InnovaLogica.ConsultaRecibo(inn);
                    }
                    else
                    {
                        inn.Orden = sCve;
                        dt        = InnovaLogica.ConsultaOrden(inn);
                    }


                    if (dt.Rows.Count > 0)
                    {
                        cbbbArticulo.DataSource    = dt;
                        cbbbArticulo.ValueMember   = "no_art";
                        cbbbArticulo.DisplayMember = "no_art";
                        cbbbArticulo.SelectedIndex = -1;
                    }
                    else
                    {
                        MessageBox.Show("No se encontro el documento", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtRecibo.Clear();
                        txtRecibo.Focus();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error." + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtRecibo.Clear();
                txtRecibo.Focus();
                return;
            }


            cbbbArticulo.Focus();
        }