private void textBox3_Leave(object sender, EventArgs e) //quando sai do textbox da id do cliente { dataGridView1.DataSource = null; //esvazia-se o datagrid dataGridView1.Rows.Clear(); //esvazia-se o datagrid Contas.Clear(); //esvazia-se a lista de contas do cliente a ser debitado var stringConexao = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=bd;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; SqlConnection conexao = new SqlConnection(stringConexao); conexao.Open(); SqlCommand comando = new SqlCommand("SELECT CONTAS.ID, CONTAS.TIPO, CONTAS.AGENCIA, CONTAS.CONTA, CONTAS.SALDO, CLIENTES.NOME FROM CONTAS JOIN CLIENTES ON CONTAS.IdCliente = CLIENTES.IdCliente WHERE CONTAS.IdCliente = '" + textBox3.Text.ToString() + "' ", conexao); SqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { Conta conta = new Conta(); conta.IdConta = Convert.ToInt32(reader["Id"]); conta.Tipo = reader["Tipo"].ToString(); conta.Agencia = reader["Agencia"].ToString(); conta.Numero = reader["Conta"].ToString(); conta.Saldo = Convert.ToDecimal(reader["Saldo"]); textBox4.Text = reader["Nome"].ToString(); Contas.Add(conta); } dataGridView1.DataSource = Contas; dataGridView1.Columns["IdConta"].Visible = false; dataGridView1.Columns["IdCliente"].Visible = false; textBox1.Clear(); textBox2.Clear(); textBox6.Clear(); conexao.Close(); }
private void textBox3_Leave(object sender, EventArgs e) //quando sai do textbox da id do cliente { dataGridView1.DataSource = null; //esvazia-se o datagrid dataGridView1.Rows.Clear(); //esvazia-se o datagrid Contas.Clear(); //esvazia-se a lista de contas do cliente a ser debitado SqlConnection conexao = new SqlConnection(stringConexao); conexao.Open(); SqlCommand comando = new SqlCommand("SELECT CONTAS.ID, CONTAS.TIPO, CONTAS.AGENCIA, CONTAS.CONTA, CONTAS.SALDO, CLIENTES.NOME FROM CONTAS JOIN CLIENTES ON CONTAS.IdCliente = CLIENTES.IdCliente WHERE CONTAS.IdCliente = '" + textBox3.Text.ToString() + "' ", conexao); SqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { Conta conta = new Conta(); conta.IdConta = Convert.ToInt32(reader["Id"]); conta.Tipo = reader["Tipo"].ToString(); conta.Agencia = reader["Agencia"].ToString(); conta.Numero = reader["Conta"].ToString(); conta.Saldo = Convert.ToDecimal(reader["Saldo"]); textBox4.Text = reader["Nome"].ToString(); Contas.Add(conta); } dataGridView1.DataSource = Contas; dataGridView1.Columns["IdConta"].Visible = false; dataGridView1.Columns["IdCliente"].Visible = false; textBox1.Clear(); textBox2.Clear(); textBox6.Clear(); conexao.Close(); }
public void addAccount(Account account) { Contas.Add(account); }
public void AddConta(Conta conta) { Contas.Add(conta); }