示例#1
0
        private void btn_procurar_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = null;

            try
            {
                conn = Conexao.getConexao();
                MySqlCommand cmd = new MySqlCommand("select distinct * from cliente where cpf = @cpf", conn);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@cpf", this.txt_cpf.Text);

                MySqlDataReader rs = cmd.ExecuteReader();
                rs.Read();

                if (rs.HasRows)
                {
                    model.Cliente cliente = new model.Cliente(rs);
                    conn.Close();
                    editar.EditCliente editCliente = new editar.EditCliente(cliente);
                    editCliente.MdiParent = this.MdiParent;
                    editCliente.Show();
                    this.Close();
                }
                else
                {
                    conn.Close();
                    new ErrorDialog("Cliente não encontrado!");
                }
            }
            catch (Exception err)
            {
                if (conn != null) conn.Close();
                new ErrorDialog(err.Message);
            }
        }
示例#2
0
        public Cliente getClientePorRut(String rut)
        {
            Cliente c = null;

            query = "select*from cliente where rut='" + rut + "'";
            conexion.ejecutar(query);

            if (conexion.rs.Read())
            {
                c     = new model.Cliente();
                c.Rut = conexion.rs[1].ToString();
            }

            conexion.cerrar();
            return(c);
        }