private void GetModelData(PaymentFromCustomerForm pqf) { if (IsNew == false) { // this.ID = pqf.PaymentFromCustomer.ID; this.SelectedCustomerID = pqf.PaymentFromCustomer.CustomerID; this.SelectedAccountID = pqf.PaymentFromCustomer.AccountId; this.AmountStr = pqf.PaymentFromCustomer.AmountStr; this.IsCheque = pqf.PaymentFromCustomer.IsCheque; this.CashChequeNo = pqf.PaymentFromCustomer.CashChequeNo; this.Remarks = pqf.PaymentFromCustomer.Remarks; if (IsCheque == true) { IsChequeTrue = true; IsChequeFalse = false; } else { IsChequeFalse = true; IsChequeTrue = false; } } var result = pqf.PaymentFromCustomerDetails.OrderByDescending(e => e.CreatedDate).GroupBy(e => e.SalesNo).Select(e => e.First()).ToList(); this.PQDetailsEntity = new ObservableCollection <CollectSalesAmountDataGridViewModel>(); foreach (var item in result) { CollectSalesAmountDataGridViewModel pqEntity = new CollectSalesAmountDataGridViewModel(); pqEntity.SalesNo = item.SalesNo; pqEntity.SalesDate = item.SalesDate; pqEntity.SalesDateStr = changedateformat(item.SalesDate); pqEntity.SalesAmountStr = Convert.ToString(item.SalesAmount); pqEntity.SalesAmount = item.SalesAmount; pqEntity.PaymentDueDate = item.PaymentDueDate; pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate); pqEntity.AmountDue = item.AmountDue; pqEntity.AmountDueStr = Convert.ToString(item.AmountDue); pqEntity.AmountAdjusted = item.AmountAdjusted; pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted); pqEntity.Discount = item.Discount; PQDetailsEntity.Add(pqEntity); OnPropertyChanged("PQDetailsEntity"); } TotalSalesAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.SalesAmount)); TotalAmountDue = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountDue)); TotalAmountPaid = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); PQDetailsEntityLst = PQDetailsEntity; }
private void GetModelData(RefundToCustomerForm pqf) { if (IsNew == false) { this.ID = pqf.RefundToCustomer.ID; this.SelectedCustomerID = pqf.RefundToCustomer.CustomerID; this.SelectedAccountID = pqf.RefundToCustomer.AccountId; this.AmountStr = pqf.RefundToCustomer.AmountStr; this.IsCheque = pqf.RefundToCustomer.IsCheque; if (IsCheque == true) { IsChequeTrue = true; } else { IsChequeFalse = true; } this.CashChequeNo = pqf.RefundToCustomer.CashChequeNo; this.Remarks = pqf.RefundToCustomer.Remarks; } this.PQDetailsEntity = new ObservableCollection <CollectSalesAmountDataGridViewModel>(); foreach (var item in pqf.RefundToCustomerDetails) { CollectSalesAmountDataGridViewModel pqEntity = new CollectSalesAmountDataGridViewModel(); pqEntity.SalesNo = item.SalesNo; pqEntity.SalesDate = item.SalesDate; pqEntity.SalesDateStr = changedateformat(item.SalesDate); pqEntity.SalesAmount = Math.Abs(decimal.Parse(item.SalesAmount.ToString())); pqEntity.SalesAmountStr = Convert.ToString(pqEntity.SalesAmount); pqEntity.PaymentDueDate = item.PaymentDueDate; pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate); pqEntity.AmountDue = Math.Abs(decimal.Parse(item.AmountDue.ToString())); pqEntity.AmountDueStr = Convert.ToString(pqEntity.AmountDue); pqEntity.AmountAdjusted = Math.Abs(decimal.Parse(item.AmountAdjusted.ToString())); pqEntity.AmountAdjustedStr = Convert.ToString(pqEntity.AmountAdjusted); pqEntity.Discount = item.Discount; PQDetailsEntity.Add(pqEntity); OnPropertyChanged("PQDetailsEntity"); } TotalSalesAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.SalesAmount)); TotalAmountDue = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountDue)); TotalAmountPaid = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); PQDetailsEntityLst = PQDetailsEntity; }