public static string EditarCuentaContable(Dictionary <string, object> pCuentaContable) { CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); CUsuario Usuario = new CUsuario(); Usuario.LlenaObjeto(Convert.ToInt32(HttpContext.Current.Session["IdUsuario"]), ConexionBaseDatos); CCuentaContable CuentaContable = new CCuentaContable(); CuentaContable.LlenaObjeto(Convert.ToInt32(pCuentaContable["IdCuentaContable"]), ConexionBaseDatos); CuentaContable.IdCuentaContable = Convert.ToInt32(pCuentaContable["IdCuentaContable"]); CuentaContable.CuentaContable = Convert.ToString(pCuentaContable["CuentaContable"]); CuentaContable.IdSucursal = Convert.ToInt32(pCuentaContable["IdSucursal"]); CuentaContable.IdDivision = Convert.ToInt32(pCuentaContable["IdDivision"]); CuentaContable.IdTipoCompra = Convert.ToInt32(pCuentaContable["IdTipoCompra"]); CuentaContable.Descripcion = Convert.ToString(pCuentaContable["Descripcion"]); string validacion = ValidarCuentaContable(CuentaContable, ConexionBaseDatos); JObject oRespuesta = new JObject(); if (validacion == "") { CuentaContable.Editar(ConexionBaseDatos); oRespuesta.Add(new JProperty("Error", 0)); ConexionBaseDatos.CerrarBaseDatosSqlServer(); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", validacion)); } return(oRespuesta.ToString()); }
public static string ObtenerFormaEditarCuentaContable(int IdCuentaContable) { CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); int puedeEditarCuentaContable = 0; JObject oRespuesta = new JObject(); JObject oPermisos = new JObject(); CUsuario Usuario = new CUsuario(); if (Usuario.TienePermisos(new string[] { "puedeEditarCuentaContable" }, ConexionBaseDatos) == "") { puedeEditarCuentaContable = 1; } oPermisos.Add("puedeEditarCuentaContable", puedeEditarCuentaContable); if (respuesta == "Conexion Establecida") { JObject Modelo = new JObject(); Modelo = CCuentaContable.ObtenerCuentaContable(Modelo, IdCuentaContable, ConexionBaseDatos); Modelo.Add("Divisiones", CJson.ObtenerJsonDivision(Convert.ToInt32(Modelo["IdDivision"].ToString()), ConexionBaseDatos)); Modelo.Add("TipoCompras", CJson.ObtenerJsonTipoCompra(Convert.ToInt32(Modelo["IdTipoCompra"].ToString()), ConexionBaseDatos)); Modelo.Add("Sucursales", CSucursal.ObtenerSucursales(Convert.ToInt32(Modelo["IdSucursal"].ToString()), 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 string ObtenerCuentaContableGenerada(Dictionary <string, object> pCuentaContable) { //Abrir Conexion CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); Dictionary <string, object> CuentaContableGenerada = new Dictionary <string, object>(); JObject oRespuesta = new JObject(); //¿La conexion se establecio? if (respuesta == "Conexion Establecida") { CUsuario Usuario = new CUsuario(); CCuentaContable CuentaContable = new CCuentaContable(); Usuario.LlenaObjeto(Convert.ToInt32(HttpContext.Current.Session["IdUsuario"]), ConexionBaseDatos); CuentaContableGenerada = CuentaContable.ObtenerCuentaContableGeneradaSegmentos(Convert.ToInt32(pCuentaContable["IdSucursal"]), Convert.ToInt32(pCuentaContable["IdDivision"]), Convert.ToInt32(pCuentaContable["IdTipoCompra"]), 0, ConexionBaseDatos); JObject Modelo = new JObject(); Modelo.Add("SegmentoSucursal", CuentaContableGenerada["SegmentoSucursal"].ToString()); Modelo.Add("SegmentoDivision", CuentaContableGenerada["SegmentoDivision"].ToString()); Modelo.Add("SegmentoTipoCompra", CuentaContableGenerada["SegmentoTipoCompra"].ToString()); oRespuesta.Add(new JProperty("Error", 0)); oRespuesta.Add(new JProperty("Modelo", Modelo)); ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(oRespuesta.ToString()); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", "No hay conexión con la base de datos.")); return(oRespuesta.ToString()); } }
public static string ObtenerFormaCuentaContable(int pIdCuentaContable) { CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); int puedeEditarCuentaContable = 0; JObject oRespuesta = new JObject(); JObject oPermisos = new JObject(); CUsuario Usuario = new CUsuario(); if (Usuario.TienePermisos(new string[] { "puedeEditarCuentaContable" }, ConexionBaseDatos) == "") { puedeEditarCuentaContable = 1; } oPermisos.Add("puedeEditarCuentaContable", puedeEditarCuentaContable); if (respuesta == "Conexion Establecida") { JObject Modelo = new JObject(); Modelo = CCuentaContable.ObtenerCuentaContable(Modelo, pIdCuentaContable, ConexionBaseDatos); Modelo.Add(new JProperty("Permisos", oPermisos)); oRespuesta.Add(new JProperty("Error", 0)); oRespuesta.Add(new JProperty("Modelo", Modelo)); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", "No hay conexion a Base de Datos")); } ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(oRespuesta.ToString()); }
public static string BuscarCuentaContable(string pCuentaContable) { //Abrir Conexion CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); CCuentaContable jsonCuentaContable = new CCuentaContable(); jsonCuentaContable.StoredProcedure.CommandText = "sp_Proveedor_ConsultarCuentaContable"; jsonCuentaContable.StoredProcedure.Parameters.AddWithValue("@Opcion", 1); jsonCuentaContable.StoredProcedure.Parameters.AddWithValue("@pCuentaContable", pCuentaContable); return(jsonCuentaContable.ObtenerJsonCuentaContable(ConexionBaseDatos)); }
//Constructores //Metodos Especiales public static JObject ObtenerCuentaContable(JObject pModelo, int pIdCuentaContable, CConexion pConexion) { CCuentaContable CuentaContable = new CCuentaContable(); CuentaContable.LlenaObjeto(pIdCuentaContable, pConexion); pModelo.Add(new JProperty("IdCuentaContable", CuentaContable.IdCuentaContable)); pModelo.Add(new JProperty("CuentaContable", CuentaContable.CuentaContable)); string[] segmentosCuentaContables; segmentosCuentaContables = CuentaContable.CuentaContable.Split('-'); int contador = 0; JArray JASegmentos = new JArray(); foreach (string segmento in segmentosCuentaContables) { contador++; JObject JSegmento = new JObject(); JSegmento.Add("Id", contador); JSegmento.Add("Segmento", segmento); JASegmentos.Add(JSegmento); } pModelo.Add(new JProperty("Segmentos", JASegmentos)); pModelo.Add(new JProperty("Descripcion", CuentaContable.Descripcion)); pModelo.Add(new JProperty("IdDivision", CuentaContable.IdDivision)); pModelo.Add(new JProperty("IdTipoCompra", CuentaContable.IdTipoCompra)); pModelo.Add(new JProperty("IdSucursal", CuentaContable.IdSucursal)); CDivision Division = new CDivision(); Division.LlenaObjeto(CuentaContable.IdDivision, pConexion); pModelo.Add(new JProperty("Division", Division.Division)); CTipoCompra TipoCompra = new CTipoCompra(); TipoCompra.LlenaObjeto(CuentaContable.IdTipoCompra, pConexion); pModelo.Add(new JProperty("TipoCompra", TipoCompra.TipoCompra)); CSucursal Sucursal = new CSucursal(); Sucursal.LlenaObjeto(CuentaContable.IdSucursal, pConexion); pModelo.Add(new JProperty("Sucursal", Sucursal.Sucursal)); return(pModelo); }
public static string AgregarCuentaContableComplementos(Dictionary <string, object> pCuentaContable) { //Abrir Conexion CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); //¿La conexion se establecio? if (respuesta == "Conexion Establecida") { CUsuario Usuario = new CUsuario(); Usuario.LlenaObjeto(Convert.ToInt32(HttpContext.Current.Session["IdUsuario"]), ConexionBaseDatos); CCuentaContable CuentaContable = new CCuentaContable(); Dictionary <string, object> Parametros = new Dictionary <string, object>(); Parametros.Add("IdTipoCuentaContable", Convert.ToInt32(pCuentaContable["IdTipoCuentaContable"])); CuentaContable.LlenaObjetoFiltros(Parametros, ConexionBaseDatos); JObject oRespuesta = new JObject(); if (CuentaContable.IdCuentaContable == 0) { CuentaContable.IdTipoCuentaContable = Convert.ToInt32(pCuentaContable["IdTipoCuentaContable"]); CuentaContable.CuentaContable = pCuentaContable["CuentaClienteComplemento"].ToString(); CuentaContable.Descripcion = pCuentaContable["DescripcionCuentaClienteComplemento"].ToString(); CuentaContable.Agregar(ConexionBaseDatos); } else { CuentaContable.IdTipoCuentaContable = Convert.ToInt32(pCuentaContable["IdTipoCuentaContable"]); CuentaContable.CuentaContable = pCuentaContable["CuentaClienteComplemento"].ToString(); CuentaContable.Descripcion = pCuentaContable["DescripcionCuentaClienteComplemento"].ToString(); CuentaContable.Editar(ConexionBaseDatos); } oRespuesta.Add(new JProperty("Error", 0)); ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(oRespuesta.ToString()); } else { return("1|" + respuesta); } }
public static string ObtenerFormaAgregarCuentaContableComplementos(int pIdTipoCuentaContable) { CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); int puedeEditarCuentaContable = 0; JObject oRespuesta = new JObject(); JObject oPermisos = new JObject(); CUsuario Usuario = new CUsuario(); if (Usuario.TienePermisos(new string[] { "puedeEditarCuentaContable" }, ConexionBaseDatos) == "") { puedeEditarCuentaContable = 1; } oPermisos.Add("puedeEditarCuentaContable", puedeEditarCuentaContable); if (respuesta == "Conexion Establecida") { CCuentaContable CuentaContable = new CCuentaContable(); Dictionary <string, object> Parametros = new Dictionary <string, object>(); Parametros.Add("IdTipoCuentaContable", pIdTipoCuentaContable); CuentaContable.LlenaObjetoFiltros(Parametros, ConexionBaseDatos); CTipoCuentaContable TipoCuentaContable = new CTipoCuentaContable(); TipoCuentaContable.LlenaObjeto(pIdTipoCuentaContable, ConexionBaseDatos); JObject Modelo = new JObject(); Modelo.Add("IdTipoCuentaContable", pIdTipoCuentaContable); Modelo.Add("TipoCuentaContable", TipoCuentaContable.TipoCuentaContable); Modelo.Add("CuentaClienteComplemento", CuentaContable.CuentaContable); Modelo.Add("DescripcionCuentaClienteComplemento", CuentaContable.Descripcion); Modelo.Add(new JProperty("Permisos", oPermisos)); oRespuesta.Add(new JProperty("Error", 0)); oRespuesta.Add(new JProperty("Modelo", Modelo)); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", "No hay conexion a Base de Datos")); } ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(oRespuesta.ToString()); }
public static string CambiarEstatus(int pIdCuentaContable, bool pBaja) { //Abrir Conexion CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); //¿La conexion se establecio? if (respuesta == "Conexion Establecida") { CCuentaContable CuentaContable = new CCuentaContable(); CuentaContable.IdCuentaContable = pIdCuentaContable; CuentaContable.Baja = pBaja; CuentaContable.Eliminar(ConexionBaseDatos); respuesta = "0|CuentaContableEliminado"; } //Cerrar Conexion ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(respuesta); }
//Validaciones private static string ValidarCuentaContable(CCuentaContable pCuentaContable, CConexion pConexion) { string errores = ""; if (pCuentaContable.CuentaContable == "") { errores = errores + "<span>*</span> El campo de la cuenta contable esta vacío, favor de capturarlo.<br />"; } if (pCuentaContable.IdDivision == 0) { errores = errores + "<span>*</span> El campo división esta vacío, favor de seleccionarlo.<br />"; } if (pCuentaContable.IdTipoCompra == 0) { errores = errores + "<span>*</span> El campo tipo de compra esta vacío, favor de seleccionarlo.<br />"; } if (pCuentaContable.IdCuentaContable == 0) { if (pCuentaContable.ExisteCuentaContable(pCuentaContable.CuentaContable, pConexion) == 1) { errores = errores + "<span>*</span> Esta cuenta contable " + pCuentaContable.CuentaContable + " ya esta dada de alta.<br />"; } } else { if (pCuentaContable.ExisteCuentaContableEditar(pCuentaContable.CuentaContable, pCuentaContable.IdCuentaContable, pConexion) == 1) { errores = errores + "<span>*</span> Esta cuenta contable " + pCuentaContable.CuentaContable + " ya esta dada de alta.<br />"; } } if (errores != "") { errores = "<p>Favor de completar los siguientes requisitos:</p>" + errores; } return(errores); }
public static string ObtenerFormaAgregarCuentaContable() { CConexion ConexionBaseDatos = new CConexion(); string respuesta = ConexionBaseDatos.ConectarBaseDatosSqlServer(); int puedeEditarCuentaContable = 0; JObject oRespuesta = new JObject(); JObject oPermisos = new JObject(); CUsuario Usuario = new CUsuario(); string CuentaContableGenerada = ""; if (Usuario.TienePermisos(new string[] { "puedeEditarCuentaContable" }, ConexionBaseDatos) == "") { puedeEditarCuentaContable = 1; } oPermisos.Add("puedeEditarCuentaContable", puedeEditarCuentaContable); if (respuesta == "Conexion Establecida") { CCuentaContable CuentaContable = new CCuentaContable(); Usuario.LlenaObjeto(Convert.ToInt32(HttpContext.Current.Session["IdUsuario"]), ConexionBaseDatos); CuentaContableGenerada = CuentaContable.ObtenerCuentaContableGenerada(Usuario.IdSucursalActual, 0, 0, 0, ConexionBaseDatos); JObject Modelo = new JObject(); Modelo.Add("Divisiones", CJson.ObtenerJsonDivision(ConexionBaseDatos)); Modelo.Add("TipoCompras", CJson.ObtenerJsonTipoCompra(ConexionBaseDatos)); Modelo.Add("Sucursales", CSucursal.ObtenerSucursales(ConexionBaseDatos)); Modelo.Add(new JProperty("CuentaContable", CuentaContableGenerada)); Modelo.Add(new JProperty("Permisos", oPermisos)); oRespuesta.Add(new JProperty("Error", 0)); oRespuesta.Add(new JProperty("Modelo", Modelo)); } else { oRespuesta.Add(new JProperty("Error", 1)); oRespuesta.Add(new JProperty("Descripcion", "No hay conexion a Base de Datos")); } ConexionBaseDatos.CerrarBaseDatosSqlServer(); return(oRespuesta.ToString()); }