public IList<DocumentPackage> Select(DocumentPackage data) { IList<DocumentPackage> datos = new List<DocumentPackage>(); try { datos = GetHsql(data).List<DocumentPackage>(); //if (!Factory.IsTransactional) // Factory.Commit(); } catch (Exception e) { NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e)); } return datos; }
public DocumentPackage CreateNewPackage(Document document, SysUser picker, bool isOpen, DocumentPackage parent, string packageType) { return TranMngr.CreateNewPackage(document, picker, isOpen, parent, packageType); }
public void UpdateDocumentPackage(DocumentPackage data) { Factory.DaoDocumentPackage().Update(data); }
public void DeleteDocumentPackage(DocumentPackage data) { try { //Revisa que ese package no tenga hijos if (data.PackLabel.LabelID > 0) { IList<Label> lblList = Factory.DaoLabel() .Select(new Label { LabelType = new DocumentType { DocTypeID = LabelType.ProductLabel }, FatherLabel = new Label { LabelID = data.PackLabel.LabelID } }); if (lblList == null || lblList.Count == 0) Factory.DaoDocumentPackage().Delete(data); } } catch { } }
public DocumentPackage SaveDocumentPackage(DocumentPackage data) { return Factory.DaoDocumentPackage().Save(data); }
public IList<DocumentPackage> GetDocumentPackage(DocumentPackage data) { return Factory.DaoDocumentPackage().Select(data); }
private IList<ReportDetailFormat> GetDetailsWithKitAssembly(IList<ReportDetailFormat> pkgDetails, Document shpDocument, DocumentPackage pkg) { ReportDetailFormat detail = null; DocumentLine curLine = null; int kitLine; //IList<DocumentLine> processeKits = new List<DocumentLine>(); //Inner join del documento contra las los pkgdetails, obteniendo los documentlines. IList<DocumentLine> shpLines = Factory.DaoDocumentLine().Select(new DocumentLine { Document = shpDocument }); //Obtiene las lineas del documento que son tocadas por los detalles del paquete a procesar. shpLines = (from sales in shpLines join pack in pkgDetails on sales.Product.ProductCode equals pack.ProductCode select sales).Distinct().ToList(); //Lleva el conteo d ela sequencia para cada Kit Dictionary<DocumentLine, int> countKit = new Dictionary<DocumentLine,int>(); int nextKit = 1; int countComponent = 1; //Recorre los componentes para encontrar su Kit/Assembly Padre. foreach (DocumentLine dl in shpLines.Where(f => f.Note == "1").OrderBy(f => f.LinkDocLineNumber)) { try { //Entrega la linea del KIT/ASSEMBLY en el Sales Order kitLine = Factory.DaoDocumentLine().Select( new DocumentLine { LineNumber = dl.LinkDocLineNumber, Document = new Document { DocNumber = dl.LinkDocNumber, Company = dl.Document.Company } } ).First().LinkDocLineNumber; curLine = Factory.DaoDocumentLine().Select( new DocumentLine { LineNumber = kitLine, Document = new Document { DocNumber = dl.LinkDocNumber, Company = dl.Document.Company } } ).First(); //revisa si ese kit aun no ha sido procesado. Si fue procesado va al siguiente if (countKit.Where(f => f.Key.LineNumber == curLine.LineNumber).Count() > 0) { //A los paquetes que tiene ese producto se les pone subdetail foreach (ReportDetailFormat pkgDet in pkgDetails.Where(f => f.ProductCode == dl.Product.ProductCode)) { pkgDet.IsSubDetail = true; pkgDet.AuxSequence = countKit[curLine] + countComponent++; pkgDet.Custom1 = curLine.Product.Category.ExplodeKit.ToString(); //Adicionado para Maxiforce caterpillar } continue; } else { //processeKits.Add(curLine); countKit.Add(curLine, 1000 * nextKit++); } //A los paquetes que tiene ese producto se les pone subdetail foreach (ReportDetailFormat pkgDet in pkgDetails.Where(f => f.ProductCode == dl.Product.ProductCode)) { pkgDet.IsSubDetail = true; pkgDet.AuxSequence = countKit[curLine] + countComponent++; pkgDet.Custom1 = curLine.Product.Category.ExplodeKit.ToString(); //Adicionado para Maxiforce caterpillar } } catch { continue; } //Crea una linea para el documento de shipment detail = new ReportDetailFormat { //Grouped By Pack - Label BarcodeLabel = pkg.PackLabel.Barcode, PackWeight = pkg.Weight, Dimension = pkg.Dimension, //Map Data ProductCode = curLine.Product.ProductCode, ProductDescription = curLine.Product.Name, Unit = curLine.Unit.Name, CreatedBy = pkg.CreatedBy, IsSubDetail = false, AuxSequence = countKit[curLine] }; IList<ProductAccountRelation> acctItem = null; //Customer Item Number if (shpDocument.Customer.AccountCode != WmsSetupValues.DEFAULT) { acctItem = curLine.Product.ProductAccounts.Where(f => f.Account.AccountID == shpDocument.Customer.AccountID).ToList(); if (acctItem != null && acctItem.Count() > 0) detail.AccountItemNumber = acctItem[0].ItemNumber; } if (detail.AccountItemNumber == null) detail.AccountItemNumber = ""; pkgDetails.Add(detail); } return pkgDetails; }
/// <summary> /// Crea a new label package for a specific document, this package will contain product picked for the order. /// </summary> /// <param name="line"></param> /// <param name="picker"></param> /// <returns></returns> public DocumentPackage CreateNewPackage(Document document, SysUser picker, bool isOpen, DocumentPackage parent, string packageType) { Factory.IsTransactional = true; Node node = WType.GetNode(new Node { NodeID = NodeType.Picked }); Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); DocumentType labelType = WType.GetLabelType(new DocumentType { DocTypeID = LabelType.CustomerLabel }); Unit logisticUnit = WType.GetUnit(new Unit { Company = document.Company, Name = WmsSetupValues.CustomUnit }); Bin destLocation = WType.GetBin(new Bin { Location = document.Location, BinCode = DefaultBin.PICKING }); int sequence = Factory.DaoDocumentPackage().Select(new DocumentPackage { Document = document, //PostingDocument = new Document {DocID = -1 } }).Count + 1; //Generate new logistig labels located in MAIN //Labels shouldbe activated the next transaction try { //Funcion para obtener siguiente Label //DocumentTypeSequence initSequence = GetNextDocSequence(document.Company, labelType); Label packLabel = new Label(); packLabel.Node = node; packLabel.Bin = destLocation; packLabel.CreatedBy = picker.UserName; packLabel.Status = status; packLabel.LabelType = labelType; packLabel.CreationDate = DateTime.Now; packLabel.Printed = false; packLabel.Unit = logisticUnit; packLabel.IsLogistic = true; packLabel.LabelCode = ""; // initSequence.NumSequence.ToString() + GetRandomHex(picker.UserName, initSequence.NumSequence); packLabel.Notes = "Package label for Document # " + document.DocNumber; packLabel.ShippingDocument = document; //Added on 14/ENE/09 if (parent != null && parent.PackLabel != null && parent.PackLabel.LabelID != 0) { try { packLabel.FatherLabel = parent.PackLabel; } catch { } } //Creado el document Package Asociado al Label DocumentPackage docPack = new DocumentPackage { Document = document, CreatedBy = picker.UserName, CreationDate = DateTime.Now, IsClosed = !isOpen, PackLabel = packLabel, Picker = picker, StartTime = DateTime.Now, EndTime = DateTime.Now, Sequence = (short)sequence, Dimension = "", ShipToName = document.Customer.Name, //Added on 14/ENE/09 ParentPackage = (parent != null && parent.PackID != 0) ? parent : null, PackageType = packageType }; //Address Line for package 16/oct/09 DocumentAddress ShipTo_address = null; try { ShipTo_address = Factory.DaoDocumentAddress().Select( new DocumentAddress { Document = document, AddressType = AddressType.Shipping }) .Where(f => f.DocumentLine == null).First(); docPack.AddressLine1 = ShipTo_address.AddressLine1 + " " + ShipTo_address.AddressLine2; docPack.AddressLine2 = ShipTo_address.City + ", " + ShipTo_address.State + " " + ShipTo_address.ZipCode; docPack.AddressLine3 = ShipTo_address.Country; } catch { } packLabel.DocumentPackages = new List<DocumentPackage> { docPack }; packLabel = Factory.DaoLabel().Save(packLabel); packLabel.LabelCode = packLabel.LabelID.ToString(); //Registra el movimiento del nodo SaveNodeTrace( new NodeTrace { Node = node, Document = document, Label = packLabel, Quantity = packLabel.CurrQty, IsDebit = false, CreatedBy = picker.UserName } ); //initSequence.NumSequence; //Factory.DaoDocumentTypeSequence().Update(initSequence); Factory.Commit(); //actualizando el documento try { if (string.IsNullOrEmpty(document.UserDef3)) { //document.UserDef3 = picker.UserName; Factory.DaoDocument().Update(document); } } catch { } return docPack; } catch { throw; } }
public Boolean Delete(DocumentPackage data) { return base.Delete(data); }
public DocumentPackage SelectById(DocumentPackage data) { return (DocumentPackage)base.SelectById(data); }
public Boolean Update(DocumentPackage data) { return base.Update(data); }
public DocumentPackage Save(DocumentPackage data) { return (DocumentPackage)base.Save(data); }
public void CloseDocumentPackage(DocumentPackage newPack) { try { //Close package and his childs. Factory.IsTransactional = true; newPack = Factory.DaoDocumentPackage().Select(new DocumentPackage { PackID = newPack.PackID }).First(); newPack.IsClosed = true; Factory.DaoDocumentPackage().Update(newPack); foreach (DocumentPackage child in newPack.ChildPackages) { child.IsClosed = true; Factory.DaoDocumentPackage().Update(child); } Factory.Commit(); } catch { Factory.Rollback(); throw; } }
public void MoveQtyBetweenPackages(DocumentPackage curPack, DocumentPackage newPack, Product product, double qty) { TranMngr.MoveQtyBetweenPackages(curPack, newPack, product, qty); }
private string GetParentPallet(DocumentPackage pkg) { if (pkg.ParentPackage == null) return pkg.PackLabel.LabelCode; return GetParentPallet(pkg.ParentPackage); }
public void CloseDocumentPackage(DocumentPackage newPack) { LabelMngr.CloseDocumentPackage(newPack); }
//Mueve cantidades de un package a otro public void MoveQtyBetweenPackages(DocumentPackage curPack, DocumentPackage newPack, Product product, double qty) { Factory.IsTransactional = true; Unit baseUnit = product.BaseUnit; try { DocumentLine line = new DocumentLine { Quantity = qty, Product = product, Unit = baseUnit, CreatedBy = newPack.CreatedBy }; #region remove from OLD package //######################################################################### //Remover la cantidad del paquete origen //Saca las cantidades para es BIN y de ese producto. IList<Label> labelList = GetPackageLabels(curPack.PackLabel, line); Label sourceLabel = null; if (labelList.Sum(f => f.BaseCurrQty) < line.Quantity * line.Unit.BaseAmount) { Factory.Rollback(); throw new Exception("No quantity available for the transaction."); } //Recorre los labels hasta que termine el saldo y se salga. double qtyBalance = line.Quantity * line.Unit.BaseAmount; double curQty; foreach (Label label in labelList) { if (qtyBalance <= 0) break; label.CurrQty = label.BaseCurrQty; label.StartQty = label.BaseStartQty; label.Unit = baseUnit; //Cantidad a Disminuir curQty = qtyBalance > label.CurrQty ? label.CurrQty : qtyBalance; qtyBalance -= curQty; label.CurrQty -= curQty; label.ModDate = DateTime.Now; label.ModifiedBy = line.CreatedBy; Factory.DaoLabel().Update(label); sourceLabel = label; } #endregion #region add to NEW package //######################################################################### //Adicionar la cantidad al paquete destino Label tmpLabel = null; Status statusLock = WType.GetStatus(new Status { StatusID = EntityStatus.Locked }); //Active DocumentType lblType = new DocumentType { DocTypeID = LabelType.ProductLabel }; //DocumentTypeSequence initSequence = DocMngr.GetNextDocSequence(curPack.Document.Company, lblType); //Funcion para obtener siguiente Label //Salvar con el nuevo status tmpLabel = new Label(); //To Send Node node = WType.GetNode(new Node { NodeID = NodeType.Released }); tmpLabel.Node = curPack.PackLabel.Node; tmpLabel.Bin = curPack.PackLabel.Bin; tmpLabel.CurrQty = line.Quantity; tmpLabel.Product = line.Product; tmpLabel.StartQty = line.Quantity; tmpLabel.Unit = line.Product.BaseUnit; tmpLabel.CreatedBy = line.CreatedBy; tmpLabel.Status = statusLock; tmpLabel.LabelType = lblType; tmpLabel.LabelCode = ""; // initSequence.NumSequence.ToString() + GetRandomHex(line.CreatedBy, initSequence.NumSequence); tmpLabel.Printed = false; tmpLabel.CreationDate = DateTime.Now; tmpLabel.IsLogistic = false; tmpLabel.ShippingDocument = curPack.Document; tmpLabel.LabelSource = sourceLabel; tmpLabel.FatherLabel = newPack.PackLabel; tmpLabel = Factory.DaoLabel().Save(tmpLabel); #endregion Factory.Commit(); } catch { Factory.Rollback(); throw; } }