private void OnAmend(Window window) { var companyBill = RMSEntitiesHelper.CheckIfPurchaseBillExists(BillNo.Value, _categoryId); if (companyBill == null) { return; } var cancelBill = _rmsEntities.Purchases.FirstOrDefault(s => s.RunningBillNo == BillNo && companyBill.CompanyId == s.CompanyId); if (cancelBill.IsCancelled.HasValue && cancelBill.IsCancelled.Value) { Utility.ShowWarningBox("Bill has been cancelled already"); return; } View.Entitlements.Login login = new View.Entitlements.Login(true); var result = login.ShowDialog(); if (!result.Value) { return; } var purchaseParams = new PurchaseParams() { Billno = BillNo, CompanyId = companyBill.CompanyId }; Workspace.This.OpenPurchaseEntryCommand.Execute(purchaseParams); _closeWindowCommand.Execute(window); }
private void OnAmend(Window window) { var customerBill = RMSEntitiesHelper.CheckIfBillExists(BillNo.Value, _categoryId); if (customerBill == null) { return; } var cancelBill = RMSEntitiesHelper.Instance.RMSEntities.Sales.FirstOrDefault(s => s.RunningBillNo == BillNo && customerBill.CustomerId == s.CustomerId); if (cancelBill.IsCancelled.HasValue && cancelBill.IsCancelled.Value) { Utility.ShowWarningBox("Bill has been cancelled already"); return; } View.Entitlements.Login login = new View.Entitlements.Login(true); var result = login.ShowDialog(); if (!result.Value) { //Utility.ShowErrorBox(window, "Invalid UserId or Password"); return; } var saleParams = new SalesParams() { Billno = BillNo, CustomerId = customerBill.CustomerId }; Workspace.This.OpenSalesEntryCommand.Execute(saleParams); _closeWindowCommand.Execute(window); //window.DialogResult = true; }
private void OnGetBill(object parameter) { PanelLoading = true; var GetBillTask = System.Threading.Tasks.Task.Run(() => { _returnSalesDetailsList = new ObservableCollection <ReturnSaleDetailExtn>(); var customerBill = RMSEntitiesHelper.CheckIfBillExists(BillNo.Value, _categoryId); if (customerBill == null) { PanelLoading = false; return; } _billSales = _rmsEntities.Sales.Where(s => s.RunningBillNo == BillNo && customerBill.CustomerId == s.CustomerId).FirstOrDefault(); CustomerName = _billSales.Customer.Name; SaleDate = _billSales.AddedOn.Value; PaymentMode pm = new PaymentMode(); ModeOfPayment = pm.GetPaymentString(_billSales.PaymentMode); var saleDetailsForBill = _rmsEntities.SaleDetails.Where(b => b.BillId == _billSales.BillId); foreach (var saleDetailItem in saleDetailsForBill.ToList()) { //Get the item and check if there is any return done for the item. var returnQty = _rmsEntities.ReturnDamagedStocks.FirstOrDefault(b => b.BillId == _billSales.BillId && saleDetailItem.ProductId == b.ProductId); var remainingQty = 0.0M; if (returnQty != null) { remainingQty = saleDetailItem.Qty.Value - returnQty.Quantity; if (remainingQty == 0) { continue; } } else { remainingQty = saleDetailItem.Qty.Value; } var productPrice = _rmsEntities.PriceDetails.Where(p => p.PriceId == saleDetailItem.PriceId).FirstOrDefault(); var saleDetailExtn = new ReturnSaleDetailExtn() { Discount = saleDetailItem.Discount, PriceId = saleDetailItem.PriceId, ProductId = saleDetailItem.ProductId, Qty = remainingQty, OriginalQty = saleDetailItem.Qty, SellingPrice = saleDetailItem.SellingPrice, BillId = saleDetailItem.BillId, CostPrice = productPrice.Price, ProductName = _rmsEntities.Products.FirstOrDefault(p => p.Id == saleDetailItem.ProductId).Name, //AvailableStock = productPrice.Quantity, Amount = productPrice.SellingPrice * saleDetailItem.Qty }; ReturnSaleDetailList.Add(saleDetailExtn); saleDetailExtn.PropertyChanged += (s, e) => { if (e.PropertyName == Constants.RETURN_QTY) { saleDetailExtn.ReturnAmount = saleDetailExtn.SellingPrice.Value * saleDetailExtn.ReturnQty; TotalAmount = _returnSalesDetailsList.Sum(p => p.ReturnAmount); } }; //tempTotalAmount += productPrice.SellingPrice * remainingQty; } //TotalAmount = tempTotalAmount; System.Threading.Thread.Sleep(1000); }).ContinueWith( (t) => { PanelLoading = false; RaisePropertyChanged("ReturnSaleDetailList"); IsBillBasedReturn = true; }); }