//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 barcodeURL = App.curCompany.WebURL + "/"+ WmsSetupValues.BarcodeDir + "/"; //int i = 1; 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; detail.Weight = label.Product.Weight * label.StartQty; } notes = (label.Notes != null) ? label.Notes : ""; if (label.Printed == true) { try { detail.Unit = notes.Split(',')[0].Trim(); } catch { } detail.QtyOrder = label.StartQty; //Aqui guardan las logisitcas las hijas que contienen unas vez se imprimen } else { detail.Unit = label.Unit.Name; detail.QtyOrder = label.CurrQty; } //detail.BarcodeProduct = label.Product.ProductCode; detail.BarcodeLabel = 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; 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 { } //Pieces try { detail.Pieces = label.DocumentPackages[0].Pieces; } catch { } //Shipping Address try { DocumentAddress shipAddr = (new WMSServiceClient()).GetDocumentAddress( 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 { } } detailList.Add(detail); seq++; //if (i++ >= quantity) // break; } //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); } }
//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 barcodeURL = App.curCompany.WebURL + "/"+ WmsSetupValues.BarcodeDir + "/"; //int i = 1; 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; detail.Weight = label.Product.Weight * label.StartQty; } notes = (label.Notes != null) ? label.Notes : ""; if (label.Printed == true) { try { detail.Unit = notes.Split(',')[0].Trim(); } catch { } detail.QtyOrder = label.StartQty; //Aqui guardan las logisitcas las hijas que contienen unas vez se imprimen } else { detail.Unit = label.Unit.Name; detail.QtyOrder = label.CurrQty; } //detail.BarcodeProduct = label.Product.ProductCode; detail.BarcodeLabel = 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; 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 { } //Pieces try { detail.Pieces = label.DocumentPackages[0].Pieces; } catch { } //Shipping Address try { DocumentAddress shipAddr = (new WMSServiceClient()).GetDocumentAddress( 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 { } } detailList.Add(detail); seq++; //if (i++ >= quantity) // break; } //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; } }