Exemplo n.º 1
0
        //TRATAMENTO ESTÁTICO:
        public static void Iniciar()
        {
            MontapratoView    lst;
            AlmocoView        almoco;
            JantaView         janta;
            LanchedaManhaView lm;
            LanchedaNoiteView ln;
            LanchedaTardeView lt;
            CafedaManhaView   cafe;

            for (int i = 1; i <= 7; i++)
            {
                lst = new MontapratoView()
                {
                    Datasemana = i, Almoco_fk = i, Cafedamanha_fk = i, Jantar_fk = i, Id_montaprato = i, Lanchedanoite_fk = i, Lanchemanha_fk = i, Lanchetarde_fk = i, Statuspronto = false
                };
                almoco = new AlmocoView()
                {
                    Frutafk = i, GraoIntegralfk = i, Liquidofk = i, Proteinafk = i, Vegetalfk = i, Id_almoco = i
                };
                almoco.Gravar();
                janta = new JantaView()
                {
                    Frutafk = i, GraoIntegralfk = i, Liquidofk = i, Proteinafk = i, Vegetalfk = i, Id_janta = i
                };
                janta.Gravar();
                lm = new LanchedaManhaView()
                {
                    Frutafk = i, Id_lanchedamanha = i, Liquidofk = i, Paofk = i
                };
                lm.Gravar();
                ln = new LanchedaNoiteView()
                {
                    Frutafk = i, Id_lanchedanoite = i, Liquidofk = i, Paofk = i
                };
                ln.Gravar();
                lt = new LanchedaTardeView()
                {
                    Frutafk = i, Id_lanchedatarde = i, Liquidofk = i, Paofk = i
                };
                lt.Gravar();
                cafe = new CafedaManhaView()
                {
                    Frutafk = i, Id_cafedamanha = i, Liquidofk = i, Paofk = i
                };
                cafe.Gravar();
                Gravar(lst);
            }
        }
Exemplo n.º 2
0
 //TRATAMENDO DINÂMICO:
 /// <summary>
 /// Grava no banco um Almoco.
 /// </summary>
 /// <param name="Almoco">Instância de Almoco.</param>
 /// <returns> [true]: se cadastrou; [false]: se não cadastrou;</returns>
 public static bool Gravar(AlmocoView Almoco)
 {
     try
     {
         App thisApp = Application.Current as App;
         thisApp.LINDADB.AlmocoItems.InsertOnSubmit(Almoco);
         thisApp.LINDADB.SubmitChanges();
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message, "Erro", MessageBoxButton.OK);
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
 public void MontapratoUsar()
 {
     usandomontaprato = !usandomontaprato;
     RefeicaoActive   = new MontapratoView();
     R_almoco         = new AlmocoView();
     R_cafedamanha    = new CafedaManhaView();
     R_jantar         = new JantaView();
     R_lanchetarde    = new LanchedaTardeView();
     R_lanchedamanha  = new LanchedaManhaView();
     R_lanchenoite    = new LanchedaNoiteView();
     bolRefeicoes     = new bool[6];
     for (int i = 0; i < 6; i++)
     {
         bolRefeicoes[i] = false;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Exclui um Almoco.
 /// </summary>
 /// <param name="Almoco">Instância de Almoco.</param>
 /// <returns> [true]: se conseguiu; [false]: se não conseguiu;</returns>
 public static bool Excluir(AlmocoView Almoco)
 {
     try
     {
         App thisApp = Application.Current as App;
         var excluir = thisApp.LINDADB.AlmocoItems.Where(a => a.Id_almoco == Almoco.Id_almoco).First();
         thisApp.LINDADB.AlmocoItems.DeleteOnSubmit(excluir);
         thisApp.LINDADB.SubmitChanges();
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message, "Erro", MessageBoxButton.OK);
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Altera um Almoco.
        /// </summary>
        /// <param name="Almoco">Instância de Almoco.</param>
        /// <param name="novoQTD">Nova quantidade.</param>
        /// <returns> [true]: se cadastrou; [false]: se não cadastrou;</returns>
        public static bool Alterar(AlmocoView Almoco, int novoQTD)
        {
            try
            {
                App thisApp = Application.Current as App;

                AlmocoView update = (from com in thisApp.LINDADB.AlmocoItems
                                     where com.Id_almoco == Almoco.Id_almoco
                                     select com).First();
                update.GraoIntegralfk = novoQTD;
                thisApp.LINDADB.SubmitChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }