public ActionResult _AjaxList(GridCommand command, WorkingCalendarSearchModel searchModel)
        {
            var objList = this.genericMgr.FindAllWithNativeSql<object[]>("exec USP_Busi_GetWorkingCalendarView ?,?,?,?",
                                                            new object[]
                                                               {
                                                                   searchModel.SearchRegion, "",
                                                                   searchModel.StartWorkingDate, searchModel.EndWorkingDate
                                                               });

            var list = new List<WorkingCalendarView>();
            foreach (var obj in objList)
            {
                var w = obj as object[];
                if (w == null) continue;

                list.Add(new WorkingCalendarView
                             {
                                 Date = (DateTime)w[0],
                                 DateFrom = (DateTime)w[1],
                                 DateTo = (DateTime)w[2]
                             });
            }

            return PartialView(new GridModel(list));
        }
        public ActionResult List(GridCommand command, WorkingCalendarSearchModel searchModel)
        {
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
            var error = false;
            if (string.IsNullOrWhiteSpace(searchModel.SearchRegion))
            {
                error = true;
                SaveErrorMessage(Resources.ErrorMessage.Errors_Common_FieldRequired, Resources.PRD.WorkingCalendar.WorkingCalendar_ProdLine);
            }
            if (!searchModel.StartWorkingDate.HasValue)
            {
                error = true;
                SaveErrorMessage(Resources.ErrorMessage.Errors_Common_FieldRequired, Resources.PRD.WorkingCalendar.WorkingCalendar_StartWorkingDate);
            }
            if (!searchModel.EndWorkingDate.HasValue)
            {
                error = true;
                SaveErrorMessage(Resources.ErrorMessage.Errors_Common_FieldRequired, Resources.PRD.WorkingCalendar.WorkingCalendar_EndWorkingDate);
            }
            if (searchModel.StartWorkingDate.HasValue && searchModel.EndWorkingDate.HasValue && searchModel.StartWorkingDate.Value >= searchModel.EndWorkingDate.Value)
            {
                error = true;
                SaveErrorMessage(Resources.PRD.WorkingCalendar.WorkingCalendar_EndDateMustGreaterThanStartDate);
            }
            ViewBag.ReadOnly = error;
            ViewBag.PageSize = base.ProcessPageSize(command.PageSize);

            return View();
        }
        public ActionResult List(GridCommand command, WorkingCalendarSearchModel searchModel)
        {
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
            ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
            IList<CodeDetail> workingCalendarTypeList = systemMgr.GetCodeDetails(CodeMaster.CodeMaster.WorkingCalendarType);
            ViewData["WorkingCalendarType"] = base.Transfer2DropDownList(CodeMaster.CodeMaster.WorkingCalendarType, workingCalendarTypeList);

            // 判断是否有编辑生产线标准工作日历的权限
            var user = SecurityContextHolder.Get();
            var q = user.UrlPermissions.Where(p => p.Contains("Url_WorkingCalendar_Edit")).ToList();
            ViewBag.NoEditPermission = q == null || q.Count() == 0;
            
            return View();
        }
 public ActionResult _AjaxList(GridCommand command, WorkingCalendarSearchModel searchModel)
 {
     SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<WorkingCalendar>(searchStatementModel, command));
 }
        /// <summary>
        /// Search Statement
        /// </summary>
        /// <param name="command">Telerik GridCommand</param>
        /// <param name="searchModel">WorkingCalendar Search Model</param>
        /// <returns>return WorkingCalendar search model</returns>
        private SearchStatementModel PrepareSearchStatement(GridCommand command, WorkingCalendarSearchModel searchModel)
        {
            string whereStatement = string.Empty;

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

            HqlStatementHelper.AddEqStatement("Category", (int)WorkingCalendarCategory.Region, "wc", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Region", searchModel.SearchRegion, "wc", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Shift", searchModel.SearchShift, "wc", ref whereStatement, param);

            if (searchModel.StartWorkingDate.HasValue && searchModel.EndWorkingDate.HasValue)
            {
                HqlStatementHelper.AddBetweenStatement("WorkingDate", searchModel.StartWorkingDate, searchModel.EndWorkingDate, "wc", ref whereStatement, param);
            }
            else if (searchModel.StartWorkingDate.HasValue & !searchModel.EndWorkingDate.HasValue)
            {
                HqlStatementHelper.AddGeStatement("WorkingDate", searchModel.StartWorkingDate, "wc", ref whereStatement, param);
            }
            else if (!searchModel.StartWorkingDate.HasValue & searchModel.EndWorkingDate.HasValue)
            {
                HqlStatementHelper.AddLeStatement("WorkingDate", searchModel.EndWorkingDate, "wc", ref whereStatement, param);
            }

            if (command.SortDescriptors.Count > 0)
            {
                if (command.SortDescriptors[0].Member == "DayOfWeekDescription")
                {
                    command.SortDescriptors[0].Member = "DayOfWeek";
                }

                if (command.SortDescriptors[0].Member == "TypeDescription")
                {
                    command.SortDescriptors[0].Member = "Type";
                }
            }

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by wc.Region, wc.WorkingDate ";
            }

            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 _Update(int id, WorkingCalendar workingCalendar, WorkingCalendarSearchModel searchModel, GridCommand command)
        {
            try
            {
                ModelState.Remove("EndDate");

                var newWorkingCalendar = base.genericMgr.FindById<WorkingCalendar>(id);

                newWorkingCalendar.Shift = workingCalendar.Shift;
                newWorkingCalendar.Type = workingCalendar.Type;
                newWorkingCalendar.Category = WorkingCalendarCategory.Region;

                this.WorkingCalendarMgr.UpdateWorkingCalendar(newWorkingCalendar);
                //SaveSuccessMessage(Resources.PRD.WorkingCalendar.WorkingCalendar_Updated);
            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
            }
            SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);
            return PartialView(GetAjaxPageData<WorkingCalendar>(searchStatementModel, command));
        }