Beispiel #1
0
        public static bool SaveLTDInfoDetailData(Dictionary <Guid, LTD_InfoDetail> ltdInfoDetailList)
        {
            bool ret = false;

            if (ltdInfoDetailList.Count > 0)
            {
                List <LTD_InfoDetail> ltdInfoDetailValueList = new List <LTD_InfoDetail>();
                LTD_InfoDetail[]      ltdInfoDetailArray     = new LTD_InfoDetail[ltdInfoDetailList.Values.Count];
                ltdInfoDetailList.Values.CopyTo(ltdInfoDetailArray, 0);
                ltdInfoDetailValueList.AddRange(ltdInfoDetailArray);
                ret = JsonStore <LTD_InfoDetail> .SaveData(ltdInfoDetailValueList, true);
            }

            return(ret);
        }
Beispiel #2
0
        private static string GetListSingleItemView(LTD_InfoDetail ltdDetail, long pageNo, long itemsPerDetail, long dataIndex, string templateSuffix, long infoSectionId)
        {
            string       htmlTextItem = "";
            LTD_InfoPage ltdInfoPage  = DataInfoList.GetLtdInfoPage(ltdDetail.InfoPageID);

            if ((ltdDetail != null) && (ltdInfoPage != null))
            {
                string message;
                List <TemplateInfoDetailListDetailItem.EditAction> editActionList = new List <TemplateInfoDetailListDetailItem.EditAction>();
                if (((UtilsSecurity.HaveAdminRole() == true) && (UtilsSecurity.HaveAuthorRoleEnabled() == true)) || ((UtilsSecurity.HaveAuthorRoleEnabled() == true) && (ltdInfoPage.UserID == UtilsSecurity.GetUserId())))
                {
                    editActionList.Add(new TemplateInfoDetailListDetailItem.EditAction
                    {
                        Id             = ltdDetail.InfoDetailID.ToString(),
                        DataIndex      = dataIndex.ToString(),
                        PageNo         = pageNo.ToString(),
                        ItemsPerPage   = itemsPerDetail.ToString(),
                        TemplateSuffix = templateSuffix,
                        InfoSectionId  = infoSectionId.ToString(),
                    });
                }

                var templateItem = new TemplateInfoDetailListDetailItem
                {
                    InfoDetailName        = ltdDetail.InfoDetailName,
                    InfoDetailDescription = ltdDetail.InfoDetailDescription,
                    IsInActive            = !ltdDetail.IsActive,

                    EditActionList = editActionList
                };
                htmlTextItem = templateItem.GetFilled(templateSuffix, UtilsGeneric.Validate,
                                                      UtilsGeneric.ThrowException,
                                                      out message);
            }
            return(htmlTextItem);
        }
Beispiel #3
0
        public static string GetListAllItemView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, long infoSectionId)
        {
            string message = "";

            if (itemsPerPage == 0)
            {
                itemsPerPage = UtilsGeneric.DefaultInnerItemsPerPage;
            }
            long   totalDetails;
            long   totalItems;
            string htmlTextItemList = "";
            string htmlAddItemList  = "";

            #region Add Link

            LTD_InfoSection ltdInfoSection = DataInfoList.GetLtdInfoSection(infoSectionId);
            if (ltdInfoSection != null)
            {
                LTD_InfoPage ltdInfoPage = DataInfoList.GetLtdInfoPage(ltdInfoSection.InfoPageID);
                if (UtilsSecurity.HaveAuthorRoleEnabled() == true)
                {
                    if ((ltdInfoPage != null) && (ltdInfoPage.UserID == UtilsSecurity.GetUserId()))
                    {
                        TemplateInfoDetailSaveAdd saveAdd = new TemplateInfoDetailSaveAdd
                        {
                            DataIndex      = dataIndex.ToString(),
                            PageNo         = pageNo.ToString(),
                            ItemsPerPage   = itemsPerPage.ToString(),
                            TemplateSuffix = templateSuffix,
                            InfoSectionId  = infoSectionId.ToString(),
                        };
                        htmlAddItemList = saveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                    }
                }
            }

            #endregion

            #region Get Fill List

            #region Get Detaild Data

            List <LTD_InfoDetail> ltdDetailList = new List <LTD_InfoDetail>();
            if ((UtilsSecurity.HaveAdminRole() == true) || (UtilsSecurity.HaveAuthorRoleEnabled() == true))
            {
                ltdDetailList = DataInfoList.GetPagedLtdInfoDetail(infoSectionId, false, pageNo, itemsPerPage, out totalDetails, out totalItems);
            }
            else
            {
                ltdDetailList = DataInfoList.GetPagedLtdInfoDetail(infoSectionId, true, pageNo, itemsPerPage, out totalDetails, out totalItems);
            }

            #endregion

            if (ltdDetailList.Count > 0)
            {
                #region Get Detail Details

                string topDetailrDetails    = UtilsGeneric.GetItemPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalDetails, RefreshListFunctionName, infoSectionId.ToString());
                string bottomDetailrDetails = UtilsGeneric.GetLinkPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalDetails, totalItems, RefreshListFunctionName, infoSectionId.ToString(), false);

                #endregion

                #region Append Top Details

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

                #endregion

                #region Append Items

                int index = 0;
                for (; index < ltdDetailList.Count; index++)
                {
                    LTD_InfoDetail ltdDetail            = ltdDetailList[index];
                    string         htmlTextItemTemplate = GetListSingleItemView(ltdDetail, pageNo, itemsPerPage, dataIndex, templateSuffix, infoSectionId);
                    htmlTextItemList += htmlTextItemTemplate;
                }

                #endregion

                #region Append Bottom Detailr

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

                #endregion
            }

            #endregion

            #region Set Fill List

            if ((htmlTextItemList.Length == 0) && (UtilsSecurity.HaveAuthorRoleEnabled() == true))
            {
                //TemplateInfoDetailListDetailEmpty listDetailEmpty = new TemplateInfoDetailListDetailEmpty
                //{
                //    DataIndex = dataIndex.ToString(),
                //    PageNo = pageNo.ToString(),
                //    ItemsPerPage = itemsPerPage.ToString(),
                //    TemplateSuffix = templateSuffix,
                //    InfoSectionId = infoSectionId.ToString(),
                //};
                //htmlTextItemList = listDetailEmpty.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }

            #endregion

            return(htmlAddItemList + htmlTextItemList);
        }
