public imp_gasto_Info get_info(int IdGasto_tipo) { try { imp_gasto_Info info = new imp_gasto_Info(); using (Entities_importacion Context = new Entities_importacion()) { imp_gasto Entity = Context.imp_gasto.FirstOrDefault(q => q.IdGasto_tipo == IdGasto_tipo); if (Entity == null) { return(null); } info = new imp_gasto_Info { IdGasto_tipo = Entity.IdGasto_tipo, gt_descripcion = Entity.gt_descripcion, observacion = Entity.observacion, gt_orden = Entity.gt_orden, estado = Entity.estado }; } return(info); } catch (Exception) { throw; } }
public bool guardarDB(imp_gasto_Info info) { try { using (Entities_importacion Context = new Entities_importacion()) { imp_gasto Entity = new imp_gasto { IdGasto_tipo = info.IdGasto_tipo = get_id(), gt_descripcion = info.gt_descripcion, observacion = info.observacion, gt_orden = info.gt_orden, estado = info.estado = true, }; Context.imp_gasto.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public ActionResult Anular(int IdGasto_tipo = 0) { int IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); imp_gasto_Info model = bus_gasto.get_info(IdGasto_tipo); if (model == null) { return(RedirectToAction("Index")); } model.info_gasto_cta = bus_gasto_ct.get_info(IdGasto_tipo, IdEmpresa); if (model.info_gasto_cta == null) { model.info_gasto_cta = new imp_gasto_x_ct_plancta_Info { IdEmpresa = IdEmpresa, IdGasto_tipo = model.IdGasto_tipo } } ; else { model.IdCtaCble = model.info_gasto_cta.IdCtaCble; } cargar_combos(IdEmpresa); return(View(model)); }
public ActionResult CmbCuenta_Gasto() { imp_gasto_Info model = new imp_gasto_Info { info_gasto_cta = new imp_gasto_x_ct_plancta_Info() }; return(PartialView("_CmbCuenta_Gasto", model)); }
public bool anularDB(imp_gasto_Info info) { try { return(odata.anularDB(info)); } catch (Exception) { throw; } }
public bool modificarDB(imp_gasto_Info info) { try { return(odata.modificarDB(info)); } catch (Exception) { throw; } }
public ActionResult Nuevo(imp_gasto_Info model) { if (bus_gasto.guardarDB(model)) { model.info_gasto_cta.IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); model.info_gasto_cta.IdGasto_tipo = model.IdGasto_tipo; model.info_gasto_cta.IdCtaCble = model.IdCtaCble; bus_gasto_ct.guardarDB(model.info_gasto_cta); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public ActionResult Anular(imp_gasto_Info model) { model.info_gasto_cta = new imp_gasto_x_ct_plancta_Info { IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa) }; if (!bus_gasto.anularDB(model)) { cargar_combos(Convert.ToInt32(SessionFixed.IdEmpresa)); return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Nuevo(int IdGasto_tipo = 0) { int IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); imp_gasto_Info model = new imp_gasto_Info { info_gasto_cta = new imp_gasto_x_ct_plancta_Info() { IdEmpresa = IdEmpresa, IdGasto_tipo = IdGasto_tipo } }; cargar_combos(IdEmpresa); return(View(model)); }
public bool modificarDB(imp_gasto_Info info) { try { using (Entities_importacion Context = new Entities_importacion()) { //TRes el info del gasto - OK imp_gasto Entity = Context.imp_gasto.FirstOrDefault(q => q.IdGasto_tipo == info.IdGasto_tipo); if (Entity == null) { return(false); } //Modificar los campos si encuentra un gasto - OK Entity.gt_descripcion = info.gt_descripcion; Entity.observacion = info.observacion; Entity.gt_orden = info.gt_orden; //aqui tienes que hacer la parte del detalle //Primero busco si este gasto tiene cuenta en esta empresa var Entity_cta = Context.imp_gasto_x_ct_plancta.Where(q => q.IdEmpresa == info.info_gasto_cta.IdEmpresa && q.IdGasto_tipo == info.IdGasto_tipo).FirstOrDefault(); if (Entity_cta == null) { //Si no tiene creo uno nuevo Context.imp_gasto_x_ct_plancta.Add(new imp_gasto_x_ct_plancta { IdEmpresa = info.info_gasto_cta.IdEmpresa, IdCtaCble = info.IdCtaCble, IdGasto_tipo = info.IdGasto_tipo }); } else { //Caso contrario le actualizo la cuenta contable Entity_cta.IdCtaCble = info.IdCtaCble; } Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool anularDB(imp_gasto_Info info) { try { using (Entities_importacion Context = new Entities_importacion()) { imp_gasto Entity = Context.imp_gasto.FirstOrDefault(q => q.IdGasto_tipo == info.IdGasto_tipo); if (Entity == null) { return(false); } Entity.estado = info.estado = false; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }