コード例 #1
0
        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;
        }
コード例 #2
0
        private ReportHeaderFormat ProcessHeaderAndDetailsForHAZMAT(Document document)
        {

            ReportHeaderFormat header = ProcessHeader(document);


            #region Map Details for each document Line
            // 
            //ReportDetailFormat detail;
            IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();
            ReportDetailFormat detail;

            //TODO: Incluir Filtro por bodega zona en este punto para solo obtener los detalles del filtro
            int sequence = 1;

            IList<DocumentLine> hazmatLines = Factory.DaoDocumentLine()
                .Select(new DocumentLine { Document = new Document { DocID = document.DocID } });

            bool isHazmat = false;
            foreach (DocumentLine line in hazmatLines)
                if (line.Product.ProductTrack.Any(f => f.TrackOption.Name == "HAZMAT"))
                {
                    isHazmat = true;
                    line.Note = "HAZMAT";
                }
                

            if (!isHazmat)   //SI NO ES HAZMAT SALE
                return null;

            int qtyOrder;
            foreach (Product product in hazmatLines.Where(f=>f.Note=="HAZMAT").Select(f=>f.Product).Distinct())
            {
                detail = new ReportDetailFormat();

                detail.SeqLine = sequence++;
                detail.ProductDescription = string.IsNullOrEmpty(product.Comment) ? "NO HAZMAT COMMENT, PLEASE GO TO PRODUCT CARD" : product.Comment;
                detail.ProductDescription = product.Name + "\n" + detail.ProductDescription;
                detail.ProductCode = product.ProductCode;
                

                qtyOrder = (int)hazmatLines.Where(f=>f.Product.ProductID == product.ProductID).Sum(f=>f.Quantity);
                detail.QtyOrder = (product.UnitsPerPack > 0) ? qtyOrder / product.UnitsPerPack : qtyOrder;

                //Peso por caja
                detail.PackWeight  = product.Weight * detail.QtyOrder;

                // CAA [2010/05/07]
                // Se agrega el campo de peso (individual)
                detail.Weight = product.Weight;

                if (detail.ProductDescription.Contains("Not Regulated"))
                    detail.Notes = "";
                else
                    detail.Notes = "XX";

                detailList.Add(detail);

                header.TotalCases += detail.QtyOrder;
                header.TotalWeight += detail.PackWeight;

            }

            #endregion


            header.ReportDetails = detailList.ToList();
            return header;

        }
