Exemplo n.º 1
0
        public async Task <Boolean> getAllMaquinas()
        {
            var bounds = UIScreen.MainScreen.Bounds;

            loadPop = new LoadingOverlay(bounds, "Buscando Maquinas ...");
            View.Add(loadPop);

            client = new HttpClient();
            string url = Consts.ulrserv + "maquinas/getListadoMaquinas";
            var    uri = new Uri(string.Format(url));

            var json = "";

            string responseString = string.Empty;

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

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

            JArray jrarray;

            try
            {
                var jsonresponse = JArray.Parse(responseString);
                jrarray = jsonresponse;
            }
            catch (Exception e)
            {
                loadPop.Hide();
                var jsonresponse = JObject.Parse(responseString);

                string mensaje = "error al traer maquinas del servidor: " + e.HResult;

                var jtokenerror = jsonresponse["error"];
                if (jtokenerror != null)
                {
                    mensaje = jtokenerror.ToString();
                }

                funciones.MessageBox("Error", mensaje);
                return(false);
            }


            foreach (var maquina in jrarray)
            {
                clsListadoMaquinas objm = getobjMaquina(maquina);
                lstMaqServ.Add(objm);
            }


            return(true);
        }
Exemplo n.º 2
0
        public clsListadoMaquinas getobjMaquina(Object varjson)
        {
            clsListadoMaquinas objmaq = new clsListadoMaquinas();
            JObject            json   = (JObject)varjson;

            objmaq.noserie       = json["noserie"].ToString();
            objmaq.noeconomico   = Int32.Parse(json["noeconomico"].ToString());
            objmaq.marca         = json["marca"].ToString();
            objmaq.modelo        = json["modelo"].ToString();
            objmaq.IdTipoMaquina = Int32.Parse(json["idtipomaquina"].ToString());
            objmaq.tieneReporte  = Int32.Parse(json["tieneReporte"].ToString());


            return(objmaq);
        }
Exemplo n.º 3
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            if (isChild(indexPath))
            {
                //Handle selection of child cell


                if (indexPath.Row == currentExpandedIndex + 1)
                {
                    clsListadoMaquinas maquina = lstmaq.ElementAt(currentExpandedIndex);

                    ReporteOperador viewro = new ReporteOperador();
                    viewro.Title = "Reporte Operador";

                    viewro.strNoeconomico = maquina.noeconomico.ToString();
                    viewro.strModelo      = maquina.modelo.ToString();
                    viewro.strNoSerie     = maquina.noserie;
                    viewro.viewmaq        = viewparent;

                    viewparent.NavigationController.PushViewController(viewro, false);
                    UIView.BeginAnimations(null);
                    UIView.SetAnimationDuration(0.7);
                    UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromRight, viewparent.NavigationController.View, true);
                    UIView.CommitAnimations();

                    tableView.DeselectRow(indexPath, true);
                    return;
                }
                else
                {
                    if (indexPath.Row == currentExpandedIndex + 2)
                    {
                        clsListadoMaquinas maquina = lstmaq.ElementAt(currentExpandedIndex);
                        ReporteServicio    viewrs  = new ReporteServicio();
                        viewrs.Title      = "Reporte Servicio";
                        viewrs.strNoSerie = maquina.noserie;
                        viewrs.viewmaq    = viewparent;

                        viewparent.NavigationController.PushViewController(viewrs, false);
                        UIView.BeginAnimations(null);
                        UIView.SetAnimationDuration(0.7);
                        UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromRight, viewparent.NavigationController.View, true);
                        UIView.CommitAnimations();

                        tableView.DeselectRow(indexPath, true);
                        return;
                    }
                    else
                    {
                        clsListadoMaquinas maquina = lstmaq.ElementAt(currentExpandedIndex);

                        FichaMaquinaController viewfm = new FichaMaquinaController();
                        viewfm.Title      = "Ficha Tecnica de la Maquina";
                        viewfm.viewmaq    = viewparent;
                        viewfm.strNoserie = maquina.noserie;


                        viewparent.NavigationController.PushViewController(viewfm, false);
                        UIView.BeginAnimations(null);
                        UIView.SetAnimationDuration(0.7);
                        UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromRight, viewparent.NavigationController.View, true);
                        UIView.CommitAnimations();

                        tableView.DeselectRow(indexPath, true);
                        return;
                    }
                }
            }

            tableView.BeginUpdates();
            if (currentExpandedIndex == indexPath.Row)
            {
                this.collapseSubItemsAtIndex(tableView, currentExpandedIndex);
                currentExpandedIndex = -1;
            }
            else
            {
                var shouldCollapse = currentExpandedIndex > -1;
                if (shouldCollapse)
                {
                    this.collapseSubItemsAtIndex(tableView, currentExpandedIndex);
                }
                currentExpandedIndex = (shouldCollapse && indexPath.Row > currentExpandedIndex) ? indexPath.Row - 3 : indexPath.Row;
                this.expandItemAtIndex(tableView, currentExpandedIndex);
            }
            tableView.EndUpdates();
            tableView.DeselectRow(indexPath, true);
        }
