// GET: IngresosIndividuales/Edit/5
        public ActionResult Edit(int?id)
        {
            db.Configuration.ProxyCreationEnabled = false;
            tbIngresosIndividuales tbIngresosIndividualesJSON = db.tbIngresosIndividuales.Find(id);

            return(Json(tbIngresosIndividualesJSON, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(string ini_Motivo, int emp_Id, decimal ini_Monto, bool ini_PagaSiempre)
        {
            tbIngresosIndividuales tbIngresosIndividuales = new tbIngresosIndividuales
            {
                ini_Motivo      = ini_Motivo,
                emp_Id          = emp_Id,
                ini_Monto       = ini_Monto,
                ini_Pagado      = false,
                ini_PagaSiempre = ini_PagaSiempre
            };

            //LLENAR LA DATA DE AUDITORIA, DE NO HACERLO EL MODELO NO SERÍA VÁLIDO Y SIEMPRE CAERÍA EN EL CATCH
            tbIngresosIndividuales.ini_UsuarioCrea = 1;
            tbIngresosIndividuales.ini_FechaCrea   = DateTime.Now;
            //VARIABLE PARA ALMACENAR EL RESULTADO DEL PROCESO Y ENVIARLO AL LADO DEL CLIENTE
            string response = String.Empty;
            IEnumerable <object> listIngresosIndividuales = null;
            string MensajeError = "";

            //VALIDAR SI EL MODELO ES VÁLIDO
            if (ModelState.IsValid)
            {
                try
                {
                    //EJECUTAR PROCEDIMIENTO ALMACENADO
                    listIngresosIndividuales = db.UDP_Plani_tbIngresosIndividuales_Insert(tbIngresosIndividuales.ini_Motivo,
                                                                                          tbIngresosIndividuales.emp_Id,
                                                                                          tbIngresosIndividuales.ini_Monto,
                                                                                          tbIngresosIndividuales.ini_Pagado,
                                                                                          tbIngresosIndividuales.ini_PagaSiempre,
                                                                                          tbIngresosIndividuales.ini_UsuarioCrea,
                                                                                          tbIngresosIndividuales.ini_FechaCrea);
                    //RECORRER EL TIPO COMPLEJO DEL PROCEDIMIENTO ALMACENADO PARA EVALUAR EL RESULTADO DEL SP
                    foreach (UDP_Plani_tbIngresosIndividuales_Insert_Result Resultado in listIngresosIndividuales)
                    {
                        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));
        }