private SearchStatementModel PrepareInstanceSearchStatement(GridCommand command, ProdLineExInstanceSearchModel searchModel)
        {
            string whereStatement = string.Empty;

            IList<object> param = new List<object>();

            if (searchModel.DateType != null)
            {
                if (searchModel.DateType.Value == 4)
                {
                    if (searchModel.DateIndexDate != null & searchModel.DateIndexToDate != null)
                    {
                        HqlStatementHelper.AddBetweenStatement("DateIndex", searchModel.DateIndexDate.Value.ToString("yyyy-MM-dd"), searchModel.DateIndexToDate.Value.ToString("yyyy-MM-dd"), "p", ref whereStatement, param);
                    }
                    else if (searchModel.DateIndexDate != null & searchModel.DateIndexToDate == null)
                    {
                        HqlStatementHelper.AddGeStatement("DateIndex", searchModel.DateIndexDate.Value.ToString("yyyy-MM-dd"), "p", ref whereStatement, param);
                    }
                    else if (searchModel.DateIndexDate == null & searchModel.DateIndexToDate != null)
                    {
                        HqlStatementHelper.AddLeStatement("DateIndex", searchModel.DateIndexToDate.Value.ToString("yyyy-MM-dd"), "p", ref whereStatement, param);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(searchModel.DateIndex) & !string.IsNullOrEmpty(searchModel.DateIndexTo))
                    {
                        HqlStatementHelper.AddBetweenStatement("DateIndex", searchModel.DateIndex, searchModel.DateIndexTo, "p", ref whereStatement, param);
                    }
                    else if (!string.IsNullOrEmpty(searchModel.DateIndex) & string.IsNullOrEmpty(searchModel.DateIndexTo))
                    {
                        HqlStatementHelper.AddGeStatement("DateIndex", searchModel.DateIndex, "p", ref whereStatement, param);
                    }
                    else if (string.IsNullOrEmpty(searchModel.DateIndex) & !string.IsNullOrEmpty(searchModel.DateIndexTo))
                    {
                        HqlStatementHelper.AddLeStatement("DateIndex", searchModel.DateIndexTo, "p", ref whereStatement, param);
                    }
                }
            }

            HqlStatementHelper.AddEqStatement("ProductLine", searchModel.ProductLine, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("SnapTime", searchModel.SnapTime, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("ShiftType", searchModel.ShiftType, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("ApsPriority", searchModel.ApsPriority, "p", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("DateType", searchModel.DateType, "p", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by p.DateType,p.ProductLine,p.DateIndex,p.Item";
            }

            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectInstanceCountStatement;
            searchStatementModel.SelectStatement = selectInstanceStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
 public ActionResult _AjaxInstanceList(GridCommand command, ProdLineExInstanceSearchModel searchModel)
 {
     SearchStatementModel searchStatementModel = this.PrepareInstanceSearchStatement(command, searchModel);
     var list = GetAjaxPageData<SnapProdLineEx>(searchStatementModel, command);
     var productType = genericMgr.FindAll<ProductType>("from ProductType as i");
     foreach (var listdata in list.Data)
     {
         listdata.ItemDesc = itemMgr.GetCacheItem(listdata.Item).Description;
         listdata.ProductTypeDescription = productType.Where(p => p.Code == listdata.ProductType).FirstOrDefault().Description;
     }
     return PartialView(list);
 }
 public void ExportXLS(ProdLineExInstanceSearchModel searchModel)
 {
     int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(com.Sconit.Entity.SYS.EntityPreference.CodeEnum.MaxRowSizeOnPage));
     GridCommand command = new GridCommand();
     command.Page = 1;
     command.PageSize = value;
     SearchStatementModel searchStatementModel = this.PrepareInstanceSearchStatement(command, searchModel);
     var fileName = string.Format("EXCalendar.xls");
     ExportToXLS<SnapProdLineEx>(fileName, GetAjaxPageData<SnapProdLineEx>(searchStatementModel, command).Data.ToList());
 }
 public ActionResult InstanceList(GridCommand command, ProdLineExInstanceSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     ViewBag.DateType = searchModel.DateType == null ? null : searchModel.DateType.ToString();
     return View();
 }