private void btnDeleteCard_Click(object sender, RoutedEventArgs e) { var r = MessageBox .Show("You are about to delete a Route card permanently!!\nPlease note that this action cannot be undone!" , "Delete", MessageBoxButton.OKCancel); if (r == MessageBoxResult.OK) { var proxy = new RouteCardServiceClient(); try { proxy.DeleteRoutCardCompleted += (s, ev) => MessageBox.Show("Route Card Deleted!", "Delete!", MessageBoxButton.OK); proxy.DeleteRoutCardAsync(MyViewModel.Iserial, LoggedUserInfo.Iserial); btnCancel_Click(null, null); } catch (Exception) { throw; } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (sender == BtnSave) { PostOrNo = 0; } else if (sender == BtnPostToAx) { PostOrNo = 1; } if (MyViewModel.Iserial == 0) { var proxy = new RouteCardServiceClient(); proxy.GetMaxRouteCardTransactionIDAsync((int)CmbRouteGroup.SelectedValue, CmbDirection.SelectedIndex, MyViewModel.TransactionType); proxy.GetMaxRouteCardTransactionIDCompleted += _proxy_GetMaxRouteCardTransactionIDCompleted; } else { var proxy = new RouteCardServiceClient(); proxy.GetMaxRouteCardTransactionIDAsync((int)CmbRouteGroup.SelectedValue, CmbDirection.SelectedIndex, MyViewModel.TransactionType); proxy.GetMaxRouteCardTransactionIDCompleted += (s, ev) => { var myViewModel = (LayoutRoot.DataContext as RouteCardHeaderViewModel); var routerCardFabricRow = new ObservableCollection <RouteCardService.RouteCardFabric>(); if (myViewModel != null) { MyViewModel.TransID = (ev.Result + 1); foreach (var routeFabricRow in myViewModel.RouteCardFabricViewModelList) { routerCardFabricRow.Add(RouteCardMappers.MapToViewModel(routeFabricRow)); } var rch = new RouteCardService.RouteCardHeader(); var rcd = new ObservableCollection <RouteCardService.RouteCardDetail>(); try { RouteCardMappers.MapToViewModel(myViewModel, rch); foreach (var item in myViewModel.RouteCardDetails) { foreach (var sizeItem in item.RoutCardSizes.Where(x => x.SizeCode != "")) { rcd.Add(new RouteCardService.RouteCardDetail { TblColor = item.TblColor, Degree = item.Degree, TblSalesOrder = item.TblSalesOrder, Trans_TransactionHeader = rch.TransID, Size = sizeItem.SizeCode, SizeQuantity = sizeItem.SizeConsumption, RoutGroupID = rch.RoutGroupID, Direction = rch.Direction, ObjectIndex = item.ObjectIndex, Price = item.Price, Notes = item.Notes, Blocks = item.Blocks, TblWarehouse = item.TblWarehouse }); } } myViewModel.SaveRouteCard(rch, rcd, "update", PostOrNo); tBlockTransID.Text = rch.TransID.ToString(CultureInfo.InvariantCulture); //btnCancel_Click(null, null); } catch (Exception ex) { var err = new ErrorWindow(ex); } } }; } }