Exemple #1
0
        public ActionResult Post(bool IsNew, Detalle_Aseguramiento_de_PlantiosModel varDetalle_Aseguramiento_de_Plantios)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_Aseguramiento_de_PlantiosApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_Aseguramiento_de_PlantiosInfo = new Detalle_Aseguramiento_de_Plantios
                    {
                        Clave = varDetalle_Aseguramiento_de_Plantios.Clave
                        , Motivo_de_Registro = varDetalle_Aseguramiento_de_Plantios.Motivo_de_Registro
                        , Tipo                  = varDetalle_Aseguramiento_de_Plantios.Tipo
                        , No__de_Plantios       = varDetalle_Aseguramiento_de_Plantios.No__de_Plantios
                        , Kilogramos            = varDetalle_Aseguramiento_de_Plantios.Kilogramos
                        , Metodo_de_Destruccion = varDetalle_Aseguramiento_de_Plantios.Metodo_de_Destruccion
                        , Superficie            = varDetalle_Aseguramiento_de_Plantios.Superficie
                        , Altura                = varDetalle_Aseguramiento_de_Plantios.Altura
                        , Densidad              = varDetalle_Aseguramiento_de_Plantios.Densidad
                        , Peso_por_planta       = varDetalle_Aseguramiento_de_Plantios.Peso_por_planta
                        , Latitud               = varDetalle_Aseguramiento_de_Plantios.Latitud
                        , Longitud              = varDetalle_Aseguramiento_de_Plantios.Longitud
                        , Largo                 = varDetalle_Aseguramiento_de_Plantios.Largo
                        , Ancho                 = varDetalle_Aseguramiento_de_Plantios.Ancho
                    };

                    result = !IsNew?
                             _IDetalle_Aseguramiento_de_PlantiosApiConsumer.Update(Detalle_Aseguramiento_de_PlantiosInfo, null, null).Resource.ToString() :
                                 _IDetalle_Aseguramiento_de_PlantiosApiConsumer.Insert(Detalle_Aseguramiento_de_PlantiosInfo, null, null).Resource.ToString();

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #2
0
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            int ModuleId   = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 45537);

            ViewBag.Permission = permission;
            var varDetalle_Aseguramiento_de_Plantios = new Detalle_Aseguramiento_de_PlantiosModel();

            ViewBag.ObjectId  = "45537";
            ViewBag.Operation = "New";

            ViewBag.IsNew = true;



            if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0"))
            {
                ViewBag.IsNew     = false;
                ViewBag.Operation = "Update";
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IDetalle_Aseguramiento_de_PlantiosApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Detalle_Aseguramiento_de_PlantiosData = _IDetalle_Aseguramiento_de_PlantiosApiConsumer.GetByKeyComplete(Id).Resource.Detalle_Aseguramiento_de_Plantioss[0];
                if (Detalle_Aseguramiento_de_PlantiosData == null)
                {
                    return(HttpNotFound());
                }

                varDetalle_Aseguramiento_de_Plantios = new Detalle_Aseguramiento_de_PlantiosModel
                {
                    Clave = (int)Detalle_Aseguramiento_de_PlantiosData.Clave
                    , Motivo_de_Registro            = Detalle_Aseguramiento_de_PlantiosData.Motivo_de_Registro
                    , Motivo_de_RegistroDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Aseguramiento_de_PlantiosData.Motivo_de_Registro), "Motivo_de_Registro") ?? (string)Detalle_Aseguramiento_de_PlantiosData.Motivo_de_Registro_Motivo_de_Registro.Descripcion
                    , Tipo                             = Detalle_Aseguramiento_de_PlantiosData.Tipo
                    , TipoDescripcion                  = CultureHelper.GetTraduction(Convert.ToString(Detalle_Aseguramiento_de_PlantiosData.Tipo), "Tipo_de_Plantio") ?? (string)Detalle_Aseguramiento_de_PlantiosData.Tipo_Tipo_de_Plantio.Descripcion
                    , No__de_Plantios                  = Detalle_Aseguramiento_de_PlantiosData.No__de_Plantios
                    , Kilogramos                       = Detalle_Aseguramiento_de_PlantiosData.Kilogramos
                    , Metodo_de_Destruccion            = Detalle_Aseguramiento_de_PlantiosData.Metodo_de_Destruccion
                    , Metodo_de_DestruccionDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Aseguramiento_de_PlantiosData.Metodo_de_Destruccion), "Metodo_de_Destruccion") ?? (string)Detalle_Aseguramiento_de_PlantiosData.Metodo_de_Destruccion_Metodo_de_Destruccion.Descripcion
                    , Superficie                       = Detalle_Aseguramiento_de_PlantiosData.Superficie
                    , Altura                           = Detalle_Aseguramiento_de_PlantiosData.Altura
                    , Densidad                         = Detalle_Aseguramiento_de_PlantiosData.Densidad
                    , Peso_por_planta                  = Detalle_Aseguramiento_de_PlantiosData.Peso_por_planta
                    , Latitud                          = Detalle_Aseguramiento_de_PlantiosData.Latitud
                    , Longitud                         = Detalle_Aseguramiento_de_PlantiosData.Longitud
                    , Largo                            = Detalle_Aseguramiento_de_PlantiosData.Largo
                    , Ancho                            = Detalle_Aseguramiento_de_PlantiosData.Ancho
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _IMotivo_de_RegistroApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Motivo_de_Registros_Motivo_de_Registro = _IMotivo_de_RegistroApiConsumer.SelAll(true);

            if (Motivo_de_Registros_Motivo_de_Registro != null && Motivo_de_Registros_Motivo_de_Registro.Resource != null)
            {
                ViewBag.Motivo_de_Registros_Motivo_de_Registro = Motivo_de_Registros_Motivo_de_Registro.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Motivo_de_Registro", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }
            _ITipo_de_PlantioApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Tipo_de_Plantios_Tipo = _ITipo_de_PlantioApiConsumer.SelAll(true);

            if (Tipo_de_Plantios_Tipo != null && Tipo_de_Plantios_Tipo.Resource != null)
            {
                ViewBag.Tipo_de_Plantios_Tipo = Tipo_de_Plantios_Tipo.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Tipo_de_Plantio", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }
            _IMetodo_de_DestruccionApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Metodo_de_Destruccions_Metodo_de_Destruccion = _IMetodo_de_DestruccionApiConsumer.SelAll(true);

            if (Metodo_de_Destruccions_Metodo_de_Destruccion != null && Metodo_de_Destruccions_Metodo_de_Destruccion.Resource != null)
            {
                ViewBag.Metodo_de_Destruccions_Metodo_de_Destruccion = Metodo_de_Destruccions_Metodo_de_Destruccion.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Metodo_de_Destruccion", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varDetalle_Aseguramiento_de_Plantios));
        }
Exemple #3
0
        public ActionResult AddDetalle_Aseguramiento_de_Plantios(int rowIndex = 0, int functionMode = 0, int id = 0)
        {
            int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;

            ViewBag.currentRowIndex = rowIndex;
            ViewBag.functionMode    = functionMode;
            ViewBag.Consult         = false;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 45537);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _IDetalle_Aseguramiento_de_PlantiosApiConsumer.SetAuthHeader(_tokenManager.Token);
            Detalle_Aseguramiento_de_PlantiosModel varDetalle_Aseguramiento_de_Plantios = new Detalle_Aseguramiento_de_PlantiosModel();


            if (id.ToString() != "0")
            {
                var Detalle_Aseguramiento_de_PlantiossData = _IDetalle_Aseguramiento_de_PlantiosApiConsumer.ListaSelAll(0, 1000, "Detalle_Aseguramiento_de_Plantios.Clave=" + id, "").Resource.Detalle_Aseguramiento_de_Plantioss;

                if (Detalle_Aseguramiento_de_PlantiossData != null && Detalle_Aseguramiento_de_PlantiossData.Count > 0)
                {
                    var Detalle_Aseguramiento_de_PlantiosData = Detalle_Aseguramiento_de_PlantiossData.First();
                    varDetalle_Aseguramiento_de_Plantios = new Detalle_Aseguramiento_de_PlantiosModel
                    {
                        Clave = Detalle_Aseguramiento_de_PlantiosData.Clave
                        , Motivo_de_Registro            = Detalle_Aseguramiento_de_PlantiosData.Motivo_de_Registro
                        , Motivo_de_RegistroDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Aseguramiento_de_PlantiosData.Motivo_de_Registro), "Motivo_de_Registro") ?? (string)Detalle_Aseguramiento_de_PlantiosData.Motivo_de_Registro_Motivo_de_Registro.Descripcion
                        , Tipo                             = Detalle_Aseguramiento_de_PlantiosData.Tipo
                        , TipoDescripcion                  = CultureHelper.GetTraduction(Convert.ToString(Detalle_Aseguramiento_de_PlantiosData.Tipo), "Tipo_de_Plantio") ?? (string)Detalle_Aseguramiento_de_PlantiosData.Tipo_Tipo_de_Plantio.Descripcion
                        , No__de_Plantios                  = Detalle_Aseguramiento_de_PlantiosData.No__de_Plantios
                        , Kilogramos                       = Detalle_Aseguramiento_de_PlantiosData.Kilogramos
                        , Metodo_de_Destruccion            = Detalle_Aseguramiento_de_PlantiosData.Metodo_de_Destruccion
                        , Metodo_de_DestruccionDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Aseguramiento_de_PlantiosData.Metodo_de_Destruccion), "Metodo_de_Destruccion") ?? (string)Detalle_Aseguramiento_de_PlantiosData.Metodo_de_Destruccion_Metodo_de_Destruccion.Descripcion
                        , Superficie                       = Detalle_Aseguramiento_de_PlantiosData.Superficie
                        , Altura                           = Detalle_Aseguramiento_de_PlantiosData.Altura
                        , Densidad                         = Detalle_Aseguramiento_de_PlantiosData.Densidad
                        , Peso_por_planta                  = Detalle_Aseguramiento_de_PlantiosData.Peso_por_planta
                        , Latitud                          = Detalle_Aseguramiento_de_PlantiosData.Latitud
                        , Longitud                         = Detalle_Aseguramiento_de_PlantiosData.Longitud
                        , Largo                            = Detalle_Aseguramiento_de_PlantiosData.Largo
                        , Ancho                            = Detalle_Aseguramiento_de_PlantiosData.Ancho
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _IMotivo_de_RegistroApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Motivo_de_Registros_Motivo_de_Registro = _IMotivo_de_RegistroApiConsumer.SelAll(true);

            if (Motivo_de_Registros_Motivo_de_Registro != null && Motivo_de_Registros_Motivo_de_Registro.Resource != null)
            {
                ViewBag.Motivo_de_Registros_Motivo_de_Registro = Motivo_de_Registros_Motivo_de_Registro.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Motivo_de_Registro", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }
            _ITipo_de_PlantioApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Tipo_de_Plantios_Tipo = _ITipo_de_PlantioApiConsumer.SelAll(true);

            if (Tipo_de_Plantios_Tipo != null && Tipo_de_Plantios_Tipo.Resource != null)
            {
                ViewBag.Tipo_de_Plantios_Tipo = Tipo_de_Plantios_Tipo.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Tipo_de_Plantio", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }
            _IMetodo_de_DestruccionApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Metodo_de_Destruccions_Metodo_de_Destruccion = _IMetodo_de_DestruccionApiConsumer.SelAll(true);

            if (Metodo_de_Destruccions_Metodo_de_Destruccion != null && Metodo_de_Destruccions_Metodo_de_Destruccion.Resource != null)
            {
                ViewBag.Metodo_de_Destruccions_Metodo_de_Destruccion = Metodo_de_Destruccions_Metodo_de_Destruccion.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Metodo_de_Destruccion", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }


            return(PartialView("AddDetalle_Aseguramiento_de_Plantios", varDetalle_Aseguramiento_de_Plantios));
        }