Beispiel #4
0
        public static string GetSaveDetailView(long infoDetailId, long pageNo, long itemsPerDetail, long dataIndex, string templateSuffix, long infoSectionId)
        {
            string message               = "";
            string htmlSaveDetail        = "";
            long   revisionNo            = 0;
            string infoSectionName       = "";
            string infoDetailName        = "";
            string infoDetailDescription = "";
            bool   isActive              = true;
            bool   isDeleted             = false;
            long   sequence              = 0;
            bool   showAdditional        = (infoDetailId != 0);

            if ((UtilsSecurity.HaveAdminRole() == false) && (UtilsSecurity.HaveAuthorRoleEnabled() == false))
            {
                TemplateInfoDetailView view = new TemplateInfoDetailView
                {
                    DataIndex      = dataIndex.ToString(),
                    PageNo         = pageNo.ToString(),
                    ItemsPerPage   = itemsPerDetail.ToString(),
                    TemplateSuffix = templateSuffix,
                    InfoSectionId  = infoSectionId.ToString(),
                };
                htmlSaveDetail = view.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }
            else
            {
                #region Get Section Details

                if (infoSectionId > 0)
                {
                    LTD_InfoSection ltdSectionExisting = DataInfoList.GetLtdInfoSection(infoSectionId);
                    if (ltdSectionExisting != null)
                    {
                        infoSectionName = ltdSectionExisting.InfoSectionName;
                    }
                }

                #endregion

                #region Get Detail Details

                if (infoDetailId > 0)
                {
                    LTD_InfoDetail ltdDetailExisting = DataInfoList.GetLtdInfoDetail(infoDetailId);
                    if (ltdDetailExisting != null)
                    {
                        infoDetailName        = ltdDetailExisting.InfoDetailName;
                        infoDetailDescription = ltdDetailExisting.InfoDetailDescription;
                        isActive   = ltdDetailExisting.IsActive;
                        isDeleted  = ltdDetailExisting.IsDeleted;
                        sequence   = ltdDetailExisting.Sequence;
                        revisionNo = ltdDetailExisting.RevisionNo;
                    }
                }

                #endregion

                #region Set Action

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

                showDeleted = (!UtilsSecurity.HaveAdminRole() && (infoSectionId > 0));

                #endregion

                #region Set Template

                #region Additional

                List <TemplateInfoDetailSaveDetail.AdditionalVisible> additionalVisibleList = new List <TemplateInfoDetailSaveDetail.AdditionalVisible>();
                if (showAdditional == true)
                {
                    additionalVisibleList.Add(new TemplateInfoDetailSaveDetail.AdditionalVisible
                    {
                        IsActiveHidden  = (infoDetailId == 0),
                        IsActive        = isActive,
                        IsDeletedHidden = !showDeleted,
                        IsDeleted       = isDeleted,
                        SequenceHidden  = (infoDetailId == 0),
                        Sequence        = sequence.ToString(),
                    });
                }

                #endregion

                #region Action

                string addActionHtml  = "";
                string editActionHtml = "";
                if (infoDetailId == 0)
                {
                    var saveDetailAdd = new TemplateInfoDetailSaveDetailAdd
                    {
                        AddActionDisabled = !enableSave,
                        DataIndex         = dataIndex.ToString("N0", CultureInfo.InvariantCulture),
                        PageNo            = pageNo.ToString("N0", CultureInfo.InvariantCulture),
                        ItemsPerPage      = itemsPerDetail.ToString("N0", CultureInfo.InvariantCulture),
                        TemplateSuffix    = templateSuffix,
                        InfoSectionId     = infoSectionId.ToString(),
                    };
                    addActionHtml = saveDetailAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }
                else
                {
                    var templateSaveEdit = new TemplateInfoDetailSaveDetailEdit
                    {
                        Id                   = infoDetailId.ToString(),
                        DataIndex            = dataIndex.ToString("N0", CultureInfo.InvariantCulture),
                        PageNo               = pageNo.ToString("N0", CultureInfo.InvariantCulture),
                        ItemsPerPage         = itemsPerDetail.ToString("N0", CultureInfo.InvariantCulture),
                        TemplateSuffix       = templateSuffix,
                        InfoSectionId        = infoSectionId.ToString(),
                        SaveActionDisabled   = !enableSave,
                        DeleteActionDisabled = !enableDelete,
                    };
                    editActionHtml = templateSaveEdit.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
                }

                #endregion

                var templateSaveDetail = new TemplateInfoDetailSaveDetail
                {
                    //Id = infoSectionId.ToString("N0", CultureInfo.InvariantCulture),
                    RevisionNo = revisionNo.ToString(),

                    InfoSectionName         = infoSectionName,
                    InfoDetailName          = infoDetailName,
                    InfoDetailDescription   = infoDetailDescription,
                    AdditionalActionVisible = showAdditional,
                    AdditionalVisibleList   = additionalVisibleList,

                    //AddMode = (levelId == 0) ? true : false,
                    AddAction    = addActionHtml,
                    EditAction   = editActionHtml,
                    ShowUserInfo = showUserInfo,
                };

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

                #endregion
            }

            return(htmlSaveDetail);
        }