public override global::System.Data.DataSet Clone() { ReportsDataSet cln = ((ReportsDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { ReportsDataSet ds = new ReportsDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public void ExcuteViewDocumentCommand(object obj) { try { AttachmentDTO attachment = null; switch (SelectedTabItem.Name) { case "TabAgreement": attachment = SelectedRequiredDocument.AgreementAttachment; break; case "TabPassport": attachment = SelectedRequiredDocument.PassportAttachment; break; case "TabIdCard": attachment = SelectedRequiredDocument.IdCardAttachment; break; case "TabContactIdCard": attachment = SelectedRequiredDocument.ContactIdCardAttachment; break; case "TabFingerPrint": attachment = SelectedRequiredDocument.FingerPrintAttachment; break; case "TabMedical": attachment = SelectedRequiredDocument.MedicalAttachment; break; case "TabPreDeparture": attachment = SelectedRequiredDocument.PreDepartureAttachment; break; case "TabGradeEight": attachment = SelectedRequiredDocument.GradeEightAttachment; break; case "TabCoc": attachment = SelectedRequiredDocument.CocAttachment; break; case "TabInsurance": attachment = SelectedRequiredDocument.InsuranceAttachment; break; } if (attachment != null && attachment.AttachedFile != null) { if (SelectedTabItem.Name == "TabAgreement") { var pdfFilePath = Environment.SpecialFolder.MyDocuments + attachment.Id + ".pdf"; System.IO.File.WriteAllBytes(pdfFilePath, attachment.AttachedFile); System.Diagnostics.Process.Start(pdfFilePath); } else { var myDataSet = new ReportsDataSet(); myDataSet.LetterHeads.Rows.Add("1", attachment.AttachedFile, null, null, "", ""); var myReport = new AttachedDocument(); myReport.SetDataSource(myDataSet); var report = new ReportViewerCommon(myReport); report.ShowDialog(); } } } catch { } }
/// <summary> /// Loads the data specified by the template into a dataset /// </summary> /// <param name="template">The template to base the queries on</param> /// <returns>The dataset with the data laoded into it.</returns> private ReportsDataSet LoadData(InventoryReportTemplate template) { ReportsDataSet ds = new ReportsDataSet(); using (CCSEntities db = new CCSEntities()) { List<Container> regularContainers = new List<Container>(); List<Container> usdaContainers = new List<Container>(); if (template.USDASelection == ReportTemplate.SelectionType.ALL) { usdaContainers = db.Containers.Where(c => c.isUSDA == true).ToList(); } else if (template.USDASelection == ReportTemplate.SelectionType.SOME) { List<short> usdaCategories = new List<short>(); foreach (var i in template.FoodCategories) usdaCategories.Add(short.Parse(i)); usdaContainers = (from c in db.Containers where c.isUSDA == true && usdaCategories.Contains((short)c.USDAID) select c).ToList(); } if (template.CategoriesSelection == ReportTemplate.SelectionType.ALL) { regularContainers = db.Containers.Where( c => c.isUSDA == false).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.REGULAR) { regularContainers = (from c in db.Containers where c.isUSDA == false && c.FoodCategory.Perishable == false && c.FoodCategory.NonFood == false select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.PERISHABLE) { regularContainers = (from c in db.Containers where c.isUSDA == false && c.FoodCategory.Perishable == true && c.FoodCategory.NonFood == false select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.NONFOOD) { regularContainers = (from c in db.Containers where c.isUSDA == false && c.FoodCategory.Perishable == false && c.FoodCategory.NonFood == true select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedCategories = new List<short>(); foreach (var i in template.FoodCategories) selectedCategories.Add(short.Parse(i)); regularContainers = (from c in db.Containers where c.isUSDA == false && selectedCategories.Contains((short)c.FoodCategoryID) select c).ToList(); } regularContainers.AddRange(usdaContainers); List<short> selectedLocations = new List<short>(); if (template.LocationsSelection == ReportTemplate.SelectionType.SOME) { foreach (var i in template.Locations) selectedLocations.Add(short.Parse(i)); regularContainers = (from c in regularContainers where selectedLocations.Contains(c.Location.LocationID) select c).ToList(); } List<int> foundLocations = new List<int>(); foreach (var c in regularContainers) { if(c.FoodCategory != null || c.USDACategory != null) ds.Inventory.AddInventoryRow(c.Location.RoomName, c.USDACategory != null ? c.USDACategory.Description : c.FoodCategory.CategoryType, c.BinNumber.ToString(), c.Cases == null ? 0 : (double)c.Cases, (double)c.Weight); if (!foundLocations.Contains(c.LocationID)) foundLocations.Add(c.LocationID); } if (template.LocationsSelection != ReportTemplate.SelectionType.SOME) selectedLocations = db.Locations.Select(x => x.LocationID).ToList(); foreach(var l in selectedLocations.Where( x => !(foundLocations.Contains(x)))) { var location = db.Locations.FirstOrDefault( x => x.LocationID == l); ds.Inventory.AddInventoryRow(location.RoomName, "EMPTY", "", 0, 0); } } return ds; }
/// <summary> /// Loads the data into a dataset depending on the options set by the user. /// </summary> /// <param name="startdate">The date to start from</param> /// <param name="enddate">The date to end grabbing transactions</param> /// <param name="template">The template to load options for the query</param> /// <returns>The dataset with the data loaded into it</returns> private ReportsDataSet LoadData(DateTime startdate, DateTime enddate, InOutReportTemplate template) { ReportsDataSet ds = new ReportsDataSet(); using (CCSEntities db = new CCSEntities()) { DateTime dt = enddate.AddDays(1); List<FoodCategory> foodCategoriesData = null; List<USDACategory> usdaCategoriesData = null; foodCategoriesData = GenerateDatasetHelper.GetFoodCategoriesBySelection(template, db); if (template.USDASelection == ReportTemplate.SelectionType.ALL) { usdaCategoriesData = db.USDACategories.OrderBy(f => f.Description).ToList(); } else if (template.USDASelection == ReportTemplate.SelectionType.SOME) { List<short> selectedUSDA = new List<short>(); foreach (var i in template.USDACategories) selectedUSDA.Add(short.Parse(i)); usdaCategoriesData = (from u in db.USDACategories where selectedUSDA.Contains(u.USDAID) orderby u.Description select u).ToList(); } if (template.CategoriesSelection != ReportTemplate.SelectionType.NONE) { foreach (var f in foodCategoriesData) { double weightIn = (from w in f.FoodIns where (w.TimeStamp >= startdate.Date && w.TimeStamp < dt.Date) select (double)w.Weight).Sum(); double weightOut = (from w in f.FoodOuts where (w.TimeStamp >= startdate.Date && w.TimeStamp < dt.Date) select w.Weight).Sum(); double countIn = (from w in f.FoodIns where (w.TimeStamp >= startdate.Date && w.TimeStamp < dt.Date) && w.Count != null select (double)w.Count).Sum(); double countOut = (from w in f.FoodOuts where (w.TimeStamp >= startdate.Date && w.TimeStamp < dt.Date) && w.Count != null select (double)w.Count).Sum(); double currentBalanceWeight = 0; double currentBalanceCount = 0; if (template.ShowCurrentBalance) { currentBalanceWeight = (from c in f.Containers select (double)c.Weight).Sum(); currentBalanceCount = (from c in f.Containers where c.Cases != null select (double)c.Cases).Sum(); } ds.InOut.AddInOutRow(f.CategoryType, false, currentBalanceWeight, currentBalanceCount, weightIn, weightOut, countIn, countOut); } } if (template.USDASelection != ReportTemplate.SelectionType.NONE) { foreach (var f in usdaCategoriesData) { double weightIn = (from w in f.FoodIns where w.TimeStamp < dt.Date && w.TimeStamp >= startdate select (double)w.Weight).Sum(); double weightOut = (from w in f.FoodOuts where w.TimeStamp < dt.Date && w.TimeStamp >= startdate select w.Weight).Sum(); double countIn = (from w in f.FoodIns where w.TimeStamp < dt.Date && w.TimeStamp >= startdate && w.Count != null select (double)w.Count).Sum(); double countOut = (from w in f.FoodOuts where w.TimeStamp < dt.Date && w.TimeStamp >= startdate && w.Count != null select (double)w.Count).Sum(); double currentBalanceWeight = 0; double currentBalanceCount = 0; if (template.ShowCurrentBalance) { currentBalanceWeight = (from c in f.Containers select (double)c.Weight).Sum(); currentBalanceCount = (from c in f.Containers where c.Cases != null select (double)c.Cases).Sum(); } ds.InOut.AddInOutRow("(" + f.USDANumber + ")" + f.Description, true, currentBalanceWeight, currentBalanceCount, weightIn, weightOut, countIn, countOut); } } } return ds; }
/// <summary> /// Loads the data into a dataset depending on the options set by the user. /// </summary> /// <param name="startdate">The date to start from</param> /// <param name="enddate">The dataset with the data loaded into it</param> /// <param name="template">The template to load options for the query</param> /// <returns>The dataset with the data loaded into it</returns> private ReportsDataSet LoadData(DateTime startdate, DateTime enddate, IncomingReportTemplate template) { ReportsDataSet ds = new ReportsDataSet(); using (CCSEntities db = new CCSEntities()) { DateTime dt = enddate.AddDays(1); List<FoodIn> data = db.FoodIns.Where(f => (f.TimeStamp >= startdate.Date && f.TimeStamp < dt.Date)).ToList(); if (template.FoodSourceTypesSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedTypes = new List<short>(); foreach (var i in template.FoodSourceTypes) selectedTypes.Add(short.Parse(i)); data = (from c in data where selectedTypes.Contains((short)c.FoodSource.FoodSourceTypeID) select c).ToList(); } if (template.FoodSourcesSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedSources = new List<short>(); foreach (var i in template.FoodSources) selectedSources.Add(short.Parse(i)); data = (from c in data where selectedSources.Contains((short)c.FoodSourceID) select c).ToList(); } List<FoodIn> foodInRegularData = new List<FoodIn>(); if(template.CategoriesSelection != ReportTemplate.SelectionType.NONE) foodInRegularData = data.Where(f => f.FoodCategory != null && f.USDACategory == null).ToList(); List<FoodIn> foodInUSDAData = data.Where(f => f.USDACategory != null && f.FoodCategory == null).ToList(); if (template.CategoriesSelection == ReportTemplate.SelectionType.REGULAR) { foodInRegularData = (from c in foodInRegularData where c.FoodCategory.Perishable == false && c.FoodCategory.NonFood == false select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.PERISHABLE) { foodInRegularData = (from c in foodInRegularData where c.FoodCategory.Perishable == true && c.FoodCategory.NonFood == false select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.NONFOOD) { foodInRegularData = (from c in foodInRegularData where c.FoodCategory.Perishable == false && c.FoodCategory.NonFood == true select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedCategories = new List<short>(); foreach (var i in template.FoodCategories) selectedCategories.Add(short.Parse(i)); foodInRegularData = (from c in foodInRegularData where selectedCategories.Contains((short)c.FoodCategoryID) select c).ToList(); } if (template.USDASelection == ReportTemplate.SelectionType.SOME) { List<short> selectedUSDA = new List<short>(); foreach (var i in template.USDACategories) selectedUSDA.Add(short.Parse(i)); foodInUSDAData = (from u in foodInUSDAData where selectedUSDA.Contains((short)u.USDAID) select u).ToList(); } if (template.USDASelection != ReportTemplate.SelectionType.NONE) { foodInRegularData.InsertRange(0, foodInUSDAData); } data = foodInRegularData; // Static variables of what they want to come first. @Author Jake Abel const string taxable = "In-Kind (Taxable)"; const string nonTaxable = "In-Kind (Non-Tax)"; const string noAgency = "No-Agency"; /** Sort the foodIn similar to the food out ADDED by @Author Jake Abel */ // ds.Incoming.AddIncomingRow(categoryType, timeStamp, count, weight, foodSource, address, foodSourceType1); // Sort based on in-Kind (taxable and non-tax) and then data.Sort(delegate (FoodIn dis, FoodIn otr) { // dis.FoodSource.FoodSourceType.FoodSourceType1 // // Put the taxable first, and then the non taxable, and then whatever if (dis.FoodSource.FoodSourceType.FoodSourceType1.Equals(taxable) || dis.FoodSource.FoodSourceType.FoodSourceType1.Equals(nonTaxable) || otr.FoodSource.FoodSourceType.FoodSourceType1.Equals(taxable) || otr.FoodSource.FoodSourceType.FoodSourceType1.Equals(nonTaxable)) { if (dis.FoodSource.FoodSourceType.FoodSourceType1.Equals(taxable) && !otr.FoodSource.FoodSourceType.FoodSourceType1.Equals(taxable)) { return -1; } if (otr.FoodSource.FoodSourceType.FoodSourceType1.Equals(taxable) && !dis.FoodSource.FoodSourceType.FoodSourceType1.Equals(taxable)) { return 1; } if (dis.FoodSource.FoodSourceType.FoodSourceType1.Equals(nonTaxable) && !otr.FoodSource.FoodSourceType.FoodSourceType1.Equals(nonTaxable)) { return -1; } if (otr.FoodSource.FoodSourceType.FoodSourceType1.Equals(nonTaxable) && !dis.FoodSource.FoodSourceType.FoodSourceType1.Equals(nonTaxable)) { return 1; } } if (dis.FoodSource.FoodSourceType.FoodSourceType1.Contains(taxable) && !otr.FoodSource.FoodSourceType.FoodSourceType1.Contains(taxable)) { return 1; } if (dis.FoodSource.FoodSourceType.FoodSourceType1.Contains(nonTaxable) && !otr.FoodSource.FoodSourceType.FoodSourceType1.Contains(nonTaxable)) { return 1; } return dis.FoodSource.Source.CompareTo(otr.FoodSource.Source); // return 0; }); //ORIGINAL VERSION, @Author Nittaya P. // foreach (var i in data) // { // if (i.FoodCategory != null || i.USDACategory != null) // { // string address = string.Format("{0} {1} {2}, {3} {4}", i.FoodSource.Address.StreetAddress1 ?? "", // i.FoodSource.Address.StreetAddress2 ?? "", i.FoodSource.Address.City.CityName ?? "", // i.FoodSource.Address.State == null ? "" : i.FoodSource.Address.State.StateShortName, // i.FoodSource.Address.Zipcode.ZipCode1 ?? ""); // ds.Incoming.AddIncomingRow(i.FoodCategory == null ? i.USDACategory.Description : i.FoodCategory.CategoryType, i.TimeStamp, i.Count == null ? 0 : (double)i.Count, i.Weight == null ? 0 : (double)i.Weight, i.FoodSource.Source, address, i.FoodSource.FoodSourceType.FoodSourceType1); // } // } /** Expanded version for simplicities sake @Author Jake Abel */ foreach (var i in data) { if (i.FoodCategory != null || i.USDACategory != null) { string address = string.Format("{0} {1} {2}, {3} {4}", i.FoodSource.Address.StreetAddress1 ?? "", i.FoodSource.Address.StreetAddress2 ?? "", i.FoodSource.Address.City.CityName ?? "", i.FoodSource.Address.State == null ? "" : i.FoodSource.Address.State.StateShortName, i.FoodSource.Address.Zipcode.ZipCode1 ?? ""); string categoryType; if (i.FoodCategory == null) { categoryType = i.USDACategory.Description; } else { categoryType = i.FoodCategory.CategoryType; } DateTime timeStamp = i.TimeStamp; double count; if (i.Count == null) { count = 0; } else { count = (double)i.Count; } double weight; if (i.Weight == null) { weight = 0; } else { weight = (double) i.Weight; } string foodSource = i.FoodSource.Source; // address string foodSourceType1 = i.FoodSource.FoodSourceType.FoodSourceType1; // Original version @Author Nittaya //ds.Incoming.AddIncomingRow(i.FoodCategory == null ? i.USDACategory.Description : i.FoodCategory.CategoryType, i.TimeStamp, // i.Count == null ? 0 : (double)i.Count, i.Weight == null ? 0 : (double)i.Weight, i.FoodSource.Source, address, // i.FoodSource.FoodSourceType.FoodSourceType1 // Condensed version @Author Jake Abel ds.Incoming.AddIncomingRow(categoryType, timeStamp, count, weight, foodSource, address, foodSourceType1); } } } return ds; }
/// <summary> /// Loads the data into a dataset depending on the options set by the user. /// </summary> /// <param name="startdate">The date to start from</param> /// <param name="enddate">The dataset with the data loaded into it</param> /// <param name="template">The template to load options for the query</param> /// <returns>The dataset with the data loaded into it</returns> private ReportsDataSet LoadData(DateTime startdate, DateTime enddate, OutgoingReportTemplate template) { ReportsDataSet ds = new ReportsDataSet(); Console.WriteLine(template.ToString()); using (CCSEntities db = new CCSEntities()) { DateTime dt = enddate.AddDays(1); List<FoodOut> data = db.FoodOuts.Where(f => (f.TimeStamp >= startdate.Date && f.TimeStamp < dt.Date)).ToList(); if (template.FoodSourceTypesSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedTypes = new List<short>(); foreach (var i in template.FoodSourceTypes) selectedTypes.Add(short.Parse(i)); data = (from c in data where selectedTypes.Contains((short)c.FoodSourceTypeID) select c).ToList(); } if (template.DistributionSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedDistribution = new List<short>(); foreach (var i in template.DistributionTypes) selectedDistribution.Add(short.Parse(i)); data = (from c in data where selectedDistribution.Contains((short)c.DistributionTypeID) select c).ToList(); } if (template.AgenciesSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedAgencies = new List<short>(); foreach (var i in template.Agencies) selectedAgencies.Add(short.Parse(i)); data = (from c in data where selectedAgencies.Contains((short)c.AgencyID) select c).ToList(); } List<FoodOut> foodInRegularData = new List<FoodOut>(); List<FoodOut> foodInUSDAData = new List<FoodOut>(); if (template.CategoriesSelection != ReportTemplate.SelectionType.NONE) foodInRegularData = data.Where(f => f.FoodCategory != null).ToList(); if (template.USDASelection != ReportTemplate.SelectionType.NONE) foodInUSDAData = data.Where(f => f.USDACategory != null).ToList(); if (template.CategoriesSelection == ReportTemplate.SelectionType.REGULAR) { foodInRegularData = (from c in foodInRegularData where c.FoodCategory.Perishable == false && c.FoodCategory.NonFood == false select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.PERISHABLE) { foodInRegularData = (from c in foodInRegularData where c.FoodCategory.Perishable == true && c.FoodCategory.NonFood == false select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.NONFOOD) { foodInRegularData = (from c in foodInRegularData where c.FoodCategory.Perishable == false && c.FoodCategory.NonFood == true select c).ToList(); } else if (template.CategoriesSelection == ReportTemplate.SelectionType.SOME) { List<short> selectedCategories = new List<short>(); foreach (var i in template.FoodCategories) selectedCategories.Add(short.Parse(i)); foodInRegularData = (from c in foodInRegularData where selectedCategories.Contains((short)c.FoodCategoryID) select c).ToList(); } if (template.USDASelection == ReportTemplate.SelectionType.SOME) { List<short> selectedUSDA = new List<short>(); foreach (var i in template.USDACategories) selectedUSDA.Add(short.Parse(i)); foodInUSDAData = (from u in foodInUSDAData where selectedUSDA.Contains((short)u.USDAID) select u).ToList(); } foodInRegularData.InsertRange(0, foodInUSDAData); data = foodInRegularData; /** * @Author Jake Abel * * Sort the results based on FoodSource Type, Distribution type, and then based on Agency. */ // Static variables of what they want to come first. const string taxable = "In-Kind (Taxable)"; const string nonTaxable = "In-Kind (Non-Tax)"; const string noAgency = "No-Agency"; data.Sort(delegate(FoodOut dis, FoodOut otr) { // Put the taxable first, and then the non taxable, and then whatever if (dis.FoodSourceType.FoodSourceType1.Equals(taxable) || dis.FoodSourceType.FoodSourceType1.Equals(nonTaxable) || otr.FoodSourceType.FoodSourceType1.Equals(taxable) || otr.FoodSourceType.FoodSourceType1.Equals(nonTaxable)) { if (dis.FoodSourceType.FoodSourceType1.Equals(taxable) && !otr.FoodSourceType.FoodSourceType1.Equals(taxable)) { return -1; } if (otr.FoodSourceType.FoodSourceType1.Equals(taxable) && !dis.FoodSourceType.FoodSourceType1.Equals(taxable)) { return 1; } if (dis.FoodSourceType.FoodSourceType1.Equals(nonTaxable) && !otr.FoodSourceType.FoodSourceType1.Equals(nonTaxable)) { return -1; } if (otr.FoodSourceType.FoodSourceType1.Equals(nonTaxable) && !dis.FoodSourceType.FoodSourceType1.Equals(nonTaxable)) { return 1; } } if (dis.FoodSourceType.FoodSourceType1.Contains(taxable) && !otr.FoodSourceType.FoodSourceType1.Contains(taxable)) { return 1; } if (dis.FoodSourceType.FoodSourceType1.Contains(nonTaxable) && !otr.FoodSourceType.FoodSourceType1.Contains(nonTaxable)) { return 1; } // Sorting based on distribution type, if they are the same, continue int ret = dis.DistributionType.DistributionType1.CompareTo(otr.DistributionType.DistributionType1); if (ret != 0) { return ret; } // Sort based on agency very last of all if (dis.Agency == null && otr.Agency == null) { return 0; } else if (dis.Agency == null) { return noAgency.CompareTo(otr.Agency.AgencyName); } else if (otr.Agency == null) { return dis.Agency.AgencyName.CompareTo(noAgency); } else { return dis.Agency.AgencyName.CompareTo(otr.Agency.AgencyName); } }); // Original Version @Author Nittaya Phonharath // foreach (var i in data) // { // if(i.FoodCategory != null || i.USDACategory != null) // ds.Outgoing.AddOutgoingRow(i.FoodCategory == null? i.USDACategory.Description: i.FoodCategory.CategoryType, i.BinNumber, i.TimeStamp, (double)(i.Count ?? 0), i.Weight, i.Agency == null ? "No-Agency" : i.Agency.AgencyName, i.DistributionType.DistributionType1, i.FoodSourceType.FoodSourceType1); // } // @Author Jake Abel // Modified version, used for cleanliness and readability foreach (var i in data) { // FoodCategory foodCategory = i.FoodCategory; if (i.FoodCategory != null || i.USDACategory != null) { //ds.Outgoing.AddOutgoingRow(i.FoodCategory == null? i.USDACategory.Description: i.FoodCategory.CategoryType, i.BinNumber, i.TimeStamp, (double)(i.Count ?? 0), //i.Weight, i.Agency == null ? "No-Agency" : i.Agency.AgencyName, i.DistributionType.DistributionType1, i.FoodSourceType.FoodSourceType1); string foodCategory = ""; if (i.FoodCategory == null) { foodCategory = i.USDACategory.Description; } else { foodCategory = i.FoodCategory.CategoryType; } short binNumber = i.BinNumber; DateTime timeStamp = i.TimeStamp; short count; if (i.Count == null) { count = 0; } else { count = (short)i.Count; } double weight = i.Weight; string agencyName = ""; if (i.Agency == null) { agencyName = "No-Agency"; } else { agencyName = i.Agency.AgencyName; } string distributionType = i.DistributionType.DistributionType1; string foodSourceType2 = i.FoodSourceType.FoodSourceType1; ds.Outgoing.AddOutgoingRow(foodCategory, binNumber, timeStamp, count, weight, agencyName, distributionType, foodSourceType2); } } } return ds; }