Пример #1
0
        public static string GetListAllItemView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, bool hideDisplay)
        {
            string message = "";
            long totalPages;
            long totalItems;
            string htmlTextItemList = "";
            string htmlAddItemList = "";

            if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false))
            {
                TemplateInfoCategoryView templateView = new TemplateInfoCategoryView
                {
                    DataIndex = dataIndex.ToString(),
                    PageNo = pageNo.ToString(),
                    ItemsPerPage = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                    HideDisplay = hideDisplay.ToString().ToLower(),
                };
                htmlTextItemList = templateView.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }else
            {
                #region Add Link

                if (UtilsSecurity.HaveAuthorRoleEnabled() == true)
                {
                    TemplateInfoCategorySaveAdd templateSaveAdd = new TemplateInfoCategorySaveAdd
                    {
                        DataIndex = dataIndex.ToString(),
                        PageNo = pageNo.ToString(),
                        ItemsPerPage = itemsPerPage.ToString(),
                        TemplateSuffix = templateSuffix,
                    };
                    htmlAddItemList = templateSaveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }

                #endregion

                #region Get Fill List

                #region Get Paged Data

                List<LTD_InfoCategory> ltdInfoCategoryList = new List<LTD_InfoCategory>();
                ltdInfoCategoryList = DataInfoList.GetPagedLtdInfoCategory(pageNo, itemsPerPage, out totalPages, out totalItems);

                #endregion

                if (ltdInfoCategoryList.Count > 0)
                {
                    #region Get Pager Details

                    string topPagerDetails = UtilsGeneric.GetItemPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, RefreshListFunctionName, hideDisplay.ToString(CultureInfo.InvariantCulture).ToLower(), true, true);
                    string bottomPagerDetails = UtilsGeneric.GetLinkPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, totalItems, RefreshListFunctionName, hideDisplay.ToString(CultureInfo.InvariantCulture).ToLower());

                    #endregion

                    #region Append Top Pager

                    if (topPagerDetails.Trim().Length > 0)
                    {
                        htmlTextItemList += topPagerDetails;
                    }

                    #endregion

                    #region Append Items

                    int index = 0;
                    for (; index < ltdInfoCategoryList.Count; index++)
                    {
                        LTD_InfoCategory ltdInfoCategory = ltdInfoCategoryList[index];
                        string htmlTextItemTemplate = GetListSingleItemView(ltdInfoCategory, pageNo, itemsPerPage, dataIndex, templateSuffix, hideDisplay);
                        htmlTextItemList += htmlTextItemTemplate;
                    }

                    #endregion

                    #region Append Bottom Pager

                    if (bottomPagerDetails.Trim().Length > 0)
                    {
                        htmlTextItemList += bottomPagerDetails;
                    }

                    #endregion
                }

                #endregion

                #region Set Fill List

                if (htmlTextItemList.Length == 0)
                {
                    TemplateInfoCategoryListDetailEmpty templateListDetailEmpty = new TemplateInfoCategoryListDetailEmpty
                    {
                        DataIndex = dataIndex.ToString(),
                        PageNo = pageNo.ToString(),
                        ItemsPerPage = itemsPerPage.ToString(),
                        TemplateSuffix = templateSuffix,
                        HideDisplay = hideDisplay.ToString().ToLower(),
                    };
                    htmlTextItemList = templateListDetailEmpty.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }

                #endregion
            }

            return htmlAddItemList + htmlTextItemList;
        }
