public static DataResultAhorro InsertarCredito(Cliente cliente, Credito credito, DateTime fch_primerPago) { int idCliente = 0; int idcuenta = 0; DataResultAhorro Resultado = new DataResultAhorro(); idCliente = dalCliente.InsertarCliente(cliente); if (idCliente != 0) { credito.IdCliente = idCliente; idcuenta = dalCredito.InsertarCredito(credito, fch_primerPago); if (idcuenta != 0) { Resultado.Mensaje = "Credito Insertado con éxito"; Resultado.Obejto = idcuenta; } else { Resultado.Mensaje = "Error al Insertar el crrédito"; Resultado.Obejto = 0; } } else { Resultado.Mensaje = "Error al Insertar el cliente"; Resultado.Obejto = 0; } return Resultado; }
public int InsertarCredito(Credito entidad, DateTime FechaPrimerPago) { DataResultAhorro resultado = null; int idcuenta = 0; try { //Obtener DbCommand para ejcutar el Store Procedure using (DbCommand com = db.GetStoredProcCommand("AhorroVoluntario.InsertaCredito")) { //Parametros db.AddInParameter(com, "@IdCliente", DbType.Int32, entidad.IdCliente); db.AddInParameter(com, "@Capital", DbType.Decimal, entidad.Capital); db.AddInParameter(com, "@Frecuencia", DbType.String, entidad.Frecuencia); db.AddInParameter(com, "@Plazo", DbType.Int32, entidad.Plazo); db.AddInParameter(com, "@PrimerPago", DbType.DateTime, FechaPrimerPago); db.AddInParameter(com, "@IdPromotor", DbType.Int32, entidad.IdPromotor); db.AddInParameter(com, "@IdBanco", DbType.Int32, entidad.idBanco); db.AddInParameter(com, "@Clabe", DbType.String, entidad.Clabe); db.AddInParameter(com, "@idTipoCred", DbType.Int32, entidad.idTipoCredito); //Ejecucion de la Consulta using (IDataReader reader = db.ExecuteReader(com)) { if (reader != null) { resultado = new DataResultAhorro(); //Lectura de los datos del ResultSet while (reader.Read()) { if (!reader.IsDBNull(1)) idcuenta = Convert.ToInt32(reader[1]); } } reader.Close(); reader.Dispose(); } //Cierre de la conexion y liberacion de memoria com.Dispose(); return idcuenta; } } catch (Exception ex) { throw ex; } }
public void InsertarCredito(Credito entidad) { try { //Obtener DbCommand para ejcutar el Store Procedure using (DbCommand com = db.GetStoredProcCommand("NombreDelStrore")) { //Parametros //db.AddInParameter(com, "@Parametro", DbType.Tipo, entidad.Atributo); //Ejecucion de la Consulta db.ExecuteNonQuery(com); //Cierre de la conexion y liberacion de memoria com.Dispose(); } } catch (Exception ex) { throw ex; } }
public Credito ObtenerCredito( int idcuenta) { Credito resultado = null; try { //Obtener DbCommand para ejcutar el Store Procedure using (DbCommand com = db.GetStoredProcCommand("AhorroVoluntario.Sel_DetalleCredito")) { //Parametros db.AddInParameter(com, "@idcuenta", DbType.Int32, idcuenta); //Ejecucion de la Consulta using (IDataReader reader = db.ExecuteReader(com)) { if (reader != null) { resultado = new Credito(); while (reader.Read()) { if (!reader.IsDBNull(0)) resultado.Idcuenta = Convert.ToInt32(reader[0]); if (!reader.IsDBNull(1)) resultado.Capital = Convert.ToDecimal(reader[1]); if (!reader.IsDBNull(2)) resultado.Frecuencia = reader[2].ToString(); if (!reader.IsDBNull(3)) resultado.Plazo = Convert.ToInt32(reader[3]); if (!reader.IsDBNull(4)) resultado.SdoCapital = Convert.ToDecimal(reader[4]); if (!reader.IsDBNull(5)) resultado.IdEstatus = Convert.ToInt32(reader[5]); if (!reader.IsDBNull(6)) resultado.IdCliente = Convert.ToInt32(reader[6]); if (!reader.IsDBNull(7)) resultado.erogacion = Convert.ToDecimal(reader[7]); if (!reader.IsDBNull(8)) resultado.FechaCredito = Convert.ToDateTime(reader[8]); if (!reader.IsDBNull(9)) resultado.FechaEstatus = Convert.ToDateTime(reader[9]); if (!reader.IsDBNull(10)) resultado.IdPromotor = Convert.ToInt32(reader[10]); if (!reader.IsDBNull(11)) resultado.idBanco = Convert.ToInt32(reader[11]); if (!reader.IsDBNull(12)) resultado.Clabe = reader[12].ToString(); if (!reader.IsDBNull(13)) resultado.idTipoCredito = Convert.ToInt32(reader[13]); } } reader.Dispose(); } //Cierre de la conexion y liberacion de memoria com.Dispose(); } } catch (Exception ex) { throw ex; } return resultado; }
public static void InsertarCredito(Credito entidad) { dal.InsertarCredito(entidad); }
public DataResultAhorro InsertarCredito(Credito Credito, Cliente Cliente, DateTime FechaPrimerPago) { return CreditoBll.InsertarCredito(Cliente, Credito, FechaPrimerPago); }
public Credito ObtenerCredito() { Credito resultado = null; try { //Obtener DbCommand para ejcutar el Store Procedure using (DbCommand com = db.GetStoredProcCommand("NombreDelStrore")) { //Parametros //db.AddInParameter(com, "@Parametro", DbType.Tipo, entidad.Atributo); //Ejecucion de la Consulta using (IDataReader reader = db.ExecuteReader(com)) { if (reader != null) { resultado = new Credito(); //Lectura de los datos del ResultSet } reader.Dispose(); } //Cierre de la conexion y liberacion de memoria com.Dispose(); } } catch (Exception ex) { throw ex; } return resultado; }