private async void ResetarMethod(object obj) { var resultado = await App.Current.MainPage.DisplayAlert("Aviso", "Tem Certeza Que Deseja Resetar a Data de Fechamento do mês", "Ok", "Cancelar"); if (resultado == true) { int res = ConfiguracaoDB.TruncateTableConfigApp(); if (res > 0) { await App.Current.MainPage.DisplayAlert("Aviso", "Fechamendo do mês reconfigurado para Padrão Inicial", "Ok"); } else { await App.Current.MainPage.DisplayAlert("Aviso", "Fechamendo do mês já em estado inicial", "Ok"); } } }
private async void ConfigurarMethod(object obj) { if (!string.IsNullOrEmpty(PaginaInicial) && !string.IsNullOrEmpty(PaginaChat) && !DataFechamento.Equals(null) && !string.IsNullOrEmpty(CotaInvestimento)) { int resultado = ConfiguracaoDB.AddConfig(new Model.ConfigApp() { PaginaInicial = PaginaInicial, PaginaChat = PaginaChat, DataFechamento = DataFechamento, CotaInvestimento = CotaInvestimento }); if (resultado > 0) { //int res = ConfiguracaoDB.TruncateTableConfigApp(); await App.Current.MainPage.DisplayAlert("Aviso", "Configurado Com Sucesso", "Ok"); } } }
public App() { InitializeComponent(); Xamarin.Forms.PlatformConfiguration.AndroidSpecific. Application.SetWindowSoftInputModeAdjust(this, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Resize); PaginaIni = ""; var confg = ConfiguracaoDB.GetAllConfigApp().LastOrDefault(); if (confg != null) { PaginaCha = confg.PaginaChat; PaginaIni = confg.PaginaInicial; DataFecha = confg.DataFechamento; ValorInve = confg.CotaInvestimento; } MainPage = new MasterPage(); ((MasterPage)App.Current.MainPage).Detail = new NavigationPage(new HomePage()); ((MasterPage)App.Current.MainPage).IsPresented = false; }
public VendasViewModel() { string Configu = ""; DateTime date = DateTime.Today; GoChatCommand = new Command(GoChat); GoEstoqueCommand = new Command(GoEstoque); PesquisarCommand = new Command <string>(Pesquisar); var mes = date.Month; try { //Configura pagina inicial do app Configu = ConfiguracaoDB.GetAllConfigApp().FirstOrDefault().PaginaInicial; } catch (Exception) { } if (string.IsNullOrEmpty(Configu)) { try { //Lista todas venda realizadas entre uma periodo configurado no banco de dados Lista = VedasDB.GetAllVenda().Where(x => x.DataVendav.Month == mes).ToList(); //Mostra a data na tela DataInicio = new DateTime(date.Year, date.Month, 01); //string.Format("{0}/{1}/{2}", 01, date.Month, date.Year); // new DateTime(date.Year, date.Month, 1).ToString(); int d = DateTime.DaysInMonth(date.Year, date.Month); DataFim = new DateTime(date.Year, date.Month, d); //string.Format("{0}/{1}/{2}", d, date.Month, date.Year); //new DateTime(DateTime.DaysInMonth(date.Year, date.Month), date.Year, date.Month).ToString(); } catch (Exception) { //Evita uma exception em caso de nao haver nada no banco de dados Lista = new List <Venda>() { }; } } else { //Pega a configuração desejada pelo usuario var confg = ConfiguracaoDB.GetAllConfigApp().LastOrDefault(); try { int inicio = 1; int fim = 1; DateTime abreMes; DateTime fechamento; try { inicio = confg.DataFechamento.Day; abreMes = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, inicio); } catch (Exception) { inicio = DateTime.DaysInMonth(date.Year, date.Month - 1); abreMes = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, inicio); } try { fim = confg.DataFechamento.Day; fechamento = new DateTime(DateTime.Now.Year, DateTime.Now.Month, fim); } catch (Exception) { fim = DateTime.DaysInMonth(date.Year, date.Month); fechamento = new DateTime(DateTime.Now.Year, DateTime.Now.Month, fim); } Lista = VedasDB.GetAllVenda().Where(x => x.DataVendav >= abreMes && x.DataVendav <= fechamento).ToList(); //Mostra a data na tela DataInicio = new DateTime(date.Year, date.Month - 1, inicio); //string.Format("{0}/{1}/{2}", 01, date.Month, date.Year); // new DateTime(date.Year, date.Month, 1).ToString(); //int d = DateTime.DaysInMonth(date.Year, date.Month); DataFim = new DateTime(date.Year, date.Month, fim); //string.Format("{0}/{1}/{2}", d, date.Month, date.Year); //new DateTime(DateTime.DaysInMonth(date.Year, date.Month), date.Year, date.Month).ToString(); } catch (Exception) { if (confg.DataFechamento.Day >= 29 && confg.DataFechamento.Day >= 31) { var fechamento = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var abreMes = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, 1); Lista = VedasDB.GetAllVenda().Where(x => x.DataVendav >= abreMes && x.DataVendav <= fechamento).ToList(); } } } //formata numeros NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat; Vendas = Lista; V_Investido = Lista.Select(x => x.PrecoCusto).Sum().ToString(); V_Lucro = Lista.Select(x => x.LucroVenda).Sum().ToString(); V_Margem = (((double.Parse(V_Lucro) * 100) / double.Parse(V_Investido))).ToString("F", nfi); }