Esempio n. 1
0
        private void Buscar_Click(object sender, EventArgs e)
        {
            if (rut_p.Text.Length > 0 && rutd_p.Text.Length > 0 && nfactura_p.Text.Length > 0)
            {
                SqlConnection con = new SqlConnection("Server=localhost; database=INVERSEC_3; integrated security=yes");
                try
                {
                    SqlCommand comando = new SqlCommand("SELECT * FROM FACTURA WHERE numero_fact=@n AND guia=@guia AND rut_pro=@rut", con);
                    comando.Parameters.Add("@rut", SqlDbType.VarChar);
                    comando.Parameters["@rut"].Value = rut_p.Text + "-" + rutd_p.Text;
                    comando.Parameters.Add("@guia", SqlDbType.VarChar);
                    comando.Parameters["@guia"].Value = "Guia";
                    comando.Parameters.Add("@n", SqlDbType.Int);
                    comando.Parameters["@n"].Value = nfactura_p.Text;

                    da = new SqlDataAdapter(comando);

                    da.Fill(dt);

                    if (dt.Rows.Count > 0)
                    {
                        g = new GuiasG();
                        g.rut = rut_p.Text + "-" + rutd_p.Text;
                        g.numerof = Convert.ToInt32(nfactura_p.Text);
                        this.AddOwnedForm(g);
                        this.Hide();
                        g.Show();
                    }
                    else
                    {
                        MessageBox.Show("No se encontro la guia");
                    }
                    con.Close();

                }
                catch (Exception ev)
                {
                    MessageBox.Show("Error: " + ev.ToString());
                }
            }
            else
            {
                MessageBox.Show("Debe ingresar número de factura y rut de la empresa");
            }
        }
Esempio n. 2
0
        private void Buscar_Click(object sender, EventArgs e)
        {
            if (rut_p.Text.Length > 0 && rutd_p.Text.Length > 0 && nfactura_p.Text.Length > 0)
            {
                SqlConnection con = new SqlConnection("Server=localhost; database=INVERSEC_3; integrated security=yes");
                try
                {
                    SqlCommand comando = new SqlCommand("SELECT * FROM FACTURA WHERE numero_fact=@n AND guia=@guia AND rut_pro=@rut", con);
                    comando.Parameters.Add("@rut", SqlDbType.VarChar);
                    comando.Parameters["@rut"].Value = rut_p.Text + "-" + rutd_p.Text;
                    comando.Parameters.Add("@guia", SqlDbType.VarChar);
                    comando.Parameters["@guia"].Value = "Guia";
                    comando.Parameters.Add("@n", SqlDbType.Int);
                    comando.Parameters["@n"].Value = nfactura_p.Text;

                    da = new SqlDataAdapter(comando);

                    da.Fill(dt);

                    if (dt.Rows.Count > 0)
                    {
                        g         = new GuiasG();
                        g.rut     = rut_p.Text + "-" + rutd_p.Text;
                        g.numerof = Convert.ToInt32(nfactura_p.Text);
                        this.AddOwnedForm(g);
                        this.Hide();
                        g.Show();
                    }
                    else
                    {
                        MessageBox.Show("No se encontro la guia");
                    }
                    con.Close();
                }
                catch (Exception ev)
                {
                    MessageBox.Show("Error: " + ev.ToString());
                }
            }
            else
            {
                MessageBox.Show("Debe ingresar número de factura y rut de la empresa");
            }
        }