コード例 #3
0
        /// <summary>
        /// Shipment document debe manejar los packages en el DEtail, the Header es el mismo
        /// que los documentos standar
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        private ReportHeaderFormat ProcessHeaderAndDetailsForShipment(Document document)
        {

            ReportHeaderFormat header = ProcessHeader(document);

           

            #region Map Details for each document Line

            // 
            //ReportDetailFormat detail;
            IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();

            //TODO: Incluir Filtro por bodega zona en este punto para solo obtener los detalles del filtro
            //int sequence = 1, subSequence = 1;
            double totWeight = 0, totCases = 0, allCases = 0, totPallet = 0, totQtyOrder = 0, totProductWeight = 0;
            double totExtendedPrice = 0;

            //Obteniendo los Packages de ese Documento.
            IList<DocumentPackage> packList = Factory.DaoDocumentPackage().Select(
                new DocumentPackage { PostingDocument = document });

            IList<Label> containedLabels;
            ReportDetailFormat detail;
            IList<ReportDetailFormat> packDetail; 
            int level = -1; // 0 = Box, 1 = pallet

            foreach (DocumentPackage pkg in packList)
            {

                header.Date2 = pkg.CreationDate.ToString();

                //Obtiene los labels Contenidos en ese package                
                containedLabels = Factory.DaoLabel().Select(new Label { FatherLabel = pkg.PackLabel })
                    .Where(f => f.StockQty > 0).ToList();
                //.Where(f=>f.CurrQty > 0).ToList();

                //Guarda los detalles de cada paquete
                packDetail = new List<ReportDetailFormat>();


                //Adicion manejo de Pallets and cases.
                /*
                if (pkg.ChildPackages == null || pkg.ChildPackages.Count == 0)
                {
                    if (pkg.ParentPackage == null)
                    {
                        level = 0; //Single box
                        totCases++;
                    }
                    else
                        level = 1; //Box inside pallet

                    allCases++;
                }
                else
                {
                    level = 2; //Pallet
                    totPallet++;
                }
                */

                if (pkg.PackageType == "P")
                {
                    level = 2; //Pallet
                    totPallet++;
                }
                else if (pkg.PackageType == "B")
                {
                    level = 1; 

                    if (pkg.ParentPackage == null)
                    {
                        level = 0; //Single box
                        totCases++;
                    }

                    allCases++;
                }
                else { allCases++; }



                //foreach (Label curLabel in containedLabels)
                foreach (Product curLabel in containedLabels.Select(f => f.Product).Distinct())
                {

                    detail = new ReportDetailFormat();


                    //Grouped By Pack - Label
                    detail.BarcodeLabel = pkg.PackLabel.Barcode;
                    detail.PackWeight = pkg.Weight;
                    detail.Dimension = pkg.Dimension;
                    detail.Pieces = pkg.Pieces;
                    detail.CreatedBy = pkg.CreatedBy;


                    //Map Data
                    detail.ProductCode = curLabel.ProductCode;
                    detail.ProductDescription = curLabel.Name;
                    detail.Unit = curLabel.BaseUnit.Name;
                    detail.ProductCost = curLabel.ProductCost;
                    //CUSTOM
                    detail.Custom1 = curLabel.Manufacturer;
                    detail.Custom2 = curLabel.Reference;


                    //Agrupo por producto dentro del package. para mostrar una sola linea
                    detail.Weight = curLabel.Weight * containedLabels.Where(f => f.Product.ProductCode == curLabel.ProductCode).Sum(f => f.StockQty * f.Unit.BaseAmount); //CurrQty
                    detail.QtyOrder = containedLabels.Where(f => f.Product.ProductCode == curLabel.ProductCode).Sum(f => f.StockQty * f.Unit.BaseAmount);
                    totQtyOrder += containedLabels.Where(f => f.Product.ProductCode == curLabel.ProductCode).Sum(f => f.StockQty * f.Unit.BaseAmount);
                    totProductWeight += detail.Weight;

                    totExtendedPrice += detail.QtyOrder * curLabel.ProductCost;

                    //Descripcion del pallet
                    //detail.PackLevel = 0;
                    if (level == 0)
                    {
                        //detail.PalletNote = "";
                        detail.LogisticNote = "SINGLE BOX " + pkg.PackLabel.LabelCode;
                    }

                    else if (level == 1)
                    {
                        //CASE INSIDE PALLET
                        //detail.PalletNote = "PALLET " + GetParentPallet(pkg);
                        detail.LogisticNote = "PALLET " + GetParentPallet(pkg) + " >> BOX " + pkg.PackLabel.LabelCode; //"PL " + pkg.ParentPackage.Sequence.ToString() + "/" + pkg.PackLabel.LabelCode;
                    }

                    else
                    {
                        //detail.PalletNote = "PALLET " + pkg.PackLabel.LabelCode;
                        detail.LogisticNote = "PALLET " + pkg.PackLabel.LabelCode + " >> W/OUT BOX";
                    }


                    //IList<ProductAccountRelation> acctItem = null;

                    ////Customer Item Number
                    //if (document.Customer.AccountCode != WmsSetupValues.DEFAULT)
                    //{
                    //    acctItem = curLabel.Product.ProductAccounts.Where(f => f.Account.AccountID == document.Customer.AccountID).ToList();
                    //    if (acctItem != null && acctItem.Count() > 0)
                    //        detail.AccountItemNumber = acctItem[0].ItemNumber;
                    //}

                    //if (detail.AccountItemNumber == null)
                    //    detail.AccountItemNumber = "";

                    //Adicinando el Detalle                    
                    packDetail.Add(detail);
                }

                //Recorre los detalles de cada Package para saber si es un detalle de Kit lo que hace que
                //Adicione un Detalle nuevo (Padre)
                foreach (ReportDetailFormat kitDetail in GetDetailsWithKitAssembly(packDetail, document, pkg))
                    detailList.Add(kitDetail);


                totWeight += pkg.Weight;
                //totCases++;

            }

            #endregion


            #region Shipment Totals
            //En un Shipment enviar el CustPOUmber
            try
            {
                header.OrigNumber = Factory.DaoDocument().Select(new Document { DocNumber = document.CustPONumber, Company = document.Company }).First().CustPONumber;
            }
            catch { }

            // Totals
            try { header.TotalExtended = double.Parse(totExtendedPrice.ToString("###,###.##")); } //totExtendedPrice; 
            catch { }

            header.TotalCases = totCases;
            header.TotalPallets = totPallet;
            header.AllCases = allCases;
            header.TotalWeight = totWeight > 0 ? totWeight : totProductWeight;
            header.TotalQtyOrder = totQtyOrder;


            header.ReportDetails = detailList.OrderBy(f => f.AuxSequence).ToList();

            #endregion

            return header;
        }
