public List <Categoria_Gasto> FindAll() { var ListCategoriaGasto = new List <Categoria_Gasto>(); try { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Financiamiento"].ToString())) { con.Open(); var query = new SqlCommand("Select * from Categoria_Gasto", con); using (var dr = query.ExecuteReader()) { while (dr.Read()) { var CatGasto = new Categoria_Gasto(); CatGasto.IDCategoria_Gasto = Convert.ToInt32(dr["IDCategoria_Gasto"]); CatGasto.NCategoria_Gasto = dr["NCategoria_Gasto"].ToString(); ListCategoriaGasto.Add(CatGasto); } } } } catch (Exception ex) { throw ex; } return(ListCategoriaGasto); }
public async Task <ActionResult> DeleteConfirmed(int id) { Categoria_Gasto categoria_Gasto = await db.Categoria_Gasto.FindAsync(id); db.Categoria_Gasto.Remove(categoria_Gasto); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "IDCategoria_Gasto,NCategoria_Gasto")] Categoria_Gasto categoria_Gasto) { if (ModelState.IsValid) { db.Entry(categoria_Gasto).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(categoria_Gasto)); }
public async Task <ActionResult> Create([Bind(Include = "IDCategoria_Gasto,NCategoria_Gasto")] Categoria_Gasto categoria_Gasto) { if (ModelState.IsValid) { db.Categoria_Gasto.Add(categoria_Gasto); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(categoria_Gasto)); }
// GET: Categoria_Gasto/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Categoria_Gasto categoria_Gasto = await db.Categoria_Gasto.FindAsync(id); if (categoria_Gasto == null) { return(HttpNotFound()); } return(View(categoria_Gasto)); }
public List <Gasto> FindAll() { var Gastos = new List <Gasto>(); try { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Financiamiento"].ToString())) { con.Open(); var query = new SqlCommand("select g.IDGasto as CodigoGasto, t.NTransaccion,t.MontoTransaccion,t.FechaTransaccion" + "cg.IDCategoria_Gasto as CodigoCategoriaG,cg.NCategoria_Gasto from Gasto g, Transaccion t, Categoria_Gasto cg" + "where g.IDGasto=t.IDTransaccion and g.IDCategoria_Gasto=cg.IDCategoria_Gasto", con); using (var dr = query.ExecuteReader()) { while (dr.Read()) { var transaccion = new Gasto(); var categoria_gasto = new Categoria_Gasto(); transaccion.IDTransaccion = Convert.ToInt32(dr["IDTransaccion"]); transaccion.NTransaccion = (dr["NTransaccion"]).ToString(); transaccion.MontoTransaccion = Convert.ToDecimal(dr["MontoTransaccion"]); transaccion.FechaTransaccion = Convert.ToDateTime(dr["FechaTransaccion"]); categoria_gasto.IDCategoria_Gasto = Convert.ToInt32(dr["IDCategoria_Gasto"]); categoria_gasto.NCategoria_Gasto = (dr["NCategoria_Gasto"]).ToString(); transaccion.IDCategoria_Gasto = categoria_gasto; Gastos.Add(transaccion); } } } } catch (Exception ex) { throw ex; } return(Gastos); }
public bool Insert(Categoria_Gasto t) { bool rpta = false; try { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Financiamiento"].ToString())) { con.Open(); var query = new SqlCommand("insert into Categoria_Gasto values (@NCategoria_Gasto)", con); query.Parameters.AddWithValue("@NCategoria_Gasto", t.NCategoria_Gasto); query.ExecuteNonQuery(); rpta = true; } } catch (Exception ex) { throw ex; } return(rpta); }
public Gasto FindByID(int?id) { Gasto gasto = null; try { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Financiamiento"].ToString())) { con.Open(); var query = new SqlCommand("select g.IDGasto as CodigoGasto, t.NTransaccion,t.MontoTransaccion,t.FechaTransaccion" + "cg.IDCategoria_Gasto as CodigoCategoriaG,cg.NCategoria_Gasto from Gasto g, Transaccion t, Categoria_Gasto cg" + "where g.IDGasto=t.IDTransaccion and g.IDCategoria_Gasto=cg.IDCategoria_Gasto and g.IDGasto='" + id + "'", con); using (var dr = query.ExecuteReader()) { while (dr.Read()) { gasto = new Gasto(); var categoria_gasto = new Categoria_Gasto(); gasto.IDTransaccion = Convert.ToInt32(dr["IDTransaccion"]); gasto.NTransaccion = (dr["NTransaccion"]).ToString(); gasto.MontoTransaccion = Convert.ToDecimal(dr["MontoTransaccion"]); gasto.FechaTransaccion = Convert.ToDateTime(dr["FechaTransaccion"]); categoria_gasto.IDCategoria_Gasto = Convert.ToInt32(dr["IDCategoria_Gasto"]); categoria_gasto.NCategoria_Gasto = (dr["NCategoria_Gasto"]).ToString(); gasto.IDCategoria_Gasto = categoria_gasto; } } } } catch (Exception ex) { throw ex; } return(gasto); }
public bool Update(Categoria_Gasto t) { bool rpta = false; try { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Financiamiento"].ToString())) { con.Open(); var query = new SqlCommand("update Categoria_Gasto set NCategoria_Gasto=@NCategoria_Gasto where IDCategoria_Gasto='" + t.IDCategoria_Gasto + "'", con); query.Parameters.AddWithValue("@NCategoria_Gasto", t.NCategoria_Gasto); query.ExecuteNonQuery(); rpta = true; } } catch (Exception ex) { throw ex; } return(rpta); }
public bool Update(Categoria_Gasto t) { return(objCategoria_GastoRepo.Update(t)); }
public bool Insert(Categoria_Gasto t) { return(objCategoria_GastoRepo.Insert(t)); }