private void btnMoveSN_Click(object sender, RoutedEventArgs e) { //Mueve un serial de una caja a otra. curPack = sourceTree.SelectedItem as DocumentPackage; newPack = destTree.SelectedItem as DocumentPackage; //if (curPack.PackID == 0) //{ // Util.ShowError("Please select a valid package."); // return; //} if (newPack == null || newPack.PackID == 0) { Util.ShowError("Please select a destination package."); return; } if (newPack.PackID == curPack.PackID) { Util.ShowError("Source and destination package are the same."); return; } if (newPack.Document.DocID != curPack.Document.DocID) { Util.ShowError("Source and destination document are different"); LoadTrees(); return; } if (newPack.PackID == 0) { Util.ShowError("Please select a valid destination package."); return; } if (lvSerials.SelectedItem == null) { Util.ShowError("No serial barcode selected."); return; } if (newPack.IsClosed == true) { Util.ShowError("Destination package is closed."); return; } //Define si Curpack debe ser el root //if (curPack.PackID == 0) //curPack = rootPackage; IList <WpfFront.WMSBusinessService.Label> movedLabels = new List <WpfFront.WMSBusinessService.Label>(); foreach (WpfFront.WMSBusinessService.Label affectedLabel in lvSerials.SelectedItems) { affectedLabel.FatherLabel = newPack.PackLabel; affectedLabel.ModDate = DateTime.Now; affectedLabel.ModifiedBy = App.curUser.UserName; movedLabels.Add(affectedLabel); PackDetailsSN.Remove(affectedLabel); } service.UpdatePackageMovedLabels(movedLabels); lvSerials.Items.Refresh(); }
private void AddSerial() { if (string.IsNullOrEmpty(txtUnique.Text)) { Util.ShowError("No valid data."); return; } try { //Mueve uno de los labels existentes al package indicado. //1. Validar package is selected //Mueve un serial de una caja a otra. newPack = sourceTree.SelectedItem as DocumentPackage; if (newPack == null || newPack.PackID == 0) { Util.ShowError("Please select a package."); txtUnique.Text = ""; return; } if (newPack.IsClosed == true) { Util.ShowError("Package is closed."); return; } //2. Buscar el S/N - labelcode dentro de el listado de labels del shipment WpfFront.WMSBusinessService.Label labelToPack; try { labelToPack = service.GetNodeTrace(new NodeTrace { Label = new WpfFront.WMSBusinessService.Label { LabelCode = txtUnique.Text }, Document = curDoc, PostingDocument = curPosted }).Select(f => f.Label).First(); } catch { Util.ShowError("S/N or Barcode not found in the shipment."); txtUnique.Text = ""; return; } //3. Cambiar el Label de posicion al nuevo Package. labelToPack.FatherLabel = newPack.PackLabel; labelToPack.ModDate = DateTime.Now; labelToPack.ModifiedBy = App.curUser.UserName; service.UpdateLabel(labelToPack); //4. Refresh if (!PackDetailsSN.Any(f => f.LabelID == labelToPack.LabelID)) { PackDetailsSN.Add(labelToPack); lvSerials.Items.Refresh(); } } finally { txtUnique.Text = ""; txtUnique.Focus(); } }