private string DetalleXML()
        {
            string vrCadena = string.Empty;

            vrCadena = "<ROOT>";
            CollectionVMSGR_CartaDiaDetalleCategoria.ToList().ForEach(x =>
            {
                x.CollectionVMSGR_CartaDiaDetalleSubCategoria.ToList().ForEach(r =>
                {
                    r.CollectionESGR_CartaDiaDetalle.ToList().ForEach(f =>
                    {
                        vrCadena += "<Listar";
                        vrCadena += " xIdCartaDia = \'" + f.IdCartaDia;
                        vrCadena += "\' xItem = \'" + f.Item;
                        vrCadena += "\' xIdProducto = \'" + f.ESGR_Producto.IdProducto;
                        vrCadena += "\' xCantidad  = \'" + f.Cantidad;
                        vrCadena += "\' xPrecio = \'" + f.Precio;
                        vrCadena += "\' xStock   = \'" + f.Stock;
                        vrCadena += "\' xObservacion = \'" + f.Observacion;
                        vrCadena += "\'></Listar>";
                    });
                });
            });
            vrCadena += "</ROOT>";
            return(vrCadena);
        }
예제 #2
0
        private CmpObservableCollection <ESGR_CartaDiaDetalle> MethodCartaDia()
        {
            var CollectionESGR_Carta = new CmpObservableCollection <ESGR_CartaDiaDetalle>();

            CollectionVMSGR_CartaDiaDetalleCategoria.ToList().ForEach(x =>
            {
                x.CollectionVMSGR_CartaDiaDetalleSubCategoria.ToList().ForEach(z =>
                {
                    z.CollectionESGR_CartaDiaDetalle.ToList().ForEach(s =>
                    {
                        if (s.CartaDia)
                        {
                            CollectionESGR_Carta.Add(new ESGR_CartaDiaDetalle()
                            {
                                Cantidad      = s.Cantidad,
                                Precio        = s.Precio,
                                Stock         = s.Stock,
                                ESGR_Producto = s.ESGR_Producto,
                                Producto      = s.ESGR_Producto.Producto,
                                SubCategoria  = s.ESGR_Producto.ESGR_ProductoSubCategoria.SubCategoria,
                                Categoria     = s.ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria.Categoria
                            });
                        }
                    });
                });
            });
            return(CollectionESGR_Carta);
        }
        private void MethodQuitar()
        {
            var vrCollectionESGR_CartiaDiaDetalle = new CmpObservableCollection <ESGR_CartaDiaDetalle>();
            var vrCollectionESGR_VMSubCategoria   = new CmpObservableCollection <VMSGR_CartaDiaDetalleSubCategoria>();
            var vrCollectionESGR_VMCategoria      = new CmpObservableCollection <VMSGR_CartaDiaDetalleCategoria>();

            foreach (var item in CollectionVMSGR_CartaDiaDetalleCategoria)
            {
                foreach (var items in item.CollectionVMSGR_CartaDiaDetalleSubCategoria)
                {
                    vrCollectionESGR_CartiaDiaDetalle = new CmpObservableCollection <ESGR_CartaDiaDetalle>(items.CollectionESGR_CartaDiaDetalle);
                    foreach (ESGR_CartaDiaDetalle vrItems in vrCollectionESGR_CartiaDiaDetalle)
                    {
                        if (vrItems.Stock < vrItems.Cantidad && vrItems.ESGR_Producto.IsCheckeQuitar && ESGR_CartaDia.Opcion == "U")
                        {
                            CmpMessageBox.Show(SGRMessage.AdministratorCartaDia, "No se puede quitar algunos Producto debido a que ya existen Pedidos", CmpButton.Aceptar);
                            vrItems.ESGR_Producto.IsCheckeQuitar = false;
                        }
                        else
                        {
                            if (vrItems.ESGR_Producto.IsCheckeQuitar)
                            {
                                items.CollectionESGR_CartaDiaDetalle.Remove(vrItems);
                            }
                        }
                    }
                }
            }

            #region  QUITA CATEGORIA Y SUBCATEGORIA

            vrCollectionESGR_VMCategoria = new CmpObservableCollection <VMSGR_CartaDiaDetalleCategoria>(CollectionVMSGR_CartaDiaDetalleCategoria);
            foreach (var item in vrCollectionESGR_VMCategoria)
            {
                vrCollectionESGR_VMSubCategoria = new CmpObservableCollection <VMSGR_CartaDiaDetalleSubCategoria>(item.CollectionVMSGR_CartaDiaDetalleSubCategoria);
                foreach (VMSGR_CartaDiaDetalleSubCategoria items in vrCollectionESGR_VMSubCategoria)
                {
                    if (items.CollectionESGR_CartaDiaDetalle.Count() == 0)
                    {
                        item.CollectionVMSGR_CartaDiaDetalleSubCategoria.Remove(items);
                    }
                }

                if (item.CollectionVMSGR_CartaDiaDetalleSubCategoria.Count() == 0)
                {
                    CollectionVMSGR_CartaDiaDetalleCategoria.Remove(item);
                }
            }
            MethodContador();
            #endregion
        }
