Example #1
0
 private void listaClientes_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     int index = e.RowIndex;
     editar.EditCliente editarCliente = new editar.EditCliente(this.listaClientes[index]);
     editarCliente.MdiParent = this.MdiParent;
     editarCliente.Show();
 }
Example #2
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);
            }
        }