示例#1
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            int indicearreglo = indexPath.Row;

            UITableViewCell  cell;
            clsClasificacion objclas = lstCalsificacion.ElementAt(indicearreglo);

            if (indicearreglo % 2 == 0)
            {
                cell = tableView.DequeueReusableCell(celdaGraficasBlack) as CustomGraficaCellBlack;

                if (cell == null)
                {
                    cell = new CustomGraficaCellBlack((NSString)celdaGraficasBlack, objclas.color);
                }
            }
            else
            {
                cell = tableView.DequeueReusableCell(celdaGraficasWhite) as CustomGraficaCellWhite;

                if (cell == null)
                {
                    cell = new CustomGraficaCellWhite((NSString)celdaGraficasWhite, objclas.color);
                }
            }

            String strpor = objclas.porcentaje.ToString() + " % ";


            ((CustomGraficaCell)cell).UpdateCell(objclas.nombre, strpor);

            return(cell);
        }
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            int indicearreglo = indexPath.Row;

            clsClasificacion objclas = lstCalsificacion.ElementAt(indicearreglo);
            UITableViewCell  cell;

            if (indicearreglo % 2 == 0)
            {
                string idcell = celdaCategoriasBlack + objclas.idclasificacion.ToString() + objclas.porcentaje.ToString();
                cell = tableView.DequeueReusableCell(idcell) as CustomCategoriasCellBlack;

                if (cell == null)
                {
                    cell = new CustomCategoriasCellBlack((NSString)idcell, objclas.porcentaje);
                }
            }
            else
            {
                string idcell = celdaCategoriasWhite + objclas.idclasificacion.ToString() + objclas.porcentaje.ToString();
                cell = tableView.DequeueReusableCell(idcell) as CustomCategoriasCellWhite;

                if (cell == null)
                {
                    cell = new CustomCategoriasCellWhite((NSString)idcell, objclas.porcentaje);
                }
            }

            String strTareas = objclas.notareas + " tareas";

            ((CustomCategoriasCell)cell).UpdateCell(objclas.nombre, strTareas);
            cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton;

            return(cell);
        }
        private clsClasificacion getObjClas(Object varjson)
        {
            int indicecolor = funciones.getNumeroAleatorioSinRepetir(0, 9, arrnumusados);

            JObject          json  = (JObject)varjson;
            clsClasificacion objob = new clsClasificacion
            {
                idclasificacion = Int32.Parse(json["idcategoria"].ToString()),
                nombre          = json["nombre"].ToString(),
                porcentaje      = float.Parse(json["porcentaje"].ToString()),
                notareas        = Int32.Parse(json["notareas"].ToString()),
                color           = Consts.colores[indicecolor],
                strcolor        = Consts.strcolores[indicecolor]
            };

            arrnumusados.Add(indicecolor);
            return(objob);
        }
        public async Task <Boolean> searchCategorias()
        {
            var bounds = UIScreen.MainScreen.Bounds;

            loadPop = new LoadingOverlay(bounds, "Buscando Categorias...");
            View.Add(loadPop);
            client         = new HttpClient();
            client.Timeout = new System.TimeSpan(0, 0, 0, 10, 0);
            string url = Consts.ulrserv + "controldeobras/BuscarCategorias";
            var    uri = new Uri(string.Format(url));
            Dictionary <string, string> pet = new Dictionary <string, string>();

            pet.Add("idobra", idobra.ToString());
            pet.Add("strBusqueda", txtbusquedaCategoria.Text);

            var json = JsonConvert.SerializeObject(pet);

            string responseString = string.Empty;

            responseString = await funciones.llamadaRest(client, uri, loadPop, json, Consts.token);


            if (responseString.Equals("-1") || responseString.Equals("-2"))
            {
                funciones.SalirSesion(this);
            }

            JArray jrarray;

            try
            {
                var objectjson = JObject.Parse(responseString);

                var result = objectjson["result"];
                if (result != null)
                {
                    loadPop.Hide();
                    if (result.ToString().Equals("0"))
                    {
                        funciones.MessageBox("Aviso", "Sin categorias para mostrar");
                    }
                    else
                    {
                        funciones.MessageBox("Error", objectjson["error"].ToString());
                    }
                    return(false);
                }

                jrarray = JArray.Parse(objectjson["categorias"].ToString());
            }
            catch (Exception e)
            {
                loadPop.Hide();
                var    jsonresponse = JObject.Parse(responseString);
                string mensaje      = "al transformar el arreglo" + e.HResult;
                var    jtokenerror  = jsonresponse["error"];
                if (jtokenerror != null)
                {
                    mensaje = jtokenerror.ToString();
                }
                funciones.MessageBox("Error", mensaje);
                return(false);
            }

            arrnumusados = new List <int>();

            foreach (var obra in jrarray)
            {
                clsClasificacion objob = getObjClas(obra);
                lstClas.Add(objob);
            }
            loadPop.Hide();
            return(true);
        }