Beispiel #1
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);
        }