public ActionResult List(GridCommand command, FlowSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     if (searchCacheModel.isBack == true)
     {
         ViewBag.Page = searchCacheModel.Command.Page == 0 ? 1 : searchCacheModel.Command.Page;
     }
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     return View();
 }
        public ActionResult Export(FlowSearchModel searchModel)
        {
            int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
            GridCommand command = new GridCommand();
            command.Page = 1;
            command.PageSize = !this.CheckSearchModelIsNull(searchModel) ? 0 : value;
            SearchStatementModel searchStatementModel = PrepareSearchStatement(command, searchModel);
            IList<FlowMaster> flowMasters = GetAjaxPageData<FlowMaster>(searchStatementModel, command).Data.ToList();
            List<FlowDetail> flowDetails = new List<FlowDetail>();
            IList<FlowStrategy> flowStrategys = genericMgr.FindAll<FlowStrategy>();
            var itemCategoryList = this.genericMgr.FindAll<ItemCategory>();
            foreach (var flowMaster in flowMasters)
            {
                IList<FlowDetail> flowDetailLists = flowMgr.GetFlowDetailList(flowMaster.Code);
                FillCodeDetailDescription<FlowDetail>(flowDetailLists);
                foreach (var flowDetailList in flowDetailLists)
                {
                    //var zzz =  ;
                    //BillTermDescription ReceiveGapTo
                    //flowMaster.BillTerm   TranslateCodeDetailDescription
                    var item = itemMgr.GetCacheItem(flowDetailList.Item);
                    flowDetailList.CurrentFlowMaster = flowMaster;
                    flowDetailList.ItemDescription = item.Description;
                    flowDetailList.MaterialsGroup = item.MaterialsGroup;
                    flowDetailList.Warranty = item.Warranty;
                    flowDetailList.ItemOption = item.ItemOption;
                    flowDetailList.MaterialsGroupDesc = GetItemCategory(flowDetailList.MaterialsGroup, Sconit.CodeMaster.SubCategory.MaterialsGroup, itemCategoryList).Description;

                    flowDetailList.CurrentFlowStrategy = flowStrategys.Where(p => p.Flow == flowMaster.Code).FirstOrDefault() ?? new FlowStrategy();
                }
                flowDetails.AddRange(flowDetailLists);
            }
            var table = GetStringFlowInforView(flowDetails, true);
            return new DownloadFileActionResult(table, "TransferFlowDetail.xls");
        }
 public ActionResult _AjaxList(GridCommand command, FlowSearchModel searchModel)
 {
     this.GetCommand(ref command, searchModel);
     SearchStatementModel searchStatementModel = PrepareSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<FlowMaster>(searchStatementModel, command));
 }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, FlowSearchModel searchModel)
        {
            string whereStatement = " where f.Type=2 ";

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

            HqlStatementHelper.AddLikeStatement("Code", searchModel.Code, HqlStatementHelper.LikeMatchMode.Anywhere, "f", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("Description", searchModel.Description, HqlStatementHelper.LikeMatchMode.Anywhere, "f", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("LocationTo", searchModel.LocationTo,  "f", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("LocationFrom", searchModel.LocationFrom,  "f", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("PartyFrom", searchModel.PartyFrom, "f", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("PartyTo", searchModel.PartyTo, "f", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("IsActive", searchModel.IsActive, "f", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            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, FlowSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     return View();
 }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, FlowSearchModel searchModel)
        {
            string whereStatement = " where f.Type=" + (int)com.Sconit.CodeMaster.OrderType.Production + " and f.ProdLineType in (" +
                (int)com.Sconit.CodeMaster.ProdLineType.Chassis + "," + (int)com.Sconit.CodeMaster.ProdLineType.Cab + "," +
                (int)com.Sconit.CodeMaster.ProdLineType.Assembly + "," + (int)com.Sconit.CodeMaster.ProdLineType.Special + "," + (int)com.Sconit.CodeMaster.ProdLineType.Check + ") ";

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

            HqlStatementHelper.AddLikeStatement("Code", searchModel.Code, HqlStatementHelper.LikeMatchMode.Start, "f", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

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

            return searchStatementModel;
        }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, FlowSearchModel searchModel)
        {
            string whereStatement = " where f.Type=4 and f.ProdLineType not in (1,2,3,4,9)";

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

            HqlStatementHelper.AddLikeStatement("Code", searchModel.Code, HqlStatementHelper.LikeMatchMode.Start, "f", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("Description", searchModel.Description, HqlStatementHelper.LikeMatchMode.Start, "f", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("LocationFrom", searchModel.LocationFrom, HqlStatementHelper.LikeMatchMode.Start, "f", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("LocationTo", searchModel.LocationTo, HqlStatementHelper.LikeMatchMode.Start, "f", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("PartyFrom", searchModel.PartyFrom, HqlStatementHelper.LikeMatchMode.Start, "f", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("IsActive", searchModel.IsActive, "f", ref whereStatement, param);
            //SecurityHelper.AddPartyFromPermissionStatement(ref whereStatement, "f", "PartyFrom", com.Sconit.CodeMaster.OrderType.Production, false);
            SecurityHelper.AddPartyFromAndPartyToPermissionStatement(ref whereStatement, "f", "Type", "f", "PartyFrom", "f", "PartyTo", com.Sconit.CodeMaster.OrderType.Production, false);
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

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

            return searchStatementModel;
        }