public void InsertarTBCreditos(TBCreditos 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 List<TBCreditos> ObtenerTBCreditos(int Accion, int Cuenta) { List<TBCreditos> resultado = null; try { //Obtener DbCommand para ejcutar el Store Procedure using (DbCommand com = db.GetStoredProcCommand("Creditos.Sel_Credito")) { //Parametros db.AddInParameter(com, "@Accion", DbType.Int32, Accion); db.AddInParameter(com, "@Cuenta", DbType.Int32, Cuenta); //Ejecucion de la Consulta using (IDataReader reader = db.ExecuteReader(com)) { if (reader != null) { resultado = new List<TBCreditos>(); //Lectura de los datos del ResultSet while(reader.Read()) { TBCreditos Credito = new TBCreditos(); if (!reader.IsDBNull(0)) Credito.IdCuenta = Convert.ToInt32(reader[0]); if (!reader.IsDBNull(1)) Credito.FchCredito = Convert.ToDateTime(reader[1]); if (!reader.IsDBNull(2)) Credito.IdSolicitud = Convert.ToInt32(reader[2]); if (!reader.IsDBNull(3)) Credito.CveICobr = reader[3].ToString(); if (!reader.IsDBNull(4)) Credito.Erogacion = Convert.ToDecimal(reader[4]); if (!reader.IsDBNull(5)) Credito.Capital = Convert.ToDecimal(reader[5]); if (!reader.IsDBNull(6)) Credito.Interes = Convert.ToDecimal(reader[6]); if (!reader.IsDBNull(7)) Credito.IvaIntere = Convert.ToDecimal(reader[7]); if (!reader.IsDBNull(8)) Credito.SdoCapita = Convert.ToDecimal(reader[8]); if (!reader.IsDBNull(9)) Credito.SdoIntere = Convert.ToDecimal(reader[9]); if (!reader.IsDBNull(10)) Credito.SdoIvaIn = Convert.ToDecimal(reader[10]); if (!reader.IsDBNull(11)) Credito.Moratorio = Convert.ToDecimal(reader[11]); if (!reader.IsDBNull(12)) Credito.IvaMorato = Convert.ToDecimal(reader[12]); if (!reader.IsDBNull(13)) Credito.SdoPorApl = Convert.ToDecimal(reader[13]); if (!reader.IsDBNull(14)) Credito.SdoVencido = Convert.ToDecimal(reader[14]); if (!reader.IsDBNull(15)) Credito.IdEstatus = Convert.ToInt32(reader[15]); if (!reader.IsDBNull(16)) Credito.FchEstatus = Convert.ToDateTime(reader[16]); if (!reader.IsDBNull(17)) Credito.IdMotivo = Convert.ToInt32(reader[17]); if (!reader.IsDBNull(18)) Credito.PorcenIva = Convert.ToInt32(reader[18]); if (!reader.IsDBNull(19)) Credito.NoRecPag = Convert.ToInt32(reader[19]); if (!reader.IsDBNull(20)) Credito.DiasVenc = Convert.ToInt32(reader[20]); if (!reader.IsDBNull(21)) Credito.DiasInac = Convert.ToInt32(reader[21]); if (!reader.IsDBNull(22)) Credito.DiaMasVe = Convert.ToInt32(reader[22]); if (!reader.IsDBNull(23)) Credito.EstaAdmin = reader[23].ToString(); if (!reader.IsDBNull(24)) Credito.FchUltPago = Convert.ToDateTime(reader[24]); if (!reader.IsDBNull(25)) Credito.FchGenerado = Convert.ToDateTime(reader[25]); if (!reader.IsDBNull(26)) Credito.Mientras = Convert.ToInt32(reader[26]); if (!reader.IsDBNull(27)) Credito.Reposicion = Convert.ToInt32(reader[27]); if (!reader.IsDBNull(28)) Credito.IdCuentaReposicion = Convert.ToInt32(reader[28]); if (!reader.IsDBNull(29)) Credito.GenReposicion = Convert.ToInt32(reader[29]); if (!reader.IsDBNull(30)) Credito.Fch1erPago = Convert.ToDateTime(reader[30]); if (!reader.IsDBNull(31)) Credito.IdFondeo = Convert.ToInt32(reader[31]); if (!reader.IsDBNull(32)) Credito.FchCobro = Convert.ToDateTime(reader[32]); if (!reader.IsDBNull(33)) Credito.EstCobro = Convert.ToInt32(reader[33]); if (!reader.IsDBNull(34)) Credito.PendObs = Convert.ToInt32(reader[34]); if (!reader.IsDBNull(35)) Credito.IdEFondeador = Convert.ToInt32(reader[35]); if (!reader.IsDBNull(36)) Credito.FchLiberado = Convert.ToDateTime(reader[36]); if (!reader.IsDBNull(37)) Credito.IdTipoCobranza = Convert.ToInt32(reader[37]); if (!reader.IsDBNull(38)) Credito.IdCuentaRest = Convert.ToDecimal(reader[38]); if (!reader.IsDBNull(39)) Credito.ClaveTipoInstrumento = reader[39].ToString(); if (!reader.IsDBNull(40)) Credito.ControlUltimoPago = Convert.ToDateTime(reader[40]); if (!reader.IsDBNull(41)) Credito.CodVerif = Convert.ToInt16(reader[41]); if (!reader.IsDBNull(42)) Credito.idCliente = Convert.ToInt32(reader[42]); resultado.Add(Credito); } } reader.Dispose(); } //Cierre de la conexion y liberacion de memoria com.Dispose(); } } catch (Exception ex) { throw ex; } return resultado; }