private void InitDataSource(int startRowIndex, int recordsCount, bool returnTotalCount, string orderByClause) { DateTime now = DateTime.Now; DateTime dateTime1 = now; DateTime dateTime2 = now; bool flag; bool marketFlag = false; string market = string.Empty; if (this.FilterType == "thisweek") { dateTime1 = ManagementHelper.GetStartOfWeek(now.Date); dateTime2 = now; flag = true; } else if (this.FilterType == "thismonth") { dateTime1 = new DateTime(now.Year, now.Month, 1); dateTime2 = now; flag = true; } else if (this.FilterType == "today") { dateTime1 = now.Date; dateTime2 = now; flag = true; } else { if (this.FilterType == "sunstore") { market = this.FilterType; marketFlag = true; } else if (this.FilterType == "amavita") { market = this.FilterType; marketFlag = true; } else if (this.FilterType == "coop") { market = this.FilterType; marketFlag = true; } flag = false; } if (flag) { this.OrderListDataSource.Parameters.SqlMetaWhereClause = string.Format("META.Modified between '{0}' and '{1}'", (object)dateTime1.ToUniversalTime().ToString("s"), (object)dateTime2.ToUniversalTime().ToString("s")); } if (!string.IsNullOrEmpty(this.Status)) { this.OrderListDataSource.Parameters.SqlWhereClause = string.Format("Status = '{0}'", (object)ManagementHelper.MakeSafeSearchFilter(this.Status)); } if (marketFlag && !string.IsNullOrEmpty(market)) { this.OrderListDataSource.Parameters.JoinSourceTable = "[dbo].[OrderForm]"; this.OrderListDataSource.Parameters.JoinSourceTableKey = "[OrderGroupId]"; this.OrderListDataSource.Parameters.JoinSourceTable = "[dbo].[OrderGroup]"; this.OrderListDataSource.Parameters.JoinSourceTableKey = "[OrderGroupId]"; if (!string.IsNullOrEmpty(this.OrderListDataSource.Parameters.SqlWhereClause)) { this.OrderListDataSource.Parameters.SqlWhereClause += string.Format("AND OrderGroup.MarketId = '{0}'", market); } else { this.OrderListDataSource.Parameters.SqlWhereClause = string.Format("OrderGroup.MarketId = '{0}'", market); } } if (string.IsNullOrEmpty(orderByClause)) { orderByClause = string.Format("OrderGroupId DESC"); } OrderSearchOptions orderSearchOptions = new OrderSearchOptions(); this.OrderListDataSource.Options.Namespace = "Mediachase.Commerce.Orders"; this.OrderListDataSource.Options.Classes.Add(this.ClassType); this.MyListView.DataMember = !(this.ClassType == "ShoppingCart") ? (!(this.ClassType == "PaymentPlan") ? OrderDataSource.OrderDataSourceView.PurchaseOrdersViewName : OrderDataSource.OrderDataSourceView.PaymentPlansViewName) : OrderDataSource.OrderDataSourceView.CartsViewName; this.OrderListDataSource.Options.RecordsToRetrieve = recordsCount; this.OrderListDataSource.Options.StartingRecord = startRowIndex; this.OrderListDataSource.Parameters.OrderByClause = orderByClause; }