public ActionResult _AjaxList(GridCommand command, SearchModel searchModel)
        {

            SearchStatementModel searchStatementModel = PrepareSearchStatement(command, searchModel);
            GridModel<PostDO> gridlist = GetAjaxPageData<PostDO>(searchStatementModel, command);
            return PartialView(gridlist);
        }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, SearchModel searchModel)
        {
            string whereStatement = "";

            IList<object> param = new List<object>();
            HqlStatementHelper.AddEqStatement("OrderNo", searchModel.OrderNo, "t", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("ReceiptNo", searchModel.ReceiptNo, "t", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Status", searchModel.Status, "t", ref whereStatement, param);

            if (searchModel.StartDate != null & searchModel.EndDate != null)
            {
                HqlStatementHelper.AddBetweenStatement("CreateDate", searchModel.StartDate, searchModel.EndDate, "t", ref whereStatement, param);
            }
            else if (searchModel.StartDate != null & searchModel.EndDate == null)
            {
                HqlStatementHelper.AddGeStatement("CreateDate", searchModel.StartDate, "t", ref whereStatement, param);
            }
            else if (searchModel.StartDate == null & searchModel.EndDate != null)
            {
                HqlStatementHelper.AddLeStatement("CreateDate", searchModel.EndDate, "t", ref whereStatement, param);
            }
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by t.CreateDate desc";
            }
            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
 public ActionResult List(GridCommand command, SearchModel searchModel)
 {
     ViewBag.Status = searchModel.Status;
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     return View();
 }
        public ActionResult _AjaxList(GridCommand command, SearchModel searchModel)
        {

            SearchStatementModel searchStatementModel = PrepareSearchStatement(command, searchModel);
            GridModel<CancelProdOpReport> gridlist = GetAjaxPageData<CancelProdOpReport>(searchStatementModel, command);
            return PartialView(gridlist);
            //return PartialView(GetAjaxPageData<ReceiptMaster>(searchStatementModel, command));
        }
        public ActionResult Index(SearchModel searchModel)
        {
            SqlParameter[] sqlParam = new SqlParameter[1];
            string sql = @"select e.* from SI_EntityPreference e ";

            DataSet entity = genericMgr.GetDatasetBySql(sql, sqlParam);

            ViewModel model = new ViewModel();
            model.Data = entity.Tables[0];
            model.Columns = IListHelper.GetColumns(entity.Tables[0]);
            return View(model);
        }
        public ActionResult Index(SearchModel searchModel)
        {
            TempData["SearchModel"] = searchModel;
            SqlParameter[] sqlParam = new SqlParameter[4];
            string sql = @"select top " + MaxRowSize +
                @" e.* from SI_SAP_TransCallBack e where e.CreateDate > @p1 and e.CreateDate < @p2  ";

            string mType = string.Empty;
            if (!searchModel.Status.HasValue || searchModel.Status.Value == 2)
            {
                sql += " and e.MTYPE = @p0 ";
                sqlParam[0] = new SqlParameter("@p0", string.Empty);
            }
            else if (searchModel.Status.Value ==1)
            {
                sql += " and e.MTYPE = @p0 ";
                sqlParam[0] = new SqlParameter("@p0", "T");
            }

            if (searchModel.StartDate.HasValue)
            {
                sqlParam[1] = new SqlParameter("@p1", searchModel.StartDate);
            }
            else
            {
                sqlParam[1] = new SqlParameter("@p1", DateTime.Now.AddDays(-1));
            }
            if (searchModel.EndDate.HasValue)
            {
                sqlParam[2] = new SqlParameter("@p2", searchModel.EndDate);
            }
            else
            {
                sqlParam[2] = new SqlParameter("@p2", DateTime.Now);
            }

            if (searchModel.Id.HasValue)
            {
                sql += " and e.Id = @p3 ";
                sqlParam[3] = new SqlParameter("@p3", searchModel.Id);
            }

            sql += " order by e.Id desc ";

            DataSet entity = siMgr.GetDatasetBySql(sql, sqlParam);

            ViewModel model = new ViewModel();
            model.Data = entity.Tables[0];
            model.Columns = IListHelper.GetColumns(entity.Tables[0]);
            return View(model);
        }
        public ActionResult Index(GridCommand command, SearchModel searchModel)
        {
            return View();
            //            TempData["SearchModel"] = searchModel;
//            //command.PageSize = 100;
//            int startSize = command.Page == 0 ? 0 : (command.Page - 1) * command.PageSize;
//            int endSize = command.Page == 0 ? command.PageSize : command.Page * command.PageSize;
//            SqlParameter[] sqlParam = new SqlParameter[5];
//            //string sql = @"select top " + MaxRowSize +
//            //    @" e.* from SAP_ProdOpReport e where e.Status = @p0 and e.CreateDate > @p1 and e.CreateDate < @p2  ";
//            string sql = @"select RowId=ROW_NUMBER()OVER(order by   e.CreateDate  asc),* from SAP_ProdOpReport as e where 
//                            e.Status = @p0 and e.CreateDate > @p1 and e.CreateDate < @p2 ";

//            sqlParam[0] = new SqlParameter("@p0", searchModel.Status.HasValue ? searchModel.Status.Value : 2);

//            if (searchModel.StartDate.HasValue)
//            {
//                sqlParam[1] = new SqlParameter("@p1", searchModel.StartDate);
//            }
//            else
//            {
//                sqlParam[1] = new SqlParameter("@p1", "1900-1-1");
//            }
//            if (searchModel.EndDate.HasValue)
//            {
//                sqlParam[2] = new SqlParameter("@p2", searchModel.EndDate);
//            }
//            else
//            {
//                sqlParam[2] = new SqlParameter("@p2", DateTime.Now);
//            }

//            sqlParam[3] = new SqlParameter("@p3", startSize);
//            sqlParam[4] = new SqlParameter("@p4", endSize);

//            string execSql = " select t1.* from (" + sql + ") as t1 where RowId between @p3 and @p4";


//            DataSet entity = genericMgr.GetDatasetBySql(execSql, sqlParam);

//            sqlParam[3].Value = 0;
//            sqlParam[4].Value = 999999999999999;
//            DataSet countEntity = genericMgr.GetDatasetBySql(" select isnull(count(*),0) as count from (" + sql + ") as t1 where RowId between @p3 and @p4", sqlParam);

//            ViewModel model = new ViewModel();
//            model.Data = entity.Tables[0];
//            model.Columns = IListHelper.GetColumns(entity.Tables[0]);
//            ViewBag.Total = int.Parse((countEntity.Tables[0].Rows[0].ItemArray[0]).ToString());
//            return View(model);
        }
        public ActionResult _AjaxList(GridCommand command, SearchModel searchModel)
        {
            #region
            string hql = @"select sp.* from SAP_ProdOpBackflush as sp with(nolock) inner join ORD_OrderMstr_4 as o  with(nolock) on sp.OrderNo=o.OrderNo
where   o.ProdLineType not in  (1 , 2 , 3 , 4 , 9) ";
            IList<object> paramArr = new List<object>();
            if (!string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                hql += " and o.OrderNo = ? ";
                paramArr.Add(searchModel.OrderNo);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.AUFNR))
            {
                hql += " and sp.AUFNR = ? ";
                paramArr.Add(searchModel.AUFNR);
            }
            if (searchModel.Status != null)
            {
                hql += " and sp.Status = ? ";
                paramArr.Add(searchModel.Status);
            }
            if (searchModel.StartDate != null)
            {
                hql += " and sp.CreateDate >= ? ";
                paramArr.Add(searchModel.StartDate.Value);
            }
            if (searchModel.EndDate != null)
            {
                hql += " and sp.CreateDate <= ? ";
                paramArr.Add(searchModel.EndDate);
            }
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by CreateDate desc ";
            }
            #endregion

            IList<object> countList = this.genericMgr.FindAllWithNativeSql<object>("select count(*) from (" + hql + ") as tt3", paramArr.ToArray());

            IList<ProdOpBackflush> searchResultList = this.genericMgr.FindEntityWithNativeSql<ProdOpBackflush>("select * from ( select RowId=ROW_NUMBER()OVER(" + sortingStatement + "),* from (" + hql + " ) as tt2 ) as tt3 where tt3.RowId between " + (command.Page - 1) * command.PageSize + " and " + command.Page * command.PageSize + "", paramArr.ToArray());


            ViewBag.Total = Convert.ToInt32(countList[0]);
            GridModel<ProdOpBackflush> gridModel = new GridModel<ProdOpBackflush>();
            gridModel.Total = Convert.ToInt32(countList[0]);
            gridModel.Data = searchResultList;
            return PartialView(gridModel); 
        }
        //[SconitAuthorize(Permissions = "Url_SI_SAP_Item_View")]
        public ActionResult Index(SearchModel searchModel)
        {
            TempData["SearchModel"] = searchModel;
            SqlParameter[] sqlParam = new SqlParameter[1];
            string sql = @"select e.* from SAP_MapMoveTypeTCode e ";

            if (!string.IsNullOrWhiteSpace(searchModel.Code))
            {
                sql += " where e.BWART = @p0 ";
                sqlParam[0] = new SqlParameter("@p0", searchModel.Code);
            }

            DataSet entity = genericMgr.GetDatasetBySql(sql, sqlParam);

            ViewModel model = new ViewModel();
            model.Data = entity.Tables[0];
            model.Columns = IListHelper.GetColumns(entity.Tables[0]);
            return View(model);
        }
        //[SconitAuthorize(Permissions = "Url_SI_SAP_Supplier_View")]
        public ActionResult Index(SearchModel searchModel)
        {
            TempData["SearchModel"] = searchModel;
            SqlParameter[] sqlParam = new SqlParameter[4];

            string sql = @"select top " + MaxRowSize + 
                " e.* from SI_SAP_Supplier e  where e.IOStatus = @p0 and e.InboundDate > @p1 and e.InboundDate < @p2 ";

            sqlParam[0] = new SqlParameter("@p0", searchModel.Status.HasValue ? searchModel.Status.Value : 2);

            if (searchModel.StartDate.HasValue)
            {
                sqlParam[1] = new SqlParameter("@p1", searchModel.StartDate);
            }
            else
            {
                sqlParam[1] = new SqlParameter("@p1", DateTime.Now.AddDays(-1));
            }
            if (searchModel.EndDate.HasValue)
            {
                sqlParam[2] = new SqlParameter("@p2", searchModel.EndDate);
            }
            else
            {
                sqlParam[2] = new SqlParameter("@p2", DateTime.Now);
            }

            if (searchModel.Id.HasValue)
            {
                sql += " and e.Id = @p3 ";
                sqlParam[3] = new SqlParameter("@p3", searchModel.Id);
            }

            sql += " order by e.Id desc ";

            DataSet entity = siMgr.GetDatasetBySql(sql, sqlParam);

            ViewModel model = new ViewModel();
            model.Data = entity.Tables[0];
            model.Columns = IListHelper.GetColumns(entity.Tables[0]);
            return View(model);
        }
        public ActionResult Index(SearchModel searchModel)
        {
            TempData["SearchModel"] = searchModel;
            SqlParameter[] sqlParam = new SqlParameter[4];
            string sql = @"select top " + MaxRowSize +
                @" c.* from SAP_CancelProdOpReport c where c.Status = @p0 and c.CreateDate > @p1 and c.CreateDate < @p2  ";

            sqlParam[0] = new SqlParameter("@p0", searchModel.Status.HasValue ? searchModel.Status.Value : 2);

            if (searchModel.StartDate.HasValue)
            {
                sqlParam[1] = new SqlParameter("@p1", searchModel.StartDate);
            }
            else
            {
                sqlParam[1] = new SqlParameter("@p1", "1900-1-1");
            }
            if (searchModel.EndDate.HasValue)
            {
                sqlParam[2] = new SqlParameter("@p2", searchModel.EndDate);
            }
            else
            {
                sqlParam[2] = new SqlParameter("@p2", DateTime.Now);
            }

     

            sql += " order by c.CreateDate desc ";

            DataSet entity = genericMgr.GetDatasetBySql(sql, sqlParam);

            ViewModel model = new ViewModel();
            model.Data = entity.Tables[0];
            model.Columns = IListHelper.GetColumns(entity.Tables[0]);
            return View(model);
        }
 public ActionResult Index(GridCommand command, SearchModel searchModel)
 {
     return View();
 }
 //[SconitAuthorize(Permissions = "Url_SI_SAP_Supplier_View")]
 public ActionResult Index(SearchModel searchModel)
 {
     TempData["SearchModel"] = searchModel;
     return View();
 }
        public void ExportXLS(SearchModel searchModel)
        {
            string hql = @"select sp.* from SAP_ProdOpBackflush as sp with(nolock) inner join ORD_OrderMstr_4 as o  with(nolock) on sp.OrderNo=o.OrderNo
where   o.ProdLineType not in  (1 , 2 , 3 , 4 , 9) ";
            IList<object> paramArr = new List<object>();
            if (!string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                hql += " and o.OrderNo = ? ";
                paramArr.Add(searchModel.OrderNo);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.AUFNR))
            {
                hql += " and sp.AUFNR = ? ";
                paramArr.Add(searchModel.AUFNR);
            }
            if (searchModel.Status!=null)
            {
                hql += " and sp.Status = ? ";
                paramArr.Add(searchModel.Status);
            }
            if (searchModel.StartDate!=null)
            {
                hql += " and sp.CreateDate >= ? ";
                paramArr.Add(searchModel.StartDate.Value);
            }
            if (searchModel.EndDate!=null )
            {
                hql += " and sp.CreateDate <= ? ";
                paramArr.Add(searchModel.EndDate);
            }
            hql += " order by sp.CreateDate desc ";
            IList<ProdOpBackflush> exportList = this.genericMgr.FindEntityWithNativeSql<ProdOpBackflush>(hql, paramArr.ToArray());
            ExportToXLS<ProdOpBackflush>("ExportProdOpBackflush", "xls", exportList);
        }
        private string PrepareSearchStatement(GridCommand command, SearchModel searchModel)
        {
            string hql = @"select sp.* from SAP_ProdOpBackflush as sp with(nolock) inner join ORD_OrderMstr_4 as o  with(nolock) on sp.OrderNo=o.OrderNo
where   o.ProdLineType not in  (1 , 2 , 3 , 4 , 9) ";
            IList<object> paramArr = new List<object>();
            if (!string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                hql += " and o.OrderNo = ? ";
                paramArr.Add(searchModel.OrderNo);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.AUFNR))
            {
                hql += " and sp.AUFNR = ? ";
                paramArr.Add(searchModel.AUFNR);
            }
            if (searchModel.Status != null)
            {
                hql += " and sp.Status = ? ";
                paramArr.Add(searchModel.Status);
            }
            if (searchModel.StartDate != null)
            {
                hql += " and sp.CreateDate >= ? ";
                paramArr.Add(searchModel.StartDate.Value);
            }
            if (searchModel.EndDate != null)
            {
                hql += " and sp.CreateDate <= ? ";
                paramArr.Add(searchModel.EndDate);
            }
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by sp.CreateDate desc ";
            }

            return hql;
        }