public ActionResult Save(CentroCostosModel model) { if (sesion == null) { sesion = SessionDB.start(Request, Response, false, db); } model.sesion = sesion; if (!sesion.permisos.havePermission(Privileges[0].Permiso)) { return(Json(new { msg = Notification.notAccess() })); } try { if (model.Save()) { Log.write(this, "Save", LOG.EDICION, "SQL:" + model.sql, sesion); return(Json(new { msg = Notification.Succes("Banco guardado con exito: " + model.Descripcion) })); } else { Log.write(this, "Save", LOG.ERROR, "SQL:" + model.sql, sesion); return(Json(new { msg = Notification.Error(" Error al GUARDAR: " + model.Descripcion) })); } } catch (Exception e) { return(Json(new { msg = Notification.Error(e.Message) })); } }
public ActionResult Add(CentroCostosModel model) { if (sesion == null) { sesion = SessionDB.start(Request, Response, false, db); } model.sesion = sesion; if (!sesion.permisos.havePermission(Privileges[0].Permiso)) { return(Json(new { msg = Notification.notAccess() })); } try { if (model.Add()) { Log.write(this, "Add", LOG.REGISTRO, "SQL:" + model.sql, sesion); return(Json(new { msg = Notification.Succes("Registro agregado con exito: " + model.Descripcion) })); } else { Log.write(this, "Add", LOG.ERROR, "SQL:" + model.sql, sesion); return(Json(new { msg = Notification.Error(" Error al agregar: " + model.Descripcion) })); } } catch (Exception e) { return(Json(new { msg = Factory.Notification.Error(e.Message) })); } }
public ActionResult Edit(CentroCostosModel model) { if (model.Edit()) { return(Json(new JavaScriptSerializer().Serialize(model))); } return(View()); }
public string getCentrodecostos(string CampusVPDI = "", string EscuelaCVE = "", string TipoFactura = "", string TipoPagoCVE = "", string CVE_Programa = "") { CentroCostosModel model = new CentroCostosModel(); model.CampusVPDI = CampusVPDI; model.EscuelaCVE = EscuelaCVE; model.CVE_Programa = CVE_Programa; if (TipoPagoCVE != "" && TipoPagoCVE != null) { model.TipoPagoCVE = TipoPagoCVE; } else { switch (TipoFactura) { case "A": model.TipoPagoCVE = "ADI"; break; case "H": model.TipoPagoCVE = "HDI"; break; default: model.TipoPagoCVE = ""; break; } } SessionDB sesion = SessionDB.start(Request, Response, false, model.db, SESSION_BEHAVIOR.AJAX); if (sesion == null) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append("<option></option>"); foreach (KeyValuePair <string, string> pair in model.getCentrosdeCostos()) { sb.Append("<option value=\"").Append(pair.Key).Append("\">").Append(pair.Value).Append("</option>\n"); } return(sb.ToString()); }
public string ConsultaTipoFacturas() { CentroCostosModel model = new CentroCostosModel(); SessionDB sesion = SessionDB.start(Request, Response, false, model.db, SESSION_BEHAVIOR.AJAX); if (sesion == null) { return(""); } StringBuilder sb = new StringBuilder(); string selected = "selected"; foreach (KeyValuePair <string, string> pair in model.ConsultaTipoFacturas()) { sb.Append("<option value=\"").Append(pair.Key).Append("\" ").Append(selected).Append(">").Append(pair.Value).Append("</option>\n"); selected = ""; } return(sb.ToString()); }
public string getCentrodecostosAll() { CentroCostosModel model = new CentroCostosModel(); SessionDB sesion = SessionDB.start(Request, Response, false, model.db, SESSION_BEHAVIOR.AJAX); if (sesion == null) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append("<option></option>"); foreach (KeyValuePair <string, string> pair in model.getCentrosdeCostosAll()) { sb.Append("<option value=\"").Append(pair.Key).Append("\">").Append(pair.Value).Append("</option>\n"); } return(sb.ToString()); }
public ActionResult Delete(CentroCostosModel model) { if (sesion == null) { sesion = SessionDB.start(Request, Response, false, db); } model.sesion = sesion; if (!sesion.permisos.havePermission(Privileges[0].Permiso)) { return(Json(new { msg = Notification.notAccess() })); } try { if (model.Delete()) { if (!model.asignado) { Log.write(this, "Delete", LOG.BORRADO, "SQL:" + model.sql, sesion); return(Json(new { msg = Notification.Succes("Centro de Costos ELIMINADO con exito: " + model.Descripcion) })); } else { Log.write(this, "Delete", LOG.BORRADO, "SQL:" + model.sql, sesion); return(Json(new { msg = Notification.Warning("No se puede eliminar el Centro de Costos por que esta asignado en el Estado de Cuenta ") })); } } else { Log.write(this, "Delete", LOG.ERROR, "SQL:" + model.sql, sesion); return(Json(new { msg = Notification.Error(" Error al Eliminar: " + model.Descripcion) })); } } catch (Exception e) { return(Json(new { msg = Notification.Error(e.Message) })); } }