public SaleView() { InitializeComponent(); var customerWindow = new CustomerWindow() { DataContext = ItemsGrid, Left = 1024, Top = 0 }; this.Loaded += (sender, args) => { PosBootstrapper._msg.GetStream<ApplicationClosingEvent>() .Subscribe(x => customerWindow.Close()); customerWindow.Show(); }; }
public SaleView() { InitializeComponent(); var customerWindow = new CustomerWindow() { DataContext = ItemsGrid, Left = 1024, Top = 0 }; this.Loaded += (sender, args) => { PosBootstrapper._msg.GetStream <ApplicationClosingEvent>() .Subscribe(x => customerWindow.Close()); customerWindow.Show(); }; }
public void SubmitButtonCommand() { HttpClients httpClient = new HttpClients(); if (!String.IsNullOrEmpty(PopupValue)) { isError = false; if (_isCustomer) { if (PopupValue.Trim().Equals("00001")) { _posWindow.ViewModel.CustomerInformation.Customer = new CustomerProfile { MembershipCode = 1, Id = 1, Name = "Walkin Customer", IsWalkIn = true }; _customerWindow.DialogResult = true; _customerWindow.Close(); } else { var response = httpClient.GetAsync("api/customer/getcustomerbymebershipcodeormobileno?number=" + PopupValue); if (response.IsSuccessStatusCode) { string data = response.Content.ReadAsStringAsync().Result; var CustomerProfile = JsonConvert.DeserializeObject <CustomerProfile>(data); if (CustomerProfile != null) { if (CustomerProfile.IsActive) { CustomerProfileObject = CustomerProfile; _posWindow.ViewModel.CustomerInformation.Customer = CustomerProfile; _customerWindow.DialogResult = true; _customerWindow.Close(); } else { isError = true; Message = StringConstants.InActiveCustomer; } } else { isError = true; Message = StringConstants.CustomerNoNotFound; } //return CustomerProfile; } else { isError = true; Message = StringConstants.CustomerNoNotFound; } } } if (_isCustomerPO) { var CustomerPOResponse = httpClient.GetAsync("api/customerpo/getcustomerpobyponumber?purchaseOrderNumber=" + PopupValue); if (CustomerPOResponse.IsSuccessStatusCode) { var customerPOString = CustomerPOResponse.Content.ReadAsStringAsync().Result; var customerPOData = JsonConvert.DeserializeObject <CustomerPurchaseOrder>(customerPOString); if (customerPOData != null) { var cpoDetailResponse = httpClient.GetAsync("api/customerpo/getcustomerpurchaseorderbycpoid?cpoId=" + customerPOData.Id); if (cpoDetailResponse.IsSuccessStatusCode) { var cpoDetailString = cpoDetailResponse.Content.ReadAsStringAsync().Result; var cpoDetailData = JsonConvert.DeserializeObject <CustomerPOAC>(cpoDetailString); if (cpoDetailData != null) { if (cpoDetailData.IsCollected) { isError = true; Message = StringConstants.CpoCollected; } else if (cpoDetailData.IsCancel) { isError = true; Message = StringConstants.CpoCancelled; } else { if (cpoDetailData.CollectingBranchId != SettingHelpers.CurrentBranchId) { MessageBox.Show(string.Format(StringConstants.CPOCollectionValidation, cpoDetailData.CollectingBranchName), "CPO Collection Validation", MessageBoxButton.OK, MessageBoxImage.Information); return; } _posWindow.ViewModel.CustomerInformation.Customer = cpoDetailData.Customer; // SettingHelpers.CurrentBranchId = cpoDetailData.CollectingBranchId; _posWindow.ViewModel.BillSummary.DownPayment = cpoDetailData.POSBillAmount; _posWindow.ViewModel.ItemProfileCollectionNew = new ObservableCollection <POSItemDetail>(); _posWindow.ViewModel.BillSummary.OrderAmount = 0; _posWindow.ViewModel.BillSummary.Discount = 0; if (cpoDetailData.CPOAdditionalCost.Any()) { _posWindow.ViewModel.BillSummary.AdditionalAmount = cpoDetailData.CPOAdditionalCost.Sum(x => x.Amount); } SettingHelpers.AdditionalAmount = _posWindow.ViewModel.BillSummary.AdditionalAmount == null ? 0 : _posWindow.ViewModel.BillSummary.AdditionalAmount.Value; var tempPosItem = new List <POSTempTransItem>(); POSTempTransItem newObj; foreach (var item in cpoDetailData.CPOItem.ToList()) { newObj = new POSTempTransItem(); newObj.Barcode = item.Barcode; newObj.ItemProfile = item.ItemProfile; newObj.Quantity = item.Quantity; newObj.ItemID = item.ItemId; tempPosItem.Add(newObj); } if (SettingHelpers.CurrentTempTransId == 0) { InsertTempTranscation(cpoDetailData); } _posWindow.ViewModel.ProcessTempTransactionItems(tempPosItem, false); cpoDetailData.CPOItemDetailPOS = _posWindow.ViewModel.ItemProfileCollectionNew; SettingHelpers.IsCustomerPO = true; _posWindow.ViewModel.CustomerInformation.CPO = new CustomerPurchaseOrder { PurchaseOrderNo = cpoDetailData.PurchaseOrderNo }; _customerWindow.DialogResult = true; _customerWindow.Close(); //BackgroundWorker bgInsertTempTrans = new BackgroundWorker(); //bgInsertTempTrans.DoWork += bgInsertTempTrans_DoWork; //bgInsertTempTrans.RunWorkerCompleted += bgInsertTempTrans_RunWorkerCompleted; //bgInsertTempTrans.RunWorkerAsync(cpoDetailData); } } } } else { isError = true; Message = StringConstants.CpoNotExists; } } } else if (_isReturnBill) { var responseReturnBill = httpClient.GetAsync("api/returnbill/getposreturnbilldatabyreturnbillno?billNo=" + PopupValue); if (responseReturnBill.IsSuccessStatusCode) { var returnBillData = responseReturnBill.Content.ReadAsAsync <POSReturnBill>().Result; if (returnBillData != null) { if (!returnBillData.IsProcessed) { if (SettingHelpers.CurrentBranchId != returnBillData.IssuingBranchID) { if (SettingHelpers.CompanyConfigruationObject.ReturnItem) { _posWindow.ViewModel.CustomerInformation.ReturnBill = returnBillData; if (returnBillData.POSBill.Customer != null) { _posWindow.ViewModel.CustomerInformation.Customer = returnBillData.POSBill.Customer; } _customerWindow.DialogResult = true; _customerWindow.Close(); } else { MessageBox.Show(string.Format(StringConstants.ReturnOtherBranchNotAllowd, returnBillData.BranchDetail.Name), "Return Item", MessageBoxButton.OK, MessageBoxImage.Information); } } else { if (returnBillData.POSBill.Customer != null) { _posWindow.ViewModel.CustomerInformation.Customer = returnBillData.POSBill.Customer; } _posWindow.ViewModel.CustomerInformation.ReturnBill = returnBillData; _customerWindow.DialogResult = true; _customerWindow.Close(); } } else { isError = true; Message = StringConstants.ReturnBillProceed; } } else { isError = true; Message = StringConstants.ReturnBillNotFount; } } else { isError = true; Message = StringConstants.ReturnBillNotFount; } } } else { isError = true; if (_isCustomer) { Message = StringConstants.CustomerNoRequired; } else if (_isReturnBill) { Message = StringConstants.ReturnBillNoRequired; } else { Message = StringConstants.CustomerPORequired; } } }