示例#1
0
        public cliente leerInfoCliente(string nit)
        {
            cliente c = new cliente();

            try
            {
                conexionstring.Open();
                OleDbCommand    comando = new OleDbCommand("SELECT * FROM Clientes where NIT='" + nit + "'", conexionstring);
                OleDbDataReader lector;
                lector = comando.ExecuteReader();
                lector.Read();
                if (lector.HasRows)
                {
                    do
                    {
                        int    id        = lector.GetInt32(0);
                        string nombre    = lector.GetString(1);
                        string apellido  = lector.GetString(2);
                        string direccion = lector.GetString(3);
                        string nit1      = lector.GetString(4);
                        string telefono  = lector.GetString(5);
                        c.id        = id;
                        c.nombre    = nombre;
                        c.apellido  = apellido;
                        c.direccion = direccion;
                        c.nit       = nit1;
                        c.telefono  = telefono;
                        //MessageBox.Show("Se inserto el valor: "+lector.GetValue(1).ToString());
                    } while (lector.Read());
                }
                lector.Close();
                conexionstring.Close();
                return(c);
            }
            catch (System.Exception error)
            {
                MessageBox.Show("Ha habido un error en su conexión, intentelo más tarde" + error.Message);
                return(null);
            }
            finally
            {
                conexionstring.Close();
            }
        }
示例#2
0
 private void buscarcliente_Click(object sender, EventArgs e)
 {
     if (txtnitcotizacion.Text.Length > 0)
     {
         cliente temp = con.leerInfoCliente(txtnitcotizacion.Text);
         if (temp != null)
         {
             txtidclientecotizacion.Text = temp.id + "";
             txtnombrecotizacion.Text    = temp.nombre;
             txtapellidocotizacion.Text  = temp.apellido;
             txtdireccioncotizacion.Text = temp.direccion;
             txttelefonocotizacion.Text  = temp.telefono;
         }
     }
     else
     {
         MessageBox.Show("Por favor ingrese el nit del cliente.");
         txtnitcotizacion.Select();
     }
 }