コード例 #4
0
        private ReportHeaderFormat ProcessHeaderAndDetailsForCounting(Document document)
        {
            ReportHeaderFormat header = ProcessHeader(document);

            //Consolida todos los ajuste realizados para Confirmar la Tarea de Inventario
            //Y los muestra como Documento.
            IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();
            ReportDetailFormat detail;

            int seq = 1;
            if (document.DocStatus.StatusID == DocStatus.New || document.DocStatus.StatusID == DocStatus.InProcess)
            {
                //Si no esta posteada muestar la Executon task

                //Pattern
                IList<ProductStock> listCompleted = Factory.DaoBinByTask().GetCountInitialSummary(document);

                //Para que el doc no salga en blanco
                if (listCompleted == null || listCompleted.Count == 0) 
                    detailList.Add(new ReportDetailFormat());


                foreach (ProductStock record in listCompleted)
                {
                    detail = new ReportDetailFormat();

                    if (record.Product != null)
                    {
                        detail.ProductCode = record.Product.ProductCode;
                        detail.ProductDescription = record.Product.Name;
                    }
                    else
                    {
                        detail.ProductCode = "";
                        detail.ProductDescription = "";
                    }

                    detail.StockBin = record.Bin.BinCode;
                    detail.SeqLine = seq++;
                    detail.Rank = record.Bin.Rank;

                    detail.QtyOrder = record.Stock - record.PackStock; //DIFF
                    detail.QtyPending = record.PackStock; //Expected
                    try { detail.ProductCost = record.Product.ProductCost; }
                    catch { }
                    try { detail.ExtendedCost = record.Product.ProductCost * (record.Stock - record.PackStock); }
                    catch { }
                    detail.Date1 = record.MinDate != null ? record.MinDate.Value.ToString() : "";
                    detail.CreatedBy = document.CreatedBy;
                    detail.DocNumber = document.DocNumber;

                    detail.BarcodeLabel = record.Label != null ? "Barcode: " + record.Label.LabelCode : "";
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = 0;


                    detailList.Add(detail);

                    var sortedProducts = from p in detailList orderby p.Rank select p;
                    header.ReportDetails = sortedProducts.ToList();

                }


            }


            else if (document.DocStatus.StatusID == DocStatus.Completed)
            {
                //Si no esta posteada muestar la Executon task

                //Pattern
                IList<CountTaskBalance> listCompleted = Factory.DaoBinByTaskExecution().GetCountSummary(document, false);

                // CAA [2010/07/09]
                // Excluye los registros buenos...  (se ocultan en el reporte)
                bool hide = false;
                try{
                    if (GetConfigOption("COUNTHIDE").Equals("T"))
                    {
                        //listCompleted = listCompleted.Where(f=> f.Difference!=0 || !string.IsNullOrEmpty(f.Comment)).ToList();
                        hide = true;
                    }
                }
                catch {}

                //Para que el doc no salga en blanco
                if (listCompleted == null || listCompleted.Count == 0)
                    detailList.Add(new ReportDetailFormat());


                foreach (CountTaskBalance record in listCompleted)
                {
                    detail = new ReportDetailFormat();
                    detail.ProductCode = record.Product.ProductCode;
                    detail.ProductDescription = record.Product.Name;
                    detail.StockBin = record.Bin.BinCode;
                    detail.QtyOrder = record.Difference; //DIFF
                    detail.QtyPending = record.QtyExpected; //Expected
                    detail.ProductCost = record.Product.ProductCost;
                    detail.ExtendedCost = record.Product.ProductCost * (detail.QtyOrder);
                    detail.Date1 = DateTime.Today.ToString();
                    detail.CreatedBy = document.CreatedBy;
                    detail.DocNumber = document.DocNumber;
                    detail.Notes = record.Comment;

                    detail.BarcodeLabel = record.Label != null ? "Barcode: " + record.Label.LabelCode : "";
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = record.CaseType;

                    // Se ocultará en el reporte
                    if (hide && (record.Difference==0 && string.IsNullOrEmpty(record.Comment)))
                        detail.Custom1 = "T";

                    detailList.Add(detail);
                }

                header.ReportDetails = detailList.OrderBy(f => f.StockBin).ToList();

            }
            else if (document.DocStatus.StatusID == DocStatus.Posted)
            {
                //Si la tarea esta posteada muestra los ajustes de inventario.
                DocumentLine patternLine = new DocumentLine { 
                    Document = new Document { CustPONumber = document.DocNumber, Company = document.Company }
                };
                
                IList<DocumentLine> lines = Factory.DaoDocumentLine().Select(patternLine);

                // CAA [2010/07/09] Se incluyen los labels de el bin NoCount.
                IList<Label> labelsNoCount = Factory.DaoLabel().Select(new Label { Bin = new Bin { BinCode = DefaultBin.NOCOUNT }, Notes = document.DocNumber });

                //para que el doc no salga en blanco
                if ((lines == null || lines.Count == 0) && (labelsNoCount == null || labelsNoCount.Count == 0))
                    detailList.Add(new ReportDetailFormat());


                int sing = 0;
                foreach (DocumentLine record in lines)
                {
                    sing = record.IsDebit == true ? -1 : 1;

                    detail = new ReportDetailFormat();
                    detail.ProductCode = record.Product.ProductCode;
                    detail.ProductDescription = record.Product.Name;
                    detail.StockBin = record.BinAffected;
                    detail.QtyOrder = sing * record.Quantity; //DIFF
                    detail.QtyPending = record.QtyAllocated;
                    detail.ProductCost = record.Product.ProductCost;
                    detail.ExtendedCost = record.Product.ProductCost * record.Quantity * sing;
                    detail.Date1 = record.Date1 != null ? record.Date1.Value.ToString() : "";
                    detail.DocNumber = record.Document.DocNumber + ", " + record.Document.Comment;

                    detail.BarcodeLabel = "";
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = 0;

                    detailList.Add(detail);
                }

                // NoCount Labels
                foreach (Label record in labelsNoCount)
                {
                    //sing = record.IsDebit == true ? -1 : 1;

                    detail = new ReportDetailFormat();
                    detail.ProductCode = record.Product.ProductCode;
                    detail.ProductDescription = record.Product.Name;
                    detail.StockBin = record.Bin.BinCode;
                    detail.QtyOrder = 0-record.CurrQty;  //DIFF
                    detail.QtyPending = record.CurrQty ; 
                    detail.ProductCost = record.Product.ProductCost;
                    detail.ExtendedCost= record.Product.ProductCost * record.CurrQty * -1;
                    detail.Date1 = record.ModDate != null ? record.ModDate.Value.ToString() : "";
                    detail.DocNumber = document.DocNumber;

                    detail.BarcodeLabel = "Barcode: " + record.LabelCode;
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = 0;

                    detailList.Add(detail);
                }

                header.ReportDetails = detailList.OrderBy(f => f.StockBin).ToList();
            }



            return header;

        }
