public void AttempGuardarFinalizar()
        {
            this.IsEnabled     = false;
            this.BotonImprimir = true;

            long UnidSegmento;

            UnidSegmento = UNID.getNewUNID();
            DateTime d = DateTime.Now;

            InventarioDataMapper iDM_ = new InventarioDataMapper();

            iDM_.delete(catalogInvViewModel.SelectedInventario.UnidSegmento, this.ActualUser);

            foreach (Descriptor ii in DescriptorCollection)
            {
                if (!String.IsNullOrEmpty(ii.DescriptorName))
                {
                    InventarioDataMapper iDM = new InventarioDataMapper();
                    for (int i = 0; i < ii.Cantidad; i++)
                    {
                        iDM.insert(new INVENTARIO()
                        {
                            DESCRIPTOR = ii.DescriptorName, UNID_SEGMENTO = UnidSegmento, UNID_ALMACEN = this.SelectedAlmacen.UNID_ALMACEN, FECHA = d, FINISHED = true
                        }, this.ActualUser);
                    }
                }
            }
            this.catalogInvViewModel.InventarioCollection = this.catalogInvViewModel.GetInventarios();
        }
        public ObservableCollection <InventarioModel> GetInventarios()
        {
            InventarioDataMapper iDM = new InventarioDataMapper();
            ObservableCollection <InventarioModel> res = new ObservableCollection <InventarioModel>();
            List <INVENTARIO> aux = new List <INVENTARIO>();

            aux = (List <INVENTARIO>)iDM.getElements();

            long            segmentoAux = 0;
            InventarioModel fin         = new InventarioModel();

            fin.Descriptores = new ObservableCollection <Descriptor>();

            if (aux != null && aux.Count > 0)
            {
                segmentoAux = aux[0].UNID_SEGMENTO;
            }

            foreach (INVENTARIO ii in aux)
            {
                if (ii.UNID_SEGMENTO != segmentoAux)
                {
                    res.Add(fin);
                    segmentoAux      = ii.UNID_SEGMENTO;
                    fin              = new InventarioModel();
                    fin.Descriptores = new ObservableCollection <Descriptor>();
                }

                bool auxbool = true;
                for (int i = 0; i < fin.Descriptores.Count; i++)
                {
                    if (fin.Descriptores[i].DescriptorName.Equals(ii.DESCRIPTOR))
                    {
                        fin.Descriptores[i].Cantidad++;
                        fin.Cantidad = fin.Descriptores.Sum(p => p.Cantidad);
                        auxbool      = false;
                    }
                }

                if (auxbool)
                {
                    fin.UnidSegmento    = ii.UNID_SEGMENTO;
                    fin.SelectedAlmacen = ii.ALMACEN;
                    fin.IsChecked       = false;
                    fin.Finished        = ii.FINISHED;
                    fin.Fecha           = ii.FECHA;
                    Descriptor dd = new Descriptor();
                    dd.DescriptorName = ii.DESCRIPTOR;
                    dd.IsChecked      = false;
                    dd.Cantidad       = 1;
                    fin.Descriptores.Add(dd);
                    fin.Cantidad = fin.Descriptores.Sum(p => p.Cantidad);
                }
            }

            res.Add(fin);

            return(res);
        }
Пример #3
0
        public string downloadInventario(long?lastModifiedDate)
        {
            string respuesta = null;

            if (lastModifiedDate != null)
            {
                InventarioDataMapper dataMapper = new InventarioDataMapper();

                respuesta = dataMapper.GetJsonInventarios(lastModifiedDate);

                if (String.IsNullOrEmpty(respuesta))
                {
                    respuesta = null;
                }
            }

            return(respuesta);
        }