private async void UnlinkRows() { dgLinkedGrid.SelectedItem = null; dgUnlinkedGrid.SelectedItem = null; var dcolSerieBatchList = new List <DCOrderLineSerieBatch>(); var linkedRows = dgLinkedGrid.ItemsSource as List <SerialToOrderLineClient>; if (linkedRows == null) { dcorderlineMaster.SerieBatchMarked = false; return; } bool AllRemoved = true; foreach (var row in linkedRows) { if (row.Mark) { var olSerieBatch = new DCOrderLineSerieBatch(); olSerieBatch.SetMaster(dcorderlineMaster as UnicontaBaseEntity); olSerieBatch.SetMaster(row); olSerieBatch._Qty = row._QtyMarked; dcolSerieBatchList.Add(olSerieBatch); } else { AllRemoved = false; } } var err = await api.Delete(dcolSerieBatchList); if (err != ErrorCodes.Succes) { UtilDisplay.ShowErrorCode(err); } else { InitQuery(); if (AllRemoved) { dcorderlineMaster.SerieBatchMarked = false; } } }
private async Task LinkRows(bool added) { dgLinkedGrid.SelectedItem = null; dgUnlinkedGrid.SelectedItem = null; List <SerialToOrderLineClient> unlinkedRows; if (added) { unlinkedRows = dgLinkedGrid.ItemsSource as List <SerialToOrderLineClient>; } else { unlinkedRows = dgUnlinkedGrid.ItemsSource as List <SerialToOrderLineClient>; } if (unlinkedRows == null || unlinkedRows.Count == 0) { return; } var markedList = unlinkedRows.Where(r => r.Mark).ToList(); if (!added) { var linkedRows = dgLinkedGrid.ItemsSource as List <SerialToOrderLineClient>; if (markedList.Count == 0) { return; } if (linkedRows.Intersect(markedList).Any()) { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("LinkedRowErrorMsg"), Uniconta.ClientTools.Localization.lookup("Error")); return; } } if (markedList.Count == 0) { return; } UnicontaBaseEntity orgMaster = null; var dcorderlineMaster = this.dcorderlineMaster; var _UseSerial = this.invItemMaster._UseSerial; List <DCOrderLineSerieBatch> olSerieBatchList = new List <DCOrderLineSerieBatch>(); foreach (var row in markedList) { var olSerieBatch = new DCOrderLineSerieBatch(); double qty; if (_UseSerial) { qty = dcorderlineMaster._Qty >= 0 ? 1d : -1d; } else if (row._QtyMarked != 0) { qty = row._QtyMarked; } else { qty = dcorderlineMaster._Qty; } olSerieBatch._Qty = qty; olSerieBatch.SetMaster(row); olSerieBatch.SetMaster(dcorderlineMaster as UnicontaBaseEntity); olSerieBatchList.Add(olSerieBatch); if (row._Warehouse != null && (dcorderlineMaster._Warehouse != row._Warehouse || dcorderlineMaster._Location != row._Location)) { if (orgMaster == null && dcorderlineMaster.RowId != 0) { orgMaster = StreamingManager.Clone((UnicontaBaseEntity)dcorderlineMaster); } dcorderlineMaster.Warehouse = row._Warehouse; dcorderlineMaster.Location = row._Location; if (markedList.Count == 1) { dcorderlineMaster.SerieBatch = row._Number; } else { dcorderlineMaster.SerieBatch = null; } } else { string nr = dcorderlineMaster._SerieBatch, newNr; if (markedList.Count == 1) { newNr = row._Number; } else { newNr = null; } if (newNr != nr) { if (orgMaster == null && dcorderlineMaster.RowId != 0) { orgMaster = StreamingManager.Clone((UnicontaBaseEntity)dcorderlineMaster); } dcorderlineMaster.SerieBatch = newNr; } } } ErrorCodes err; if (orgMaster != null) { dcorderlineMaster.SerieBatchMarked = true; var Updates = new Uniconta.API.System.CrudAPI.UpdatePair() { loaded = orgMaster, modified = (UnicontaBaseEntity)dcorderlineMaster }; err = await api.MultiCrud(olSerieBatchList, new[] { Updates }, null); } else { err = await api.Insert(olSerieBatchList); } if (err != ErrorCodes.Succes) { UtilDisplay.ShowErrorCode(err); } else { dcorderlineMaster.SerieBatchMarked = true; if (!saveAndExit) { InitQuery(); } } }
private async void UnlinkRows() { var dcorderlineMaster = this.dcorderlineMaster; UnicontaBaseEntity orgMaster; dgLinkedGrid.SelectedItem = null; dgUnlinkedGrid.SelectedItem = null; var dcolSerieBatchList = new List <DCOrderLineSerieBatch>(); var linkedRows = dgLinkedGrid.ItemsSource as List <SerialToOrderLineClient>; if (linkedRows == null || linkedRows.Count == 0) { if (dcorderlineMaster._SerieBatchMarked && dcorderlineMaster.RowId != 0) { orgMaster = StreamingManager.Clone((UnicontaBaseEntity)dcorderlineMaster); dcorderlineMaster.SerieBatch = null; dcorderlineMaster.SerieBatchMarked = false; api.UpdateNoResponse(orgMaster, (UnicontaBaseEntity)dcorderlineMaster); } dcorderlineMaster.SerieBatch = null; dcorderlineMaster.SerieBatchMarked = false; return; } bool AllRemoved = true; foreach (var row in linkedRows) { if (row.Mark) { var olSerieBatch = new DCOrderLineSerieBatch(); olSerieBatch.SetMaster(dcorderlineMaster as UnicontaBaseEntity); olSerieBatch.SetMaster(row); olSerieBatch._Qty = row._QtyMarked; dcolSerieBatchList.Add(olSerieBatch); } else { AllRemoved = false; } } ErrorCodes err; if (dcorderlineMaster._SerieBatch != null && dcorderlineMaster.RowId != 0) { orgMaster = StreamingManager.Clone((UnicontaBaseEntity)dcorderlineMaster); dcorderlineMaster.SerieBatch = null; if (AllRemoved) { dcorderlineMaster.SerieBatchMarked = false; } var Updates = new Uniconta.API.System.CrudAPI.UpdatePair() { loaded = orgMaster, modified = (UnicontaBaseEntity)dcorderlineMaster }; err = await api.MultiCrud(null, new[] { Updates }, dcolSerieBatchList); } else { err = await api.Delete(dcolSerieBatchList); } if (err != ErrorCodes.Succes) { UtilDisplay.ShowErrorCode(err); } else { InitQuery(); dcorderlineMaster.SerieBatch = null; if (AllRemoved) { dcorderlineMaster.SerieBatchMarked = false; } } }
private async Task LinkRows(bool added) { dgLinkedGrid.SelectedItem = null; dgUnlinkedGrid.SelectedItem = null; List <SerialToOrderLineClient> unlinkedRows; if (added) { unlinkedRows = dgLinkedGrid.ItemsSource as List <SerialToOrderLineClient>; } else { unlinkedRows = dgUnlinkedGrid.ItemsSource as List <SerialToOrderLineClient>; } if (unlinkedRows == null || unlinkedRows.Count == 0) { return; } var markedList = unlinkedRows.Where(r => r.Mark).ToList(); if (!added) { var linkedRows = dgLinkedGrid.ItemsSource as List <SerialToOrderLineClient>; if (markedList.Count == 0) { return; } if (linkedRows.Intersect(markedList).Count() > 0) { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("LinkedRowErrorMsg"), Uniconta.ClientTools.Localization.lookup("Error")); return; } } if (markedList.Count == 0) { return; } var _UseSerial = this.invItemMaster._UseSerial; List <DCOrderLineSerieBatch> olSerieBatchList = new List <DCOrderLineSerieBatch>(); foreach (var row in markedList) { var olSerieBatch = new DCOrderLineSerieBatch(); double qty; if (_UseSerial) { qty = dcorderlineMaster._Qty >= 0 ? 1d : -1d; } else if (row._QtyMarked != 0) { qty = row._QtyMarked; } else { qty = dcorderlineMaster._Qty; } olSerieBatch._Qty = qty; olSerieBatch.SetMaster(row); olSerieBatch.SetMaster(dcorderlineMaster as UnicontaBaseEntity); olSerieBatchList.Add(olSerieBatch); if (row._Warehouse != null) { dcorderlineMaster.Warehouse = row._Warehouse; dcorderlineMaster.Location = row._Location; } } var err = await api.Insert(olSerieBatchList); if (err != ErrorCodes.Succes) { UtilDisplay.ShowErrorCode(err); } else { dcorderlineMaster.SerieBatchMarked = true; InitQuery(); } }