コード例 #5
0
        private IList<ReportDetailFormat> EvaluateLine(DocumentLine dLine, Document document, IList<DocumentBalance> docBalance,
            short binDirection, short level)
        {

            IList<ReportDetailFormat> returnList = new List<ReportDetailFormat>();
            ReportDetailFormat detail = new ReportDetailFormat();

            if (level > 2)
                return null;

            if (GetCompanyOption(document.Company, "SHOWBO").Equals("F") && dLine.Quantity - dLine.QtyBackOrder - dLine.QtyCancel <= 0)
                return returnList;
            

            //El  qty pending debe salir del balance. que se obtuvo arriba.
            if (docBalance != null && docBalance.Count > 0)
            {
                try { detail.QtyPending = docBalance.Where(f => f.DocumentLine.LineNumber == dLine.LineNumber).First().QtyPending; }
                catch { detail.QtyPending = detail.QtyOrder; }
            }

            if (document.DocType.DocClass.DocClassID == SDocClass.Shipping && GetCompanyOption(document.Company, "SHOWBO").Equals("F") && detail.QtyPending <= 0)
                return returnList;



            //Map Data
            detail.ProductCode = dLine.Product.ProductCode;

            if (string.IsNullOrEmpty(dLine.LineDescription))
                detail.ProductDescription = dLine.Product.Name;
            else
                detail.ProductDescription = dLine.LineDescription;
            
            detail.AlternProduct = "";
            try
            {
                if (dLine.Product.AlternProducts != null && dLine.Product.AlternProducts[0] != null)
                    detail.AlternProduct = dLine.Product.AlternProducts[0].AlternProduct.ProductCode;
            }
            catch {  }

            detail.Unit = dLine.Unit.Name;
            detail.Notes = dLine.Note;
            detail.AuxSequence = dLine.Sequence;
            detail.CreatedBy = dLine.CreatedBy; 
           

            //CUSTOM
            detail.Custom1 = dLine.Product.Manufacturer;
            detail.Custom2 = dLine.Product.Reference;


            //Definir si es un subdetail
            //detail.IsSubDetail = (dLine.LinkDocLineNumber > 0) ? true : false;
            detail.IsSubDetail = (dLine.Note == "1") ? true : false;

            if (detail.IsSubDetail == true)
                detail.CustNumber1 = dLine.LinkDocLineNumber;
            else
                detail.CustNumber1 = dLine.LineNumber;


            IList<ProductAccountRelation> acctItem = null;

 
            try { detail.AssignedBins = GetAssignedBins(dLine.Product, dLine.Location, binDirection); }
            catch { }

            if (document.DocType.UseStock == true)
            {
                try
                {

                    object[] objBins;

                    if (document.DocType.DocClass.DocClassID == SDocClass.Shipping)
                        objBins = GetSuggestedBins(dLine.Product, dLine.Location, document.PickMethod, BinType.Out_Only); //binDirection

                    else if (document.DocType.DocTypeID == SDocType.ReplenishPackTask)
                    {
                        objBins = GetSuggestedBins(dLine.Product, dLine.Location, document.PickMethod, BinType.Out_Only); //binDirection

                        
                        string[] xBins = objBins[0].ToString().Split("\n".ToCharArray());                        
                        string binResult = "";

                        for (int i = 0; i < xBins.Length; i++)
                            if (!xBins[i].Contains(dLine.Note.Trim()))
                                binResult += xBins[i] + "\n";

                        objBins[0] = binResult;
                        //objBins[2] = objBins[2].ToString().Replace(dLine.Note, "").ToString();
                    }
                    else
                        objBins = GetSuggestedBins(dLine.Product, dLine.Location, document.PickMethod, BinType.In_Out);

                    detail.OutBin = objBins[2].ToString();

                    detail.Rank = objBins[1] != null ? (Int32)objBins[1] : WmsSetupValues.MaxBinRank; //Rank del OutBin  

                    detail.SuggestedBins = objBins[0].ToString();

                    detail.OldestBin = objBins[3].ToString();

                }
                catch { }
            }


            //detail.QtyPending = dLine.QtyPending;
            detail.StockBin = dLine.Location.Name;
            detail.Weight = dLine.Product.Weight * dLine.Quantity;
            detail.Pieces = dLine.Product.UnitsPerPack > 0 ? dLine.Product.UnitsPerPack : 1;
            //detail.Cases = dLine.Quantity;


            //Si es un assembly order solo muestra cantidad para las lineas con Notes = "2" 
            //que significan que son items a piquear., del resto no.
            //if (document.DocType.DocTypeID == SDocType.KitAssemblyTask)
                //detail.QtyOrder = (dLine.Note != null && dLine.Note == "1") ? dLine.Quantity : 0;
            //else
                detail.QtyOrder = dLine.Quantity - dLine.QtyCancel;
                detail.QtyBO = dLine.QtyBackOrder;


            //Customer Item Number
            if (document.Customer.AccountCode != WmsSetupValues.DEFAULT)
            {
                acctItem = dLine.Product.ProductAccounts.Where(f => f.Account.AccountID == document.Customer.AccountID).ToList();
                if (acctItem != null && acctItem.Count() > 0)
                    detail.AccountItemNumber = acctItem[0].ItemNumber;
            }


            //Vendor Item Number
            if (document.Vendor.AccountCode != WmsSetupValues.DEFAULT)
            {
                acctItem = dLine.Product.ProductAccounts.Where(f => f.Account.AccountID == document.Vendor.AccountID).ToList();
                if (acctItem != null && acctItem.Count() > 0)
                    detail.AccountItemNumber = acctItem[0].ItemNumber;
            }

            if (detail.AccountItemNumber == null)
                detail.AccountItemNumber = "";


            //Aasignacion del Detalle Principal.
            returnList.Add(detail);


            ///--- FORMULACION A NIVEL DE DOCUMENTO
            ////Evalua si el producto tiene formula para meter los subitems y ademas si se pinden mostrar los subitems
            //if (dLine.Product.ProductFormula != null && dLine.Product.ProductFormula.Count > 0
            //    && GetCompanyOption(document.Company, "SHOWCOMP").Equals("T") && level == 1  
            //    && document.DocType.DocClass.DocClassID == SDocClass.Shipping )
            //{
            //    IList<ReportDetailFormat> subDetails = null;
            //    DocumentLine subLine;
            //    foreach (KitAssemblyFormula formula in dLine.Product.ProductFormula)
            //    {
            //        subLine = new DocumentLine { 
            //            Product = formula.Component, 
            //            Unit = formula.Unit, Note = "",  
            //            Location = dLine.Location, 
            //            Quantity = formula.FormulaQty * dLine.Quantity,
            //            QtyPending = formula.FormulaQty * detail.QtyPending    
            //        };

            //        subDetails = EvaluateLine(subLine, document, null, binDirection, 2);

            //        foreach (ReportDetailFormat sub in subDetails)
            //        {
            //            sub.IsSubDetail = true;
            //            returnList.Add(sub);

            //        }
            //    }
            //}

            return returnList;

        }
