public void Instanciar() { BalanceGeneralView.GetInstance().initialize(); BalanceView.GetInstance().initialize(); GastosView.GetInstance().initialize(); IngresosView.GetInstance().initialize(); }
void SetupPage() { _balanceView = null; _unlockButton = null; _unlockPassword = null; StackLayout.Children.Clear(); AddTitleRow("Title"); if (!WalletApp.HasCoreAccount) { AddRegisterSection(); } else if (!WalletApp.IsCoreAccountUnlocked) { AddUnlockSection(); } else { AddAccountSection(); } UpdateSuspendedLayout(); }
public decimal GetBalance(int cust, int contract) { BalanceView balance = GetListBalance(cust, contract); decimal sm = balance.Psm - balance.Ssm + balance.Fin.Sm; return(sm); }
private async void Edit() { var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Edit = new EditViewModel(this); var balanceView = BalanceView.GetInstance(); await balanceView.Navigation.PushAsync(new EditView()); }
public BalanceView GetListBalance(int cust, int contract) { BalanceView balance = new BalanceView(); DateTime LastDat; int year = DateTime.Today.Year; int dm = DateTime.Today.Month; LastDat = new DateTime(year, dm, 01, 0, 0, 0); var dat = db.Database.SqlQuery <DateTime>("SELECT dbo.LastDat1s()"); foreach (var prn in dat) { LastDat = prn; } if (contract > 0) { balance.Fin = db.FinBals.FirstOrDefault(f => f.CustID == cust && f.Dat >= LastDat && f.ContractID == contract); balance.Balances = db.Balances.Where(b => b.CustID == cust && b.Dat >= LastDat && b.ContractID == contract).OrderBy(b => b.Dat).ToList(); } else { balance.Fin = db.FinBals.FirstOrDefault(f => f.CustID == cust && f.Dat >= LastDat); balance.Balances = db.Balances.Where(b => b.CustID == cust && b.Dat >= LastDat).OrderBy(b => b.Dat).ToList(); } var blTotal = from b in balance.Balances group b by b.CustID into q select new { kol = q.Sum(b => b.kol), ssm = q.Sum(b => b.Ssm), psm = q.Sum(b => b.Psm) }; foreach (var bl in blTotal) { balance.kol = bl.kol; balance.Ssm = bl.ssm; balance.Psm = bl.psm; } if (balance.Fin == null) { balance.Fin = new FinBal(); balance.Fin.Dat = LastDat; balance.Fin.Sm = 0.0m; } Contract _contract = db.Contracts.Find(contract); if (_contract == null) { balance.Contract = "Нет договора"; } else { balance.Contract = _contract.Num; } return(balance); }
void AddAccountSection() { AddHeaderRow("Account"); if (ToolbarItems.Count == 0) { ToolbarItems.Add(new ExtToolbarItem(Tr.Get("Common.Refresh"), null, async() => { await WalletApp.UpdateCoreAccountBalance(); })); } var lastBalance = WalletApp.LastBalanceEvent; _balanceView = new BalanceView(); AddViewRow(_balanceView); AddButtonRow("Transfer", Transfer).SetDetailViewIcon(Icons.CreditCardFront); AddButtonRow("RequestRevenue", RequestRevenue).SetDetailViewIcon(Icons.MoneyCheckEdit); #if DEBUG AddButtonRow("Derived", async(button) => { await Navigation.PushAsync(new AuthorizeDerivedKeyPage(0, Hex.ToString(new byte[16]))); }); AddButtonRow("Join", Join); AddButtonRow("Purchase", Purchase); #endif AddSeparatorRow(); AddButtonRow("ProfilePage.Title", Profile).SetDetailViewIcon(Icons.UserCircle); AddButtonRow("ChainOverviewPage.Title", Chain).SetDetailViewIcon(Icons.Link); AddButtonRow(HandleRequestPage.HandleRequestTranslation, HandleRequest).SetDetailViewIcon(HandleRequestPage.HandleRequestIcon); AddFooterRow(); AddHeaderRow("Key"); AddButtonViewRow(new ClientAccountView(WalletApp.CurrentCoreAccount), DisplayKeyAction); AddSubmitButtonRow("Export", Export); AddFooterRow(); }
private async void Excel() { var balanceView = BalanceView.GetInstance(); var confirmacion = await dialogService.ShowMessageConfirmacion("Mensaje", "¿Desea exportar el balance a una planilla de cálculo?"); if (confirmacion) { try { Cargas(); if (ListaBalance.Count == 0) { await dialogService.ShowMessage("Error", "Se deben agregar elementos al balance"); balanceView.excelUnTapped(); return; } using (ExcelEngine excelEngine = new ExcelEngine()) { cont = 0; //Seleccionar versión de Excel 2013 excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2013; //Crear workbook con una hoja de trabajo IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1); //Acceder a la primera hoja de trabajo desde la instancia de workbook IWorksheet worksheet = workbook.Worksheets[0]; IMigrantRange migrantRange = worksheet.MigrantRange; foreach (var elemento in ListaBalance) { // Writing Data. //cont aumenta en 7 la posición de las filas en cada producto, las columnas dependen de los días elegidos migrantRange["A1"].Text = "Fecha"; migrantRange["A1"].CellStyle.Font.Bold = true; migrantRange["B1"].Text = "Origen"; migrantRange["B1"].CellStyle.Font.Bold = true; migrantRange["C1"].Text = "Categoría"; migrantRange["C1"].CellStyle.Font.Bold = true; migrantRange["D1"].Text = "Monto"; migrantRange["D1"].CellStyle.Font.Bold = true; //Nueva celda migrantRange.ResetRowColumn(cont + 2, 1); migrantRange.Text = string.Format("{0}/{1}/{2}", elemento.Dia, elemento.Mes, elemento.Anio); //migrantRange.CellStyle.Borders.LineStyle = ExcelLineStyle.Medium; //Nueva celda migrantRange.ResetRowColumn(cont + 2, 2); migrantRange.Text = elemento.Origen; //Nueva celda migrantRange.ResetRowColumn(cont + 2, 3); migrantRange.Text = elemento.GastoIngreso; //Nueva celda migrantRange.ResetRowColumn(cont + 2, 4); migrantRange.Number = double.Parse(elemento.Cantidad); if (double.Parse(elemento.Cantidad) > 0) { worksheet[string.Format("D{0}", cont + 2)].CellStyle.Font.Color = ExcelKnownColors.Green; } else if (double.Parse(elemento.Cantidad) < 0) { worksheet[string.Format("D{0}", cont + 2)].CellStyle.Font.Color = ExcelKnownColors.Red; } cont = cont + 1; } ; IRange range = worksheet.Range[string.Format("A{0}:C{0}", cont + 2)]; range.Merge(); range.Text = string.Format("Balance: "); range.CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; range.CellStyle.Font.Bold = true; worksheet[string.Format("D{0}", cont + 2)].Number = double.Parse(BalanceTotal); worksheet[string.Format("D{0}", cont + 2)].CellStyle.Font.Bold = true; if (double.Parse(BalanceTotal) > 0) { worksheet[string.Format("D{0}", cont + 2)].CellStyle.ColorIndex = ExcelKnownColors.Green; } else if (double.Parse(BalanceTotal) < 0) { worksheet[string.Format("D{0}", cont + 2)].CellStyle.ColorIndex = ExcelKnownColors.Red; } worksheet.Range[string.Format("A1:D{0}", cont + 2)].BorderInside(); worksheet.Range[string.Format("A1:D{0}", cont + 2)].BorderAround(); worksheet.UsedRange.AutofitColumns(); //Save the workbook to stream in xlsx format. MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); //Save the stream as a file in the device and invoke it for viewing DependencyService.Get <ISave>().SaveAndView(string.Format("Balance Mensual de {0}-{1}", SelectedItemMes, SelectedItemAño) + ".xlsx", "application/msexcel", stream); await dialogService.ShowMessage("Mensaje", string.Format("El balance se guardó como archivo de nombre '{0}' en la carpeta Balances", string.Format("Balance Mensual de {0}-{1}", SelectedItemMes, SelectedItemAño) + ".xlsx")); } } catch { await dialogService.ShowMessage("Error", "No se pudo exportar a hoja de cálculo. Intenta habilitando los permisos en ajustes."); } } balanceView.excelUnTapped(); }
private void UnloadPage(object sender, RoutedEventArgs e) { BalanceView.IsTransactionView = false; AddTransactionView.IsNavigationBlocked = true; BalanceView.UpdateBalance(); }