public Boolean RegistrarBanco(entBanco Banco) { SqlCommand cmd = null; Boolean registra = false; try { SqlConnection cn = Conexion.Instancia.Conectar(); cmd = new SqlCommand("insertarBanco", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@nombre", Banco.nombre); cn.Open(); int i = cmd.ExecuteNonQuery(); if (i > 0) { registra = true; } } catch (Exception e) { throw e; } finally { cmd.Connection.Close(); } return(registra); }
public List <entBanco> ListarBanco() { SqlCommand cmd = null; List <entBanco> lista = new List <entBanco>(); try { SqlConnection cn = Conexion.Instancia.Conectar(); cmd = new SqlCommand("ListaBanco", cn); cmd.CommandType = CommandType.StoredProcedure; cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { entBanco Banco = new entBanco(); Banco.idBanco = Convert.ToInt32(dr["idBanco"]); Banco.nombre = dr["nombre"].ToString(); lista.Add(Banco); } } catch (Exception e) { throw e; } finally { cmd.Connection.Close(); } return(lista); }
private void btnsave_Click_1(object sender, EventArgs e) { entBanco b = new entBanco(); b.idBanco = int.Parse(textBoxIdBanco.Text); b.nombre = textBoxNombreBanco.Text.Trim(); logBanco.Instancia.ModificarBanco(b); ListarBanco(); }
public void ModificarBanco(entBanco Banco) { try { datBanco.Instancia.ModificarBanco(Banco); } catch (Exception e) { throw e; } }
public void RegistrarBanco(entBanco Banco) { try { datBanco.Instancia.RegistrarBanco(Banco); } catch (Exception e) { throw e; } }
private void agregarBanco_Click(object sender, EventArgs e) { try { entBanco agregar = new entBanco(); agregar.nombre = textBoxNombre.Text.Trim(); logBanco.Instancia.RegistrarBanco(agregar); this.Hide(); banco1.Show(); } catch (Exception ex) { throw ex; } }
public void ModificarBanco(entBanco Banco) { SqlCommand cmd = null; try { SqlConnection cn = Conexion.Instancia.Conectar(); cmd = new SqlCommand("modificarBanco", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@idBanco", Banco.idBanco); cmd.Parameters.AddWithValue("@nombre", Banco.nombre); cn.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { cmd.Connection.Close(); } }