예제 #1
0
        private void txt_Codigo_TextChanged(object sender, EventArgs e)
        {
            string Codigo = txt_Codigo.Text;
            cJoya  joya   = new cJoya();

            if (Codigo.Length > 2)
            {
                DataTable trdo = joya.GetJoyaxCodigo(Codigo);
                if (trdo.Rows.Count > 0)
                {
                    txt_Codigo.Text      = trdo.Rows[0]["Codigo"].ToString();
                    txtCodigo.Text       = trdo.Rows[0]["CodJoya"].ToString();
                    txt_Nombre.Text      = trdo.Rows[0]["Nombre"].ToString();
                    txt_Stock.Text       = trdo.Rows[0]["Stock"].ToString();
                    txt_PrecioVenta.Text = trdo.Rows[0]["PrecioVenta"].ToString();
                    if (trdo.Rows[0]["CodTipo"].ToString() != "")
                    {
                        {
                            cmb_CodTipo.SelectedValue = trdo.Rows[0]["CodTipo"].ToString();
                        }

                        if (txt_PrecioVenta.Text != "")
                        {
                            cFunciones fun         = new cFunciones();
                            Double     PrecioVenta = Convert.ToDouble(txt_PrecioVenta.Text.Replace(".", ","));
                            txt_PrecioVenta.Text = Math.Round(PrecioVenta, 0).ToString();
                            txt_PrecioVenta.Text = fun.SepararDecimales(txt_PrecioVenta.Text);
                            txt_PrecioVenta.Text = fun.FormatoEnteroMiles(txt_PrecioVenta.Text);
                        }
                    }
                }
            }
        }
        private void txtCodigo_TextChanged(object sender, EventArgs e)
        {
            string Codigo = txtCodigo.Text;
            int    b      = 0;

            if (Codigo.Length > 3)
            {
                cJoya     joya = new cJoya();
                DataTable trdo = joya.GetJoyaxCodigo(Codigo);
                if (trdo.Rows.Count > 0)
                {
                    if (trdo.Rows[0]["CodJoya"].ToString() != "")
                    {
                        b = 1;
                        txtCodJoya.Text    = trdo.Rows[0]["CodJoya"].ToString();
                        txtNombreJoya.Text = trdo.Rows[0]["Nombre"].ToString();
                        txtStock.Text      = trdo.Rows[0]["Stock"].ToString();
                        txtPrecio.Text     = trdo.Rows[0]["PrecioVenta"].ToString();
                        if (trdo.Rows[0]["CodTipo"].ToString() != "")
                        {
                            cmbTipo.SelectedValue = trdo.Rows[0]["CodTipo"].ToString();
                        }
                        if (txtPrecio.Text != "")
                        {
                            txtPrecio.Text = fun.SepararDecimales(txtPrecio.Text);
                            txtPrecio.Text = fun.FormatoEnteroMiles(txtPrecio.Text);
                        }
                        txtCodigoBarra.Text = trdo.Rows[0]["CodigoBarra"].ToString();
                    }
                }
            }
            if (b == 0)
            {
                txtCodJoya.Text    = "";
                txtNombreJoya.Text = "";
                txtStock.Text      = "";
                if (cmbTipo.Items.Count > 0)
                {
                    cmbTipo.SelectedIndex = 0;
                }
            }
        }