예제 #4
0
 private async void MethodCompare(ESGR_CartaDiaDetalle ESGR_CartaDiaDetalle)
 {
     await Task.Factory.StartNew(() =>
     {
         try
         {
             CollectionVMSGR_CartaDiaDetalleCategoria.ToList().ForEach(x =>
             {
                 x.CollectionVMSGR_CartaDiaDetalleSubCategoria.ToList().ForEach(Z =>
                 {
                     Z.CollectionESGR_CartaDiaDetalle.ToList().ForEach(s =>
                     {
                         if (CollectionESGR_CartaDiaDetalle.Count() > 0)
                         {
                             CollectionESGR_CartaDiaDetalle.ToList().ForEach(d =>
                             {
                                 var Firts = Z.CollectionESGR_CartaDiaDetalle.ToList().Exists(r => r.ESGR_Producto.IdProducto == ESGR_CartaDiaDetalle.ESGR_Producto.IdProducto);
                                 if (Firts)
                                 {
                                     var TempProducto = Z.CollectionESGR_CartaDiaDetalle.FirstOrDefault(f => f.ESGR_Producto.IdProducto == ESGR_CartaDiaDetalle.ESGR_Producto.IdProducto);
                                     if (TempProducto == null)
                                     {
                                         return;
                                     }
                                     TempProducto.Precio      = ESGR_CartaDiaDetalle.Precio;
                                     TempProducto.Observacion = ESGR_CartaDiaDetalle.Observacion;
                                     TempProducto.Cantidad    = ESGR_CartaDiaDetalle.Cantidad;
                                     TempProducto.CartaDia    = true;
                                 }
                             });
                         }
                         else
                         {
                             s.CartaDia = false;
                         }
                     });
                 });
             });
         }
         catch (Exception ex)
         {
             CmpMessageBox.Show(SGRMessage.AdministratorCartaDia, ex.Message, CmpButton.Aceptar);
         }
     });
 }
        private void MethodAddDetails(ESGR_CartaDiaDetalle ESGR_CartaDiaDetalle)
        {
            if (ESGR_CartaDiaDetalle == null)
            {
                return;
            }
            if (ESGR_CartaDiaDetalle.ESGR_Producto == null)
            {
                return;
            }
            if (ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria == null)
            {
                return;
            }
            if (ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria == null)
            {
                return;
            }

            var NameCategoria    = ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria.Categoria;
            var NameSubCategoria = ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria.SubCategoria;

            //===================NO EXISTE CATEGORÍA============================//
            var IsExistCategoria = CollectionVMSGR_CartaDiaDetalleCategoria.ToList().Exists(x => x.Categoria == NameCategoria);

            if (!IsExistCategoria)
            {
                CollectionVMSGR_CartaDiaDetalleCategoria.Add(new VMSGR_CartaDiaDetalleCategoria()
                {
                    Categoria = NameCategoria,
                    CollectionVMSGR_CartaDiaDetalleSubCategoria = new ObservableCollection <VMSGR_CartaDiaDetalleSubCategoria>()
                    {
                        new VMSGR_CartaDiaDetalleSubCategoria()
                        {
                            SubCategoria = NameSubCategoria,
                            CollectionESGR_CartaDiaDetalle = new ObservableCollection <ESGR_CartaDiaDetalle>()
                            {
                                ESGR_CartaDiaDetalle
                            }
                        }
                    }
                });
            }
            else
            {
                //===================SI CATEGORÍA============================//
                var FirstCategoria = CollectionVMSGR_CartaDiaDetalleCategoria.First(x => x.Categoria == NameCategoria);

                //===================NO EXISTE SUB-CATEGORÍA============================//
                var IsExistSubCategoria = FirstCategoria.CollectionVMSGR_CartaDiaDetalleSubCategoria.ToList().Exists(x => x.SubCategoria == NameSubCategoria);
                if (!IsExistSubCategoria)
                {
                    FirstCategoria.CollectionVMSGR_CartaDiaDetalleSubCategoria.Add(new VMSGR_CartaDiaDetalleSubCategoria()
                    {
                        SubCategoria = NameSubCategoria,
                        CollectionESGR_CartaDiaDetalle = new ObservableCollection <ESGR_CartaDiaDetalle>()
                        {
                            ESGR_CartaDiaDetalle
                        }
                    });
                }
                else
                {
                    //===================SI SUB-CATEGORÍA============================//
                    var FirstSubCategoria = FirstCategoria.CollectionVMSGR_CartaDiaDetalleSubCategoria.First(x => x.SubCategoria == NameSubCategoria);

                    //===================NO EXISTE ESGR_CartaDiaDetalle============================//
                    var IsExistProducto = FirstSubCategoria.CollectionESGR_CartaDiaDetalle.ToList().Exists(x => x.ESGR_Producto.IdProducto == ESGR_CartaDiaDetalle.ESGR_Producto.IdProducto);
                    if (!IsExistProducto)
                    {
                        FirstSubCategoria.CollectionESGR_CartaDiaDetalle.Add(ESGR_CartaDiaDetalle);
                    }
                }
            }
        }