Exemplo n.º 4
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            if (isChild(indexPath))
            {
                var cell = tableView.DequeueReusableCell(ChildCellIndentifier);
                if (cell == null)
                {
                    cell = new UITableViewCell(UITableViewCellStyle.Subtitle, ChildCellIndentifier);
                }

                if (indexPath.Row == currentExpandedIndex + 1)
                {
                    cell.TextLabel.Text = "Reporte de Operador";
                }
                else
                {
                    if (indexPath.Row == currentExpandedIndex + 2)
                    {
                        cell.TextLabel.Text = "Reporte de Servicio";
                    }
                    else
                    {
                        cell.TextLabel.Text = "Ficha de Maquina";
                    }
                }
                cell.TextLabel.TextColor         = UIColor.FromRGB(54, 74, 97);
                cell.ImageView.Image             = null;
                cell.Accessory                   = UITableViewCellAccessory.DisclosureIndicator;
                cell.ContentView.BackgroundColor = UIColor.FromRGB(217, 215, 213);
                return(cell);
            }
            else
            {
                int indicearreglo = indexPath.Row;

                if (currentExpandedIndex > -1 && indexPath.Row > currentExpandedIndex)
                {
                    indicearreglo -= 3;
                }

                UITableViewCell cell;
                if (indicearreglo % 2 == 0)
                {
                    cell = tableView.DequeueReusableCell(ParentCellIdentifierWhite) as CustomMaquinasCellWhite;
                    if (cell == null)
                    {
                        cell = new CustomMaquinasCellWhite((NSString)ParentCellIdentifierWhite);
                    }
                }
                else
                {
                    cell = tableView.DequeueReusableCell(ParentCellIdentifierBlack) as CustomMaquinasCellBlack;
                    if (cell == null)
                    {
                        cell = new CustomMaquinasCellBlack((NSString)ParentCellIdentifierBlack);
                    }
                }

                clsListadoMaquinas maquina = lstmaq.ElementAt(indicearreglo);

                UIImage imgmaq     = null;
                String  strtipomaq = "";

                switch (maquina.IdTipoMaquina)
                {
                case 1: imgmaq = UIImage.FromFile("excabadora.png"); break;

                case 2: imgmaq = UIImage.FromFile("revolvedora.png"); break;

                case 3: imgmaq = UIImage.FromFile("trascabo.png"); break;

                default: imgmaq = UIImage.FromFile("trascabo.png"); break;
                }

                strtipomaq = Consts.tipomaquinas[maquina.IdTipoMaquina - 1];

                String leyenda = "Marca: " + maquina.marca + "   Modelo: " + maquina.modelo;

                UIImage imagesem;

                if (maquina.tieneReporte == 1)
                {
                    imagesem = UIImage.FromFile("red.png");
                }
                else
                {
                    imagesem = UIImage.FromFile("green.png");
                }


                ((CustomMaquinasCell)cell).UpdateCell(strtipomaq, leyenda, imgmaq, imagesem);


                cell.Accessory = UITableViewCellAccessory.None;
                return(cell);
            }
        }