public ActionResult Create([Bind(Include = "dafp_AporteLps,afp_Id,emp_Id,dafp_UsuarioCrea,dafp_FechaCrea,dafp_DeducirISR")] tbDeduccionAFP tbDeduccionAFP)
        {
            //LLENAR LA DATA DE AUDITORIA, DE NO HACERLO EL MODELO NO SERÍA VÁLIDO Y SIEMPRE CAERÍA EN EL CATCH

            //VARIABLE PARA ALMACENAR EL RESULTADO DEL PROCESO Y ENVIARLO AL LADO DEL CLIENTE
            string response = String.Empty;
            IEnumerable <object> listDeduccionAFP = null;
            string MensajeError = "";

            //VALIDAR SI EL MODELO ES VÁLIDO
            if (ModelState.IsValid)
            {
                try
                {
                    //EJECUTAR PROCEDIMIENTO ALMACENADO
                    listDeduccionAFP = db.UDP_Plani_tbDeduccionAFP_Insert(tbDeduccionAFP.dafp_AporteLps,
                                                                          tbDeduccionAFP.afp_Id,
                                                                          tbDeduccionAFP.emp_Id,
                                                                          Function.GetUser(),
                                                                          Function.DatetimeNow(),
                                                                          tbDeduccionAFP.dafp_DeducirISR);
                    //RECORRER EL TIPO COMPLEJO DEL PROCEDIMIENTO ALMACENADO PARA EVALUAR EL RESULTADO DEL SP
                    foreach (UDP_Plani_tbDeduccionAFP_Insert_Result Resultado in listDeduccionAFP)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        //EN CASO DE OCURRIR UN ERROR, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                        response = "error";
                    }
                }
                catch (Exception Ex)
                {
                    //EN CASO DE CAER EN EL CATCH, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                    response = Ex.Message.ToString();
                }
                //SI LA EJECUCIÓN LLEGA A ESTE PUNTO SIGNIFICA QUE NO OCURRIÓ NINGÚN ERROR Y EL PROCESO FUE EXITOSO
                //IGUALAMOS LA VARIABLE "RESPONSE" A "BIEN" PARA VALIDARLO EN EL CLIENTE
                response = "bien";
            }
            else
            {
                //SI EL MODELO NO ES VÁLIDO, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                response = "error";
            }

            //RETORNAMOS LA VARIABLE RESPONSE AL CLIENTE PARA EVALUARLA

            /*
             * ViewBag.afp_Id = new SelectList(db.tbAFP, "afp_Id", "afp_Descripcion", db.tbAFP.Include(d => d.afp_Id));
             * ViewBag.emp_Id = new SelectList(db.tbPersonas, "emp_Id", "per_Nombres" + ' ' + "per_Apellidos", db.tbEmpleados.Include(d => d.emp_Id));
             */

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult Create(string aisr_Descripcion, decimal aisr_Monto, bool aisr_DeducirISR, int emp_ID)
        {
            tbAcumuladosISR tbAcumuladosISR = new tbAcumuladosISR()
            {
                aisr_Descripcion = aisr_Descripcion, aisr_Monto = aisr_Monto, aisr_DeducirISR = aisr_DeducirISR, emp_Id = emp_ID
            };

            #region declaracion de variables
            //tbAcumuladosISR.aisr_UsuarioCrea = 1;
            //tbAcumuladosISR.aisr_FechaCrea = DateTime.Now;
            //Variable para almacenar el resultado del proceso y enviarlo al lado del cliente
            string response = String.Empty;
            IEnumerable <object> listAcumuladosISR = null;
            string MensajeError = "";
            #endregion

            if (ModelState.IsValid)
            {
                try
                {
                    //Ejecutar el procedimiento almacenado
                    listAcumuladosISR = db.UDP_Plani_tbAcumuladosISR_Insert(tbAcumuladosISR.aisr_Descripcion,
                                                                            tbAcumuladosISR.aisr_Monto,
                                                                            Function.GetUser(),
                                                                            Function.DatetimeNow(),
                                                                            tbAcumuladosISR.aisr_DeducirISR,
                                                                            tbAcumuladosISR.emp_Id);

                    //RECORRER EL TIPO COMPLEJO DEL PROCEDIMIENTO ALMACENADO PARA EVALUAR EL RESULTADO DEL SP
                    foreach (UDP_Plani_tbAcumuladosISR_Insert_Result Resultado in listAcumuladosISR)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    response = "bien";
                    if (MensajeError.StartsWith("-1"))
                    {
                        //EN CASO DE OCURRIR UN ERROR, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                        ModelState.AddModelError("", "No se pudo ingresar el registro. Contacte al administrador.");
                        response = "error";
                    }
                }
                catch (Exception Ex)
                {
                    //EN CASO DE CAER EN EL CATCH, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                    response = Ex.Message.ToString();
                }
            }
            else
            {
                //SI EL MODELO NO ES VÁLIDO, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                response = "error";
            }
            //RETORNAMOS LA VARIABLE RESPONSE AL CLIENTE PARA EVALUARLA
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create([Bind(Include = "afp_Descripcion,afp_AporteMinimoLps,afp_InteresAporte,afp_InteresAnual,tde_IdTipoDedu,afp_UsuarioCrea,afp_FechaCrea")] tbAFP tbAFP)
        {
            // data de auditoria
            //tbAFP.afp_UsuarioCrea = 1;
            //tbAFP.afp_FechaCrea = DateTime.Now;

            // variables para validar resultados
            string response = String.Empty;
            IEnumerable <object> listAFP = null;
            string MensajeError          = "";

            // validar modelo
            if (ModelState.IsValid)
            {
                try
                {
                    // ejecutar procedimientos almacenados
                    listAFP = db.UDP_Plani_tbAFP_Insert(tbAFP.afp_Descripcion,
                                                        tbAFP.afp_AporteMinimoLps,
                                                        tbAFP.afp_InteresAporte,
                                                        tbAFP.afp_InteresAnual,
                                                        tbAFP.tde_IdTipoDedu,
                                                        Function.GetUser(),
                                                        Function.DatetimeNow());

                    // verificar resultado del PA
                    foreach (UDP_Plani_tbAFP_Insert_Result Resultado in listAFP)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        // el procedimiento almacenado falló
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                        response = "error";
                    }
                }
                catch (Exception Ex)
                {
                    // se generó una excepción
                    response = "error";
                }

                // el proceso fue exitoso
                response = "bien";
            }
            else
            {
                // el modelo no es válido
                response = "error";
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create([Bind(Include = "isr_RangoInicial,isr_RangoFinal,isr_Porcentaje,tde_IdTipoDedu,isr_UsuarioCrea,isr_FechaCrea")] tbISR tbISR)
        {
            // data de auditoria
            //tbISR.isr_UsuarioCrea = 1;
            //tbISR.isr_FechaCrea = DateTime.Now;

            // variables de resultado del proceso
            string response = String.Empty;
            IEnumerable <object> listISR = null;
            string MensajeError          = "";

            // validar si el modelo es válid
            if (ModelState.IsValid)
            {
                try
                {
                    // ejecutar procedimiento almacenado
                    listISR = db.UDP_Plani_tbISR_Insert(tbISR.isr_RangoInicial,
                                                        tbISR.isr_RangoFinal,
                                                        tbISR.isr_Porcentaje,
                                                        tbISR.tde_IdTipoDedu,
                                                        Function.GetUser(),
                                                        Function.DatetimeNow());

                    // resultado del procedimiento almacenado
                    foreach (UDP_Plani_tbISR_Insert_Result Resultado in listISR)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        // el procedimiento almacenado falló
                        ModelState.AddModelError("", "No se pudo ingresar el registro. Contacte al administrador.");
                        response = "error";
                    }

                    // el proceso fue exitoso
                    response = "bien";
                }
                catch (Exception Ex)
                {
                    // se generó una excepción
                    response = "error";
                }
            }
            else
            {
                // el modelo no es válido
                response = "error";
            }

            // retornar resultado del proceso
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Create([Bind(Include = "insf_DescInstitucionFinanc,insf_Contacto,insf_Telefono,insf_Correo,insf_UsuarioCrea,insf_FechaCrea")] tbInstitucionesFinancieras tbInstitucionesFinancieras)
        {
            // data de auditoria
            //tbInstitucionesFinancieras.insf_UsuarioCrea = 1;
            //tbInstitucionesFinancieras.insf_FechaCrea = DateTime.Now;
            tbInstitucionesFinancieras.insf_Activo = true;

            // variables de resultados
            string response = "bien";
            IEnumerable <object> listInstitucionesFinancieras = null;
            string MensajeError = "";

            // validar si el modelo es válido
            if (ModelState.IsValid)
            {
                try
                {
                    // ejecutar procedimiento almacenado
                    listInstitucionesFinancieras = db.UDP_Plani_tbInstitucionesFinancieras_Insert(tbInstitucionesFinancieras.insf_DescInstitucionFinanc,
                                                                                                  tbInstitucionesFinancieras.insf_Contacto,
                                                                                                  tbInstitucionesFinancieras.insf_Telefono,
                                                                                                  tbInstitucionesFinancieras.insf_Correo,
                                                                                                  Function.GetUser(),
                                                                                                  Function.DatetimeNow(),
                                                                                                  tbInstitucionesFinancieras.insf_Activo);

                    // obtener resultado del procedimiento almacendo
                    foreach (UDP_Plani_tbInstitucionesFinancieras_Insert_Result Resultado in listInstitucionesFinancieras)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        // el procedimiento almacenado falló
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                        response = "error";
                    }
                }
                catch (Exception Ex)
                {
                    // se generó una excepción
                    response = "error";
                }
            }
            else
            {
                // el modelo no es válido
                response = "error";
            }

            // retornar resultado del proceso
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "prea_RangoInicioMeses,prea_RangoFinMeses,prea_DiasPreaviso,prea_UsuarioCrea,prea_FechaCrea,prea_Activo")] tbPreaviso tbPreaviso)
        {
            // data de auditoria
            //tbPreaviso.prea_UsuarioCrea = 1;
            //tbPreaviso.prea_FechaCrea = DateTime.Now;
            tbPreaviso.prea_Activo = true;

            // variables de resultados
            string response = "bien";
            IEnumerable <object> listPreaviso = null;
            String MessageError = "";

            // validar si el modelo es válido
            if (ModelState.IsValid)
            {
                try
                {
                    // ejecutar PA
                    listPreaviso = db.UDP_Plani_tbPreaviso_Insert(tbPreaviso.prea_RangoInicioMeses,
                                                                  tbPreaviso.prea_RangoFinMeses,
                                                                  tbPreaviso.prea_DiasPreaviso,
                                                                  Function.GetUser(),
                                                                  Function.DatetimeNow());

                    // obtener resultado del PA
                    foreach (UDP_Plani_tbPreaviso_Insert_Result resultado in listPreaviso)
                    {
                        MessageError = Convert.ToString(resultado);
                    }

                    if (MessageError.StartsWith("-1"))
                    {
                        // el PA falló
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                        response = "error";
                    }
                }
                catch (Exception Ex)
                {
                    // se generó una excepción
                    ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                    response = "error";
                }
            }
            else
            {
                // el modelo no es válido
                response = "error";
            }

            // retornar resultado del proceso
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public ActionResult Create(tbAuxilioDeCesantias tbAuxilioDeCesantias)
        {
            // Auditoria
            //tbAuxilioDeCesantias.aces_UsuarioCrea = 1;
            //tbAuxilioDeCesantias.aces_FechaCrea = DateTime.Now;
            tbAuxilioDeCesantias.aces_Activo = true;

            // variables de resultados
            string response = String.Empty;
            IEnumerable <object> listAuxCesantias = null;
            string MensajeError = "";

            // validar si el modelo es válido
            if (ModelState.IsValid)
            {
                try
                {
                    // ejecutar procedimiento almacenado
                    listAuxCesantias = db.UDP_Plani_tbAuxilioDeCesantias_Insert(tbAuxilioDeCesantias.aces_RangoInicioMeses,
                                                                                tbAuxilioDeCesantias.aces_RangoFinMeses,
                                                                                tbAuxilioDeCesantias.aces_DiasAuxilioCesantia,
                                                                                Function.GetUser(),
                                                                                Function.DatetimeNow(),
                                                                                tbAuxilioDeCesantias.aces_Activo);
                    // resultado
                    foreach (UDP_Plani_tbAuxilioDeCesantias_Insert_Result Resultado in listAuxCesantias)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        //EN CASO DE OCURRIR UN ERROR, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                        response = "error";
                    }
                }
                catch (Exception Ex)
                {
                    // se generó una excepción
                    response = Ex.Message.ToString();
                }
                response = "bien";
            }
            else
            {
                // el modelo no es válido
                response = "error";
            }

            // retornar resultado del proceso
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "cin_IdIngreso, tc_RangoInicio, tc_RangoFin, tc_PorcentajeComision, tc_UsuarioCrea, tc_FechaCrea")] tbTechosComisiones tbTechosComisiones)
        {
            //Para llenar los campos de auditoría
            //tbTechosComisiones.tc_UsuarioCrea = 1;
            //tbTechosComisiones.tc_FechaCrea = DateTime.Now;

            //Variable para enviarla al lado del Cliente
            string Response = String.Empty;
            IEnumerable <object> listTechosComisiones = null;
            string MensajeError = "";

            if (ModelState.IsValid)
            {
                try
                {
                    //Ejecutar Procedimiento Almacenado
                    listTechosComisiones = db.UDP_Plani_tbTechosComisiones_Insert(tbTechosComisiones.cin_IdIngreso,
                                                                                  tbTechosComisiones.tc_RangoInicio,
                                                                                  tbTechosComisiones.tc_RangoFin,
                                                                                  tbTechosComisiones.tc_PorcentajeComision,
                                                                                  Function.GetUser(),
                                                                                  Function.DatetimeNow());

                    //El tipo complejo del Procedimiento Almacenado
                    foreach (UDP_Plani_tbTechosComisiones_Insert_Result Resultado in listTechosComisiones)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        //En caso de un error igualamos la variable Response a "Error" para validar en el lado del Cliente
                        ModelState.AddModelError("", "No se pudo Registrar. Contacte al Administrador!");
                        Response = "Error";
                    }
                }
                catch (Exception Ex)
                {
                    Response = Ex.Message.ToString();
                }
                //Si llega aqui significa que todo salio correctamente. Solo igualamos Response a "Exito" para validar en el lado del Cliente
                Response = "Exito";
                return(RedirectToAction("Index"));
            }
            else
            {
                //Si el modelo no es valido. Igualamos Response a "Error" para validar en el lado del Cliente
                Response = "Error";
            }
            return(Json(Response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "eqem_Id,dex_MontoInicial,dex_MontoRestante,dex_ObservacionesComentarios,cde_IdDeducciones,dex_Cuota,dex_UsuarioCrea,dex_FechaCrea,dex_DeducirISR")] tbDeduccionesExtraordinarias tbDeduccionesExtraordinarias)
        {
            //Variable para enviar y validar en el FrontEnd
            string Response = String.Empty;
            IEnumerable <object> listDeduccionesExtraordinarias = null;
            string MensajeError = "";

            if (ModelState.IsValid)
            {
                try
                {
                    //Ejecutar Procedimiento Almacenado
                    listDeduccionesExtraordinarias = db.UDP_Plani_tbDeduccionesExtraordinarias_Insert(tbDeduccionesExtraordinarias.eqem_Id,
                                                                                                      tbDeduccionesExtraordinarias.dex_MontoInicial,
                                                                                                      tbDeduccionesExtraordinarias.dex_MontoRestante,
                                                                                                      tbDeduccionesExtraordinarias.dex_ObservacionesComentarios,
                                                                                                      tbDeduccionesExtraordinarias.cde_IdDeducciones,
                                                                                                      tbDeduccionesExtraordinarias.dex_Cuota,
                                                                                                      Function.GetUser(),
                                                                                                      Function.DatetimeNow(),
                                                                                                      tbDeduccionesExtraordinarias.dex_DeducirISR);
                    //El tipo complejo del Procedimiento Almacenado
                    foreach (UDP_Plani_tbDeduccionesExtraordinarias_Insert_Result Resultado in listDeduccionesExtraordinarias)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        //En caso de un error igualamos la variable Response a "Error" para validar en el lado del Cliente
                        ModelState.AddModelError("", "No se pudo Registrar. Contacte al Administrador!");
                        Response = "Error";
                    }
                }
                catch (Exception Ex)
                {
                    Response = Ex.Message.ToString();
                }

                //Si llega aqui significa que todo salio correctamente. Solo igualamos Response a "Exito" para validar en el lado del Cliente
                Response = "Exito";
            }
            else
            {
                //Si el modelo no es valido. Igualamos Response a "Error" para validar en el lado del Cliente
                Response = "Error";
            }

            //Viewbag para sus respectivos Dropdownlist
            ViewBag.cde_IdDeducciones = new SelectList(db.tbCatalogoDeDeducciones, "cde_IdDeducciones", "cde_DescripcionDeduccion", tbDeduccionesExtraordinarias.cde_IdDeducciones);
            ViewBag.eqem_Id           = new SelectList(db.V_DeduccionesExtraordinarias_EquipoEmpleado, "eqem_Id", "per_EquipoEmpleado", tbDeduccionesExtraordinarias.eqem_Id);
            return(Json(Response, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(string dei_Motivo, int emp_Id, decimal dei_Monto, int dei_NumeroCuotas, decimal dei_MontoCuota, bool dei_PagaSiempre, bool dei_DeducirISR)
        {
            tbDeduccionesIndividuales tbDeduccionesIndividuales = new tbDeduccionesIndividuales
            {
                dei_Motivo       = dei_Motivo,
                emp_Id           = emp_Id,
                dei_Monto        = dei_Monto,
                dei_NumeroCuotas = dei_NumeroCuotas,
                dei_MontoCuota   = dei_MontoCuota,
                dei_PagaSiempre  = dei_PagaSiempre,
                dei_DeducirISR   = dei_DeducirISR
            };
            //LLENAR LA DATA DE AUDITORIA, DE NO HACERLO EL MODELO NO SERÍA VÁLIDO Y SIEMPRE CAERÍA EN EL CATCH

            //VARIABLE PARA ALMACENAR EL RESULTADO DEL PROCESO Y ENVIARLO AL LADO DEL CLIENTE
            string response = String.Empty;
            IEnumerable <object> listDeduccionIndividuales = null;
            string MensajeError = "";

            //VALIDAR SI EL MODELO ES VÁLIDO
            if (ModelState.IsValid)
            {
                try
                {
                    //EJECUTAR PROCEDIMIENTO ALMACENADO
                    //(string dei_Motivo, Nullable<int> emp_Id, Nullable<decimal> dei_Monto, Nullable<int> dei_NumeroCuotas, Nullable<decimal> dei_MontoCuotas, Nullable<bool> dei_PagaSiempre, Nullable<int> dei_UsuarioCrea, Nullable<System.DateTime> dei_FechaCrea)
                    listDeduccionIndividuales = db.UDP_Plani_tbDeduccionesIndividuales_Insert(tbDeduccionesIndividuales.dei_Motivo,
                                                                                              tbDeduccionesIndividuales.emp_Id,
                                                                                              tbDeduccionesIndividuales.dei_Monto,
                                                                                              tbDeduccionesIndividuales.dei_NumeroCuotas,
                                                                                              tbDeduccionesIndividuales.dei_MontoCuota,
                                                                                              tbDeduccionesIndividuales.dei_PagaSiempre,
                                                                                              tbDeduccionesIndividuales.dei_Pagado,
                                                                                              Function.GetUser(),
                                                                                              Function.DatetimeNow(),
                                                                                              tbDeduccionesIndividuales.dei_DeducirISR);
                    //RECORRER EL TIPO COMPLEJO DEL PROCEDIMIENTO ALMACENADO PARA EVALUAR EL RESULTADO DEL SP
                    foreach (UDP_Plani_tbDeduccionesIndividuales_Insert_Result Resultado in listDeduccionIndividuales)
                    {
                        MensajeError = Resultado.MensajeError;
                    }

                    if (MensajeError.StartsWith("-1"))
                    {
                        //EN CASO DE OCURRIR UN ERROR, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador");
                        response = "error";
                    }
                }
                catch (Exception Ex)
                {
                    //EN CASO DE CAER EN EL CATCH, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                    response = Ex.Message.ToString();
                }
                //SI LA EJECUCIÓN LLEGA A ESTE PUNTO SIGNIFICA QUE NO OCURRIÓ NINGÚN ERROR Y EL PROCESO FUE EXITOSO
                //IGUALAMOS LA VARIABLE "RESPONSE" A "BIEN" PARA VALIDARLO EN EL CLIENTE
                response = "bien";
            }
            else
            {
                //SI EL MODELO NO ES VÁLIDO, IGUALAMOS LA VARIABLE "RESPONSE" A ERROR PARA VALIDARLO EN EL CLIENTE
                response = "error";
            }
            //RETORNAMOS LA VARIABLE RESPONSE AL CLIENTE PARA EVALUARLA

            return(Json(response, JsonRequestBehavior.AllowGet));
        }