private async void SaveReleaseLineButton_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(QuantityTb.Text)) { MessageDialog message = new MessageDialog("Nie podano iloĊci.", "Operacja przerwana"); await message.ShowAsync(); return; } var Itm = ItemIDCb.SelectedItem as Item; var ISKU = StockKeepUnitCb.SelectedItem as ItemStockKeepUnit; var MagNr = WarehouseNameCb.SelectedItem as Warehouse; var MagPl = WarehousePlaceCb.SelectedItem as WarehousePlace; if (Itm == null) { MessageDialog message = new MessageDialog("Nie wybrano produktu", "Operacja przerwana"); await message.ShowAsync(); return; } if (ISKU == null) { MessageDialog message = new MessageDialog("Nie wybrano jednostki.", "Operacja przerwana"); await message.ShowAsync(); return; } using (DBContext dbCtx = new DBContext()) { int position = 0; if (dbCtx.ReleaseLines.Any(x => x.DocumentID == DocumentIDTb.Text)) { position = dbCtx.ReleaseLines.Last(x => x.DocumentID == DocumentIDTb.Text).PositionNumber + 1; } else { position = 1; } releaseLine = new ReleaseLine(DocumentIDTb.Text, position, Itm.ItemID, ISKU.Code, MagNr.WarehouseName, MagPl.WarehousePlaceName, Convert.ToDouble(QuantityTb.Text)); string errorMsg = InvMgt.isReleaseLineValid(releaseLine); if (String.IsNullOrEmpty(errorMsg)) { dbCtx.ReleaseLines.Add(releaseLine); dbCtx.SaveChanges(); this.Frame.Navigate(typeof(ReleaseHeaderPage), releaseHeader); } else { MessageDialog message = new MessageDialog(errorMsg, "Operacja przerwana"); await message.ShowAsync(); return; } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { releaseLine = (ReleaseLine)e.Parameter; if (releaseLine.DocumentID != null) { releaseHeader = dbCtx.ReleaseHeaders.FirstOrDefault(x => x.DocumentID == releaseLine.DocumentID); DocumentIDTb.Text = releaseLine.DocumentID; QuantityTb.Text = "0.0"; } }
private void SaveReleaseLineButton_Click(object sender, RoutedEventArgs e) { using (DBContext dbCtx = new DBContext()) { releaseLine = dbCtx.ReleaseLines.First(x => x.DocumentID == releaseLine.DocumentID && x.PositionNumber == releaseLine.PositionNumber); dbCtx.ReleaseLines.Attach(releaseLine); releaseLine.Quantity = Convert.ToDouble(QuantityTb.Text); releaseLine.ReleaseQuantity = Convert.ToDouble(ReleaseQuantityTb.Text); releaseLine.ReleasedQuantity = Convert.ToDouble(ReleasedQuantityTb.Text); dbCtx.SaveChanges(); } this.Frame.Navigate(typeof(ReleaseHeaderPage), releaseHeader); }
protected override void OnNavigatedTo(NavigationEventArgs e) { using (DBContext dbCtx = new DBContext()) { releaseLine = (ReleaseLine)e.Parameter; releaseHeader = dbCtx.ReleaseHeaders.First(x => x.DocumentID == releaseLine.DocumentID); DocumentIDTb.Text = releaseLine.DocumentID; QuantityTb.Text = releaseLine.Quantity.ToString(); ReleaseQuantityTb.Text = releaseLine.ReleaseQuantity.ToString(); ReleasedQuantityTb.Text = releaseLine.ReleasedQuantity.ToString(); } }
private void ReleaseLineList_Tapped(object sender, TappedRoutedEventArgs e) { ReleaseLine releaseLine = ReleaseLineList.SelectedItem as ReleaseLine; Frame.Navigate(typeof(ReleaseLineEditPage), releaseLine); }