public TrackingStoreItems TrackCartonsForStoreSummary(string clientNumber, string storeNumber, DateTime fromDate, DateTime toDate, string vendorNumber, string by) { // TrackingStoreItems items = new TrackingStoreItems(); try { TrackingDataset cartons = new TrackingDataset(); DataSet ds = null; if (by.ToLower() == "pickup") { ds = new EnterpriseRGateway().GetCartonsForStoreByPickupDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber); } else { ds = new EnterpriseRGateway().GetCartonsForStoreByDeliveryDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber); } if (ds.Tables["CartonDetailForStoreTable"] != null && ds.Tables["CartonDetailForStoreTable"].Rows.Count > 0) { cartons.Merge(ds, true, MissingSchemaAction.Ignore); } //Build a summary by TL; start with a dataset of unique TrackingDataset tls = new TrackingDataset(); tls.Merge(cartons.CartonDetailForStoreTable.DefaultView.ToTable(true, new string[] { "TL" })); foreach (TrackingDataset.CartonDetailForStoreTableRow tl in tls.CartonDetailForStoreTable.Rows) { //Get one of the cartons from this TL group TrackingDataset.CartonDetailForStoreTableRow tlCarton0 = (TrackingDataset.CartonDetailForStoreTableRow)(cartons.CartonDetailForStoreTable.Select("TL='" + tl.TL + "'", "TL ASC"))[0]; tl.S = tlCarton0.S; tl.CartonCount = cartons.CartonDetailForStoreTable.Select("TL='" + tl.TL + "'").Length; tl.Wt = int.Parse(cartons.CartonDetailForStoreTable.Compute("Sum(Wt)", "TL='" + tl.TL + "'").ToString()); tl.CBOL = tlCarton0.IsCBOLNull() ? "" : tlCarton0.CBOL; object minDate = cartons.CartonDetailForStoreTable.Compute("Min(ScD)", "TL='" + tl.TL + "' AND (IsNull(ScD,#01/01/1900#) <> #01/01/1900#)"); if (minDate != System.DBNull.Value) { tl.ScD = minDate.ToString(); object minTime = cartons.CartonDetailForStoreTable.Compute("Min(ScTm)", "TL='" + tl.TL + "' AND ScD='" + minDate + "'"); tl.ScTm = minTime.ToString(); } tl.ActSDD = !tlCarton0.IsActSDDNull() ? tlCarton0.ActSDD : "01/01/0001"; tl.OFD1 = !tlCarton0.IsOFD1Null() ? tlCarton0.OFD1 : DateTime.MinValue; tl.Ag = !tlCarton0.IsAgNull() ? tlCarton0.Ag : ""; tl.AgNm = tlCarton0.AgNm; tl.AcceptChanges(); TrackingStoreItem item = new TrackingStoreItem(tl); items.Add(item); } } catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); } return(items); }
public TrackingStoreItems TrackCartonsForStoreDetail(string clientNumber, string storeNumber, DateTime fromDate, DateTime toDate, string vendorNumber, string by, string tlNumber) { // TrackingStoreItems items = new TrackingStoreItems(); try { TrackingDataset cartons = new TrackingDataset(); DataSet ds = null; if (by.ToLower() == "pickup") { ds = new EnterpriseRGateway().GetCartonsForStoreByPickupDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber); } else { ds = new EnterpriseRGateway().GetCartonsForStoreByDeliveryDate2(clientNumber, storeNumber, fromDate, toDate, vendorNumber); } if (ds.Tables["CartonDetailForStoreTable"] != null && ds.Tables["CartonDetailForStoreTable"].Rows.Count > 0) { if (tlNumber != null) { cartons.Merge(ds.Tables["CartonDetailForStoreTable"].Select("TL='" + tlNumber + "'"), true, MissingSchemaAction.Ignore); } else { cartons.Merge(ds, true, MissingSchemaAction.Ignore); } } foreach (TrackingDataset.CartonDetailForStoreTableRow carton in cartons.CartonDetailForStoreTable.Rows) { TrackingStoreItem item = new TrackingStoreItem(carton); items.Add(item); } } catch (Exception ex) { throw new FaultException <TrackingFault>(new TrackingFault(ex.Message), "Service Error"); } return(items); }