예제 #6
0
        private void MethodAddDetails(ESGR_CartaDiaDetalle ESGR_CartaDiaDetalle)
        {
            try
            {
                if (ESGR_CartaDiaDetalle == null)
                {
                    return;
                }
                if (ESGR_CartaDiaDetalle.ESGR_Producto == null)
                {
                    return;
                }
                if (ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria == null)
                {
                    return;
                }
                if (ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria == null)
                {
                    return;
                }

                var NameCategoria    = ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria.Categoria;
                var NameSubCategoria = ESGR_CartaDiaDetalle.ESGR_Producto.ESGR_ProductoSubCategoria.SubCategoria;

                //===================NO EXISTE CATEGORÍA============================//
                var IsExistCategoria = CollectionVMSGR_CartaDiaDetalleCategoria.ToList().Exists(x => x.Categoria == NameCategoria);
                if (!IsExistCategoria)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                                                          CollectionVMSGR_CartaDiaDetalleCategoria.Add(new VMSGR_CartaDiaDetalleCategoria()
                    {
                        Categoria = NameCategoria,
                        CollectionVMSGR_CartaDiaDetalleSubCategoria = new ObservableCollection <VMSGR_CartaDiaDetalleSubCategoria>()
                        {
                            new VMSGR_CartaDiaDetalleSubCategoria()
                            {
                                SubCategoria = NameSubCategoria,
                                CollectionESGR_CartaDiaDetalle = new ObservableCollection <ESGR_CartaDiaDetalle>()
                                {
                                    ESGR_CartaDiaDetalle
                                }
                            }
                        }
                    })
                                                          );
                }
                else
                {
                    //===================SI CATEGORÍA============================//
                    var FirstCategoria = CollectionVMSGR_CartaDiaDetalleCategoria.First(x => x.Categoria == NameCategoria);

                    //===================NO EXISTE SUB-CATEGORÍA============================//
                    var IsExistSubCategoria = FirstCategoria.CollectionVMSGR_CartaDiaDetalleSubCategoria.ToList().Exists(x => x.SubCategoria == NameSubCategoria);
                    if (!IsExistSubCategoria)
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                                                              FirstCategoria.CollectionVMSGR_CartaDiaDetalleSubCategoria.Add(new VMSGR_CartaDiaDetalleSubCategoria()
                        {
                            SubCategoria = NameSubCategoria,
                            CollectionESGR_CartaDiaDetalle = new ObservableCollection <ESGR_CartaDiaDetalle>()
                            {
                                ESGR_CartaDiaDetalle
                            }
                        })
                                                              );
                    }
                    else
                    {
                        //===================SI SUB-CATEGORÍA============================//
                        var FirstSubCategoria = FirstCategoria.CollectionVMSGR_CartaDiaDetalleSubCategoria.First(x => x.SubCategoria == NameSubCategoria);

                        //===================NO EXISTE ESGR_CartaDiaDetalle============================//
                        var IsExistProducto = FirstSubCategoria.CollectionESGR_CartaDiaDetalle.ToList().Exists(x => x.ESGR_Producto.IdProducto == ESGR_CartaDiaDetalle.ESGR_Producto.IdProducto);
                        if (!IsExistProducto)
                        {
                            Application.Current.Dispatcher.Invoke(() => FirstSubCategoria.CollectionESGR_CartaDiaDetalle.Add(ESGR_CartaDiaDetalle));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CmpMessageBox.Show(SGRMessage.AdministratorCartaDia, ex.Message, CmpButton.Aceptar);
            }
        }