try { #region Try to find the Order info in planned orders. dcReplication dc = new dcReplication(String.Format( "Data Source={0};Initial Catalog={1};User ID={2};Password={3}", replicationServer, replicationDatabase, replicationUsername, replicationPassword)); // Find the Bill To and Ship To Customer Numbers in the //Sales Order Master table. var q1 = (from a in dc.SalesOrderMasterTable where a.SalesOrderNumber == orderNumber select new { a.BillToCustomerNumber, a.ShipToCustomerNumber }).ToList(); foreach (var r in q1) { shipToCustomerNumber = r.ShipToCustomerNumber; billToCustomerNumber = r.BillToCustomerNumber; } if (q1.Count > 0) { whereFound = "Planned"; return orderNumber; } #endregion else { try #region Try to find Order in packed orders. { var q2 = (from a in dc.InvoiceHistoryTable where a.OrderNumber == orderNumber select new { a.BillToCustomerNumber , a.ShipToCustomerNumber }).Distinct() .ToList(); foreach (var r in q2) { shipToCustomerNumber = r.ShipToCustomerNumber; billToCustomerNumber = r.BillToCustomerNumber; } if (q2.Count > 0) { whereFound = "Packed"; return orderNumber; } else { throw new RowNotInTableException(String.Format ("Are you sure you entered the Order Number correctly? Order '{0}' could not be found in Sales Order Master or Invoice History.", orderNumber)); } } #endregion
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)