Esempio n. 1
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);
                    }
                }
            }
        }
Esempio n. 3
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);
            }
        }