public ActionResult EliminarGasto(int pID) { string tipoDevol = null; object DataDevol = null; object jsonResponse; try { objGastoLogic = new GastoLogic(); Parametro objParametro = new Parametro { codGasto = pID, segUsuElimina = User.Identity.Name, segMaquinaPC = GetIPAddress() }; /*Borra el registro de la tabla*/ returnValor = objGastoLogic.EliminarGasto(objParametro); DataDevol = returnValor.Message; tipoDevol = returnValor.Exitosa ? "C" : "I"; } catch (Exception ex) { tipoDevol = "E"; log.Error(String.Concat("EliminarGasto", " | ", ex.Message)); DataDevol = ex.Message; } finally { jsonResponse = new { Type = tipoDevol, Data = DataDevol, }; } return Json(jsonResponse, JsonRequestBehavior.AllowGet); }
public ActionResult GuardarGasto(GastoEntity pGasto) { string tipoDevol = null; object DataDevol = null; object jsonResponse; try { objGastoLogic = new GastoLogic(); pGasto.segUsuarioEdita = HttpContext.User.Identity.Name; pGasto.segUsuarioCrea = HttpContext.User.Identity.Name; pGasto.segMaquinaOrigen = GetIPAddress(); if (pGasto.Codigo != 0) returnValor = objGastoLogic.ActualizarGasto(pGasto); else returnValor = objGastoLogic.RegistrarGasto(pGasto); DataDevol = returnValor.Message; tipoDevol = returnValor.Exitosa ? "C" : "I"; } catch (Exception ex) { tipoDevol = "E"; log.Error(String.Concat("GuardarGasto", " | ", ex.Message)); DataDevol = ex.Message; } finally { jsonResponse = new { Type = tipoDevol, Data = DataDevol, }; } return Json(jsonResponse, JsonRequestBehavior.AllowGet); }
public ActionResult ListarGasto(Parametro parametro) { string tipoDevol = null; object DataDevol = null; object jsonResponse; try { objGastoLogic = new GastoLogic(); var lista = objGastoLogic.ListarGastoPaginado(new Parametro { p_NumPagina = parametro.p_NumPagina, p_TamPagina = parametro.p_TamPagina, p_OrdenPor = parametro.p_OrdenPor, p_OrdenTipo = parametro.p_OrdenTipo, numAnio = parametro.numAnio, codArea = parametro.codArea, codPlantillaDeta = parametro.codPlantillaDeta }); long totalRecords = lista.Select(x => x.TOTALROWS).FirstOrDefault(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)parametro.p_TamPagina); var jsonGrid = new { PageCount = totalPages, CurrentPage = parametro.p_NumPagina, RecordCount = totalRecords, Items = ( from item in lista select new { ID = item.Codigo, Row = new string[] {"","" , item.numDocumento , item.fecGasto.ToShortDateString() , item.cntCantidad.ToString("N2") , item.monTotal.ToString("N2") , item.objEmpleadoResp.desNombre , item.gloObservacion , item.objEmpleadoResp.objArea.desNombre , item.objPlantillaDeta.objPlantilla.objPresupuesto.desNombre , item.segFechaEdita.HasValue ? item.segFechaEdita.Value.ToString() : item.segFechaCrea.ToString() , string.IsNullOrEmpty(item.segUsuarioEdita) ? item.segUsuarioEdita : item.segUsuarioCrea } }).ToArray() }; DataDevol = jsonGrid; tipoDevol = "C"; } catch (Exception ex) { tipoDevol = "E"; log.Error(String.Concat("ListarGasto", " | ", ex.Message)); DataDevol = ex.Message; } finally { jsonResponse = new { Type = tipoDevol, Data = DataDevol, }; } return Json(jsonResponse); }
public ActionResult BuscarGasto(int pID) { string tipoDevol = null; object DataDevol = null; object empleados = null; object jsonResponse; try { objGastoLogic = new GastoLogic(); var registro = objGastoLogic.BuscarGasto(pID); if (registro == null) registro = InicializarGasto(registro); empleados = ListarEmpleados(); tipoDevol = "C"; DataDevol = registro; } catch (Exception ex) { tipoDevol = "E"; log.Error(String.Concat("BuscarGasto", " | ", ex.Message)); DataDevol = ex.Message; } finally { jsonResponse = new { Type = tipoDevol, Empleados = empleados, Data = DataDevol, }; } return Json(jsonResponse); }