Пример #2
0
        public static string GetSaveDetailView(long infoCategoryId, long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, bool hideDisplay)
        {
            string message; 
            string htmlSaveDetail = "";
            long revisionNo = 0;
            string infoCategoryName = "";
            bool infoCategoryIsDefault = false;
            bool infoCategoryIsActive = true;
            bool infoCategoryIsSystem = false;

            if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRole() == false))
            {
                TemplateInfoCategoryView templateView = new TemplateInfoCategoryView
                {
                    DataIndex = dataIndex.ToString(),
                    PageNo = pageNo.ToString(),
                    ItemsPerPage = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix
                };
                htmlSaveDetail = templateView.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }
            else
            {
                #region Get Category Details

                if (infoCategoryId > 0)
                {
                    LTD_InfoCategory ltdInfoCategoryExisting = DataInfoList.GetLtdInfoCategory(infoCategoryId);
                    if (ltdInfoCategoryExisting != null)
                    {
                        infoCategoryName = ltdInfoCategoryExisting.InfoCategoryName;

                        infoCategoryIsDefault = ltdInfoCategoryExisting.IsDefault;
                        infoCategoryIsActive = ltdInfoCategoryExisting.IsActive;
                        //infoCategoryIsSystem = ltdInfoCategoryExisting.IsSystem;
                        revisionNo = ltdInfoCategoryExisting.RevisionNo;
                    }
                }

                #endregion

                #region Set Action

                bool showUserInfo = false;
                bool enableSave = true;
                bool enableDelete = true;
                if (UtilsSecurity.IsAuthenticated() == false)
                {
                    showUserInfo = true;
                    enableSave = false;
                    enableDelete = false;
                }

                #endregion

                #region Set Template

                string addActionHtml = "";
                string editActionHtml = "";
                if (infoCategoryId == 0)
                {
                    var templateSaveAdd = new TemplateInfoCategorySaveDetailAdd
                    {
                        AddActionDisabled =!enableSave,
                        DataIndex = dataIndex.ToString("N0", CultureInfo.InvariantCulture),
                        PageNo = pageNo.ToString("N0", CultureInfo.InvariantCulture),
                        ItemsPerPage = itemsPerPage.ToString("N0", CultureInfo.InvariantCulture),
                        TemplateSuffix = templateSuffix,
                        HideDisplay = hideDisplay.ToString().ToLower(),
                    };
                    addActionHtml = templateSaveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }
                else
                {
                    var templateSaveEdit = new TemplateInfoCategorySaveDetailEdit
                    {
                        Id = infoCategoryId.ToString(),
                        DataIndex = dataIndex.ToString("N0", CultureInfo.InvariantCulture),
                        PageNo = pageNo.ToString("N0", CultureInfo.InvariantCulture),
                        ItemsPerPage = itemsPerPage.ToString("N0", CultureInfo.InvariantCulture),
                        TemplateSuffix = templateSuffix,
                        HideDisplay = hideDisplay.ToString().ToLower(),
                        SaveActionDisabled = !enableSave,
                        DeleteActionDisabled = !enableDelete,
                    };
                    editActionHtml = templateSaveEdit.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }

                List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsDefault> isDefaultList = new List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsDefault>();
                List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsNotDefault> isNotDefaultList = new List<TemplateInfoCategorySaveDetail.IsDefaultVisible.IsNotDefault>();
                if (infoCategoryIsDefault == true)
                {
                    isDefaultList.Add(new TemplateInfoCategorySaveDetail.IsDefaultVisible.IsDefault
                    {
                        DataIndex = dataIndex.ToString(),
                    });

                }
                else
                {
                    isNotDefaultList.Add(new TemplateInfoCategorySaveDetail.IsDefaultVisible.IsNotDefault
                    {
                        DataIndex = dataIndex.ToString(),
                    });
                }

                List<TemplateInfoCategorySaveDetail.IsDefaultVisible> isDefaultVisibleList = new List<TemplateInfoCategorySaveDetail.IsDefaultVisible>();
                if ((infoCategoryId != 0) && (UtilsSecurity.HaveAdminRole() ==true))
                {
                    isDefaultVisibleList.Add(new TemplateInfoCategorySaveDetail.IsDefaultVisible
                    {
                        DataIndex = dataIndex.ToString(),
                        IsDefaultList = isDefaultList,
                        IsNotDefaultList = isNotDefaultList,
                    });
                }
                List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsActive> isActiveList = new List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsActive>();
                List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsInActive> isInActiveList = new List<TemplateInfoCategorySaveDetail.IsActiveVisible.IsInActive>();
                if (infoCategoryIsActive == true)
                {
                    isActiveList.Add(new TemplateInfoCategorySaveDetail.IsActiveVisible.IsActive
                    {
                        DataIndex = dataIndex.ToString(),
                    });

                }
                else
                {
                    isInActiveList.Add(new TemplateInfoCategorySaveDetail.IsActiveVisible.IsInActive
                    {
                        DataIndex = dataIndex.ToString(),
                    });
                }

                List<TemplateInfoCategorySaveDetail.IsActiveVisible> isActiveVisibleList = new List<TemplateInfoCategorySaveDetail.IsActiveVisible>();
                if (infoCategoryId != 0)
                {
                    isActiveVisibleList.Add(new TemplateInfoCategorySaveDetail.IsActiveVisible
                    {
                        DataIndex = dataIndex.ToString(),
                        IsActiveList = isActiveList,
                        IsInActiveList = isInActiveList,
                    });
                }

                var templateSaveDetail = new TemplateInfoCategorySaveDetail
                {
                    //Id = groupId.ToString("N0", CultureInfo.InvariantCulture),
                    DataIndex = dataIndex.ToString(),                    
                    RevisionNo = revisionNo.ToString("N0", CultureInfo.InvariantCulture),    
                    InfoCategoryName =infoCategoryName,
                    InfoCategoryNameDisabled = infoCategoryIsSystem,
                    IsDefaultVisibleList = isDefaultVisibleList,
                    IsActiveVisibleList = isActiveVisibleList,

                    AddAction = addActionHtml,
                    EditAction = editActionHtml,
                    ShowUserInfo = showUserInfo,   
                };

                htmlSaveDetail = templateSaveDetail.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);

                #endregion
            }

            return htmlSaveDetail;
        }