コード例 #6
0
        //Obtiene el detalle de label y entrega el dataset
        public static DataSet GetReportDataset(IList<Label> labelList, int quantity)
        {
            try
            {

                ReportDetailFormat detail;
                IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();

                string notes = "";

                int seq = 1;
                foreach (Label label in labelList)
                {
                    detail = new ReportDetailFormat();

                    if (label.Product != null)
                    {
                        detail.ProductCode = label.Product.ProductCode;
                        detail.ProductDescription = label.Product.Name;
                    }

                    notes = (label.Notes != null) ? label.Notes : "";

                    if (label.IsLogistic == true)
                    {
                        try { detail.Unit = notes.Split(',')[0].Trim().Replace("Default", ""); }
                        catch { }
                        detail.QtyOrder = label.StartQty; //Aqui guardan las logisitcas las hijas que contienen unas vez se imprimen
                    }
                    else
                    {
                        detail.Unit = label.Unit != null ? label.Unit.Name : "Default";
                        detail.QtyOrder = label.CurrQty;
                    }

                    //detail.BarcodeProduct = label.Product.ProductCode;
                    detail.BarcodeLabel = (label.Barcode != null) ? label.Barcode : "";
                    detail.Lote = (label.LotCode != null) ? label.LotCode : "";
                    detail.Date1 = (label.ExpirationDate != null) ? label.ExpirationDate.Value.ToShortDateString() : "";
                    detail.Printed = DateTime.Today.ToString("MM/dd/yyyy hh:mm:ss");
                    detail.Serial = (label.SerialNumber != null) ? label.SerialNumber : "";
                    detail.Notes = notes;
                    detail.PrintLot = (label.PrintingLot != null) ? label.PrintingLot : "";
                    detail.UserName = (label.CreatedBy != null) ? label.Barcode : "";
                    detail.LogisticNote = ""; // (label.IsLogistic == true) ? "** LOGISTIC **" : "";


                    //Si el Label es de tipo Custom Label, Ejecuta un proceso adicional.
                    //JM 10 de Junio de 2009
                    if (label.LabelType.DocTypeID == LabelType.CustomerLabel)
                    {
                        //For Packages
                        detail.DocNumber = (label.ShippingDocument != null) ? label.ShippingDocument.DocNumber : "";

                        //Sequence
                        try { detail.PrintLot = seq.ToString() + " / " + labelList.Count(); }
                        catch { }

                        //Weight
                        try { detail.Weight = label.DocumentPackages[0].Weight; }
                        catch { }

                        //Dimemsion
                        try { detail.Dimension = label.DocumentPackages[0].Dimension; }
                        catch { }

                        try { detail.Pieces = label.DocumentPackages[0].Pieces; }
                        catch { }



                        //Shipping Address
                        try
                        {
                            DocumentAddress shipAddr = (new DaoFactory()).DaoDocumentAddress().Select(
                                new DocumentAddress { Document = label.ShippingDocument, AddressType = AddressType.Shipping })
                            .Where(f => f.DocumentLine == null).First();

                            detail.ContactPerson = shipAddr.Name; //shipAddr.ContactPerson;

                            //detail.ShipAddress = shipAddr.Name + "\n";
                            detail.ShipAddress = shipAddr.AddressLine1 + " " + shipAddr.AddressLine2 + "\n";
                            detail.ShipAddress += shipAddr.City + ", " + shipAddr.State + " " + shipAddr.ZipCode + ", ";
                            detail.ShipAddress += shipAddr.Country + "\n";
                            detail.ShipAddress += shipAddr.ContactPerson;

                        }
                        catch { }
                    }

                    seq++;
                    detailList.Add(detail);

                }

                //Add Header to DataSet
                XmlSerializer xmlSerializer;
                StringWriter writer = new StringWriter();

                DataSet dd = new DataSet("Details");
                xmlSerializer = new XmlSerializer(detailList.ToArray().GetType());  //  detailList.GetType()
                xmlSerializer.Serialize(writer, detailList.ToArray());
                StringReader reader = new StringReader(writer.ToString());
                dd.ReadXml(reader);
                dd.Tables[0].TableName = "Details";
                return dd;
            }

            catch { return null; }
        }