public SalesEntryViewModel(SalesParams salesParams) : base(salesParams != null ? salesParams.ShowAllCustomers : false) { _salesParams = salesParams; var cnt = RMSEntitiesHelper.Instance.RMSEntities.Customers.ToList(); var cnt1 = RMSEntitiesHelper.Instance.RMSEntities.Products.ToList(); _salesBillPrint = new SalesBillPrint(); _billSales = RMSEntitiesHelper.Instance.RMSEntities.Sales.Create(); _salesDetailsList = new ObservableCollection <SaleDetailExtn>(); _salesDetailsList.CollectionChanged += OnSalesDetailsListCollectionChanged; //SelectedCustomer = DefaultCustomer; Title = "Sales Entry"; if (_salesParams.ShowAllCustomers) { Title = "Sales Entry*"; } if (salesParams != null) { //Temp window to save 10 items if (salesParams.IsTempDataWindow) { //AutoSaveData(); //Title = "Sales Entry"; RMSEntitiesHelper.Instance.AddNotifier(this); RMSEntitiesHelper.Instance.SelectRunningBillNo(_categoryId); return; } if (salesParams.Billno.HasValue) { //Amend Bill OnEditBill(salesParams.Billno.Value); Title = "Sale Bill Amend :" + _runningBillNo; IsVisible = System.Windows.Visibility.Visible; return; } else if (salesParams.GetTemproaryData) { //Get Temproary window from DB GetTempDataFromDB(salesParams.Guid); return; } //return; } //Title = "Sales Entry"; RMSEntitiesHelper.Instance.AddNotifier(this); RMSEntitiesHelper.Instance.SelectRunningBillNo(_categoryId); //SaveDataTemp(); }
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; }