public static string EditarIVA(Dictionary <string, object> pIVA) { CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); CIVA IVA = new CIVA(); IVA.IdIVA = Convert.ToInt32(pIVA["IdIVA"]);; IVA.IVA = Convert.ToDecimal(pIVA["IVA"]); IVA.DescripcionIVA = Convert.ToString(pIVA["DescripcionIVA"]); IVA.ClaveCuentaContable = Convert.ToString(pIVA["ClaveCuentaContable"]); IVA.CuentaContableTrasladado = Convert.ToString(pIVA["CuentaContableTrasladado"]); IVA.CCAcreditablePagado = Convert.ToString(pIVA["CuentaContableAcreditablePagado"]); IVA.CCTrasladadoPagado = Convert.ToString(pIVA["CuentaContableTrasladadoPagado"]); string validacion = ValidarIVA(IVA, ConexionBaseDatos); JObject oRespuesta = new JObject(); if (validacion == "") { IVA.Editar(ConexionBaseDatos); oRespuesta.Add(new JProperty("Error", 0)); ConexionBaseDatos.CerrarBaseDatosSqlServer(); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", validacion)); ConexionBaseDatos.CerrarBaseDatosSqlServer(); } return(oRespuesta.ToString()); }
public static string ObtenerFormaEditarIVA(int IdIVA) { CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); int puedeEditarIVA = 0; JObject oRespuesta = new JObject(); JObject oPermisos = new JObject(); CUsuario Usuario = new CUsuario(); if (Usuario.TienePermisos(new string[] { "puedeEditarIVA" }, ConexionBaseDatos) == "") { puedeEditarIVA = 1; } oPermisos.Add("puedeEditarIVA", puedeEditarIVA); if (respuesta == "Conexion Establecida") { JObject Modelo = new JObject(); Modelo = CIVA.ObtenerIVA(Modelo, IdIVA, ConexionBaseDatos); Modelo.Add(new JProperty("Permisos", oPermisos)); oRespuesta.Add(new JProperty("Error", 0)); oRespuesta.Add(new JProperty("Modelo", Modelo)); ConexionBaseDatos.CerrarBaseDatosSqlServer(); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", "No hay conexion a Base de Datos")); } return(oRespuesta.ToString()); }
public static JArray ObtenerJsonIVAActivas(CConexion pConexion) { JArray JAIVAes = new JArray(); CIVA IVA = new CIVA(); foreach (CIVA oIVA in IVA.LlenaObjetos(pConexion)) { JObject JIVA = new JObject(); JIVA.Add("Valor", oIVA.IdIVA); JIVA.Add("Descripcion", oIVA.IVA); JAIVAes.Add(JIVA); } return(JAIVAes); }
//Constructores //Metodos Especiales public static JObject ObtenerIVA(JObject pModelo, int pIdIVA, CConexion pConexion) { CIVA IVA = new CIVA(); IVA.LlenaObjeto(pIdIVA, pConexion); pModelo.Add(new JProperty("IdIVA", IVA.IdIVA)); pModelo.Add(new JProperty("IVA", IVA.IVA)); pModelo.Add(new JProperty("DescripcionIVA", IVA.DescripcionIVA)); pModelo.Add(new JProperty("ClaveCuentaContable", IVA.ClaveCuentaContable)); pModelo.Add(new JProperty("CuentaContableTrasladado", IVA.CuentaContableTrasladado)); pModelo.Add(new JProperty("CuentaContableAcreditablePagado", IVA.CCAcreditablePagado)); pModelo.Add(new JProperty("CuentaContableTrasladadoPagado", IVA.CCTrasladadoPagado)); return(pModelo); }
public static string CambiarEstatus(int pIdIVA, bool pBaja) { //Abrir Conexion CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); //¿La conexion se establecio? if (respuesta == "Conexion Establecida") { CIVA IVA = new CIVA(); IVA.IdIVA = pIdIVA; IVA.Baja = pBaja; IVA.Eliminar(ConexionBaseDatos); respuesta = "0|IVAEliminado"; } //Cerrar Conexion ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(respuesta); }
//Validaciones private static string ValidarIVA(CIVA pIVA, CConexion pConexion) { string errores = ""; if (pIVA.IVA == 0) { errores = errores + "<span>*</span> El campo IVA esta vacío, favor de capturarlo.<br />"; } if (pIVA.DescripcionIVA == "") { errores = errores + "<span>*</span> El campo Descripción de IVA esta vacío, favor de capturarlo.<br/>"; } if (pIVA.ClaveCuentaContable == "") { errores = errores + "<span>*</span> El campo de la clave de cuenta contable esta vacío, favor de capturarlo.<br />"; } if (pIVA.IdIVA == 0) { if (pIVA.ExisteClaveCuentaContable(pIVA.ClaveCuentaContable, pConexion) == 1) { errores = errores + "<span>*</span> Esta clave de cuenta contable " + pIVA.ClaveCuentaContable + " ya esta dada de alta.<br />"; } } else { if (pIVA.ExisteClaveCuentaContableEditar(pIVA.ClaveCuentaContable, pIVA.IdIVA, pConexion) == 1) { errores = errores + "<span>*</span> Esta clave de cuenta contable " + pIVA.ClaveCuentaContable + " ya esta dada de alta.<br />"; } } if (errores != "") { errores = "<p>Favor de completar los siguientes requisitos:</p>" + errores; } return(errores); }
public static string AgregarIVA(Dictionary <string, object> pIVA) { //Abrir Conexion CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); //¿La conexion se establecio? if (respuesta == "Conexion Establecida") { CIVA IVA = new CIVA(); IVA.IVA = Convert.ToDecimal(pIVA["IVA"]); IVA.DescripcionIVA = Convert.ToString(pIVA["DescripcionIVA"]); IVA.ClaveCuentaContable = Convert.ToString(pIVA["ClaveCuentaContable"]); IVA.CuentaContableTrasladado = Convert.ToString(pIVA["CuentaContableTrasladado"]); IVA.CCAcreditablePagado = Convert.ToString(pIVA["CuentaContableAcreditablePagado"]); IVA.CCTrasladadoPagado = Convert.ToString(pIVA["CuentaContableTrasladadoPagado"]); string validacion = ValidarIVA(IVA, ConexionBaseDatos); JObject oRespuesta = new JObject(); if (validacion == "") { IVA.Agregar(ConexionBaseDatos); oRespuesta.Add(new JProperty("Error", 0)); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", validacion)); } ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(oRespuesta.ToString()); } else { return("1|" + respuesta); } }