private async void GetTotalCreditAmountAsync() { var progressDialog = ProgressDialog.Show(Activity, "", "Loading...", true); try { string TotalCreditAmount = await Task.Run(() => creditDebitDb.GetTotalCreditAmount()); txtTotalCredit.Text = TotalCreditAmount; progressDialog.Hide(); Clear(); } catch (Exception ex) { progressDialog.Hide(); clsGLB.ShowMessage(ex.Message, Activity, MessageTitle.ERROR); } }
private async void GetCurrentMonthCreditDebitAsync() { var progressDialog = ProgressDialog.Show(Activity, "", "Loading...", true); try { string FromDate = DateTime.Now.ToString("yyyy-MM-") + "01"; string ToDate = DateTime.Now.ToString("yyyy-MM-dd"); // var listTotalCreditAmount = await Task.Run(() => creditDebitDb.GetMonthyCreditDebit(FromDate, ToDate)); var listTotalCreditAmount = creditDebitDb.GetMonthyCreditDebit(FromDate, ToDate); decimal CreditAmount = 0, DebitAmount = 0; foreach (var Item in listTotalCreditAmount) { if (Item.Type == eType.CREDIT.ToString()) { CreditAmount = Convert.ToDecimal(Item.Amount); } else if (Item.Type == eType.DEBIT.ToString()) { DebitAmount = Convert.ToDecimal(Item.Amount); } } btnCredit.Text = Math.Round(CreditAmount, 2).ToString(); btnDebit.Text = Math.Round(DebitAmount, 2).ToString(); btnBal.Text = Math.Round((CreditAmount - DebitAmount), 2).ToString(); string TotalBalance = await Task.Run(() => creditDebitDb.GetTotalCreditAmount()); btnTotalBal.Text = TotalBalance; progressDialog.Hide(); } catch (Exception ex) { progressDialog.Hide(); clsGLB.ShowMessage(ex.Message, Activity, MessageTitle.ERROR); } }