public void Salvar(object sender, EventArgs eventArgs)
        {
            //String _Content = String.Format("Categoria: {0},Despesa: {1},Receita: {2},Valor: {3},Data: {4}",
            //   ListPickerSub.SelectedItems, rDespesa.IsChecked.Value, rReceita.IsChecked.Value, xValor.Text, xData.Value);
            //MessageBox.Show(_Content);

            using (var ctx = new FinancasDataContext(conn))
            {
                var cat = new Categoria();
                cat = ListPickerSub.SelectedItem as Categoria;
                CultureInfo newCulture = new CultureInfo("pt-BR");
                newCulture.NumberFormat.CurrencyDecimalSeparator = ".";
                newCulture.NumberFormat.CurrencyGroupSeparator = ",";
                newCulture.NumberFormat.NumberDecimalSeparator = ".";
                newCulture.NumberFormat.NumberGroupSeparator = ",";    
                var cadastro = new Cadastro
                                   {
                                       Descricao = xDescricao.Text,
                                       CategoriaId = cat.Id,
                                      // Valor = xValor.Text.ToString(),
                                       Preco = xValor.Text.ToString(),
                                       Data = xData.Value,
                                       TipoCategoria = (rReceita.IsChecked.Value) ? 1 : 2,
                                       Parcelas = parcela.Text != "" ? Convert.ToInt32(parcela.Text) : 0

                                   };

                ctx.Cadastros.InsertOnSubmit(cadastro);
                ctx.SubmitChanges();
            }

            MessageBox.Show("Registro salvo com sucesso!");
            NavigationService.Navigate(
               new Uri("/Pages/MainPage.xaml", UriKind.Relative));
        }
        public void Salvar(object sender, EventArgs eventArgs)
        {
            using (var ctx = new FinancasDataContext(conn))
            {
                var categoria = new Categoria
                                    {
                                        Nome = xCategoria.Text,
                                    };
                ctx.Categorias.InsertOnSubmit(categoria);
                ctx.SubmitChanges();
            }


            var m = MessageBox.Show("Registro salvo com sucesso! Deseja cadastrar mais uma categoria ?", "File Save", MessageBoxButton.OKCancel);

            if (m == MessageBoxResult.OK)
            {
                Focus();
            }
            else if (m == MessageBoxResult.Cancel)
            {
                NavigationService.GoBack();
            }
            {

            }
        }
        public IList<Categoria> GetCategorias()
        {
            using (var ctx = new FinancasDataContext(conn))
            {
                IList<Categoria> lista = null;
                IQueryable<Categoria> query = ctx.Categorias.OrderBy(categoria => Name);
                lista = query.ToList();
                return lista;
            }

        }
Example #4
0
        public Dictionary<string, string> GetDespesa()
        {
            using (var ctx = new FinancasDataContext(conn))
            {
                Dictionary<string, string> lista = new Dictionary<string, string>();

                var data = DateTime.Now.ToString().Substring(0, 11);
                IQueryable<Cadastro> query = ctx.Cadastros.Where(x => x.TipoCategoria == 1 && Convert.ToDateTime(x.Data.ToString().Substring(0, 11)) == Convert.ToDateTime(data))
                    .OrderBy(cadastro => Name);

                if (query.Count() > 0)
                {
                    foreach (var item in query.ToList())
                    {
                        lista.Add(item.Descricao, item.Preco);
                    }
                }
                return lista;
            }

        }
Example #5
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            CultureInfo newCulture = new CultureInfo("pt-BR");

            //change format of DatePicker to you own format
            newCulture.DateTimeFormat.ShortDatePattern = "d/MMM/yyyy";

            Thread.CurrentThread.CurrentCulture = newCulture;
            Thread.CurrentThread.CurrentUICulture = newCulture;


            // Global handler for uncaught exceptions. 
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode, 
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;


                using (var ctx = new FinancasDataContext(conn))
                {
                    IList<Categoria> categorias = new List<Categoria>();


                    if (!ctx.DatabaseExists())
                    {
                        //ctx.DeleteDatabase();
                        ctx.CreateDatabase();
                        categorias.Add(new Categoria { Nome = "Café" });
                        categorias.Add(new Categoria { Nome = "Almoço" });
                        categorias.Add(new Categoria { Nome = "Lanche" });
                        categorias.Add(new Categoria { Nome = "Janta" });
                        categorias.Add(new Categoria { Nome = "Transporte" });
                        categorias.Add(new Categoria { Nome = "Mercado" });
                        categorias.Add(new Categoria { Nome = "Combustivel" });

                        foreach (var categoria in categorias)
                        {
                            ctx.Categorias.InsertOnSubmit(categoria);
                            ctx.SubmitChanges();
                        }
                    }
                }

            }

        }