예제 #1
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            if (string.IsNullOrEmpty(AttachmentDocumentType))
            {
                this.ownerPage.ShowMSG("Атрибура AttachmentDocumentType е NULL. Да се въведе стойност преди да се използва контролата.");
                return;
            }

            if (string.IsNullOrEmpty(ModuleSysName))
            {
                this.ownerPage.ShowMSG("Атрибура ModuleSysName е NULL. Да се въведе стойност преди да се използва контролата.");
                return;
            }

            this.ddlAttachmentType.KeyTypeIntCode = this.DocKeyTypeIntCode;

            this.ddlAttachmentType.UserControlLoad();

            this.pnlFormData.Visible = true;
            this.currentEntity       = this.ownerPage.CommonClientRef.GetAttachmentID(this.CurrentEntityMasterID);

            if (currentEntity != null)
            {
                this.tbxDescription.Text             = currentEntity.Description;
                this.tbxAttachmentDate.Text          = currentEntity.AttachmentDate.ToString("dd.MM.yyyy");
                this.ddlAttachmentType.SelectedValue = currentEntity.idAttachmentType.ToString();

                string tmpFolderName = BaseHelper.CheckAndReplaceStringName(this.tbxDescription.Text, "_").Replace("\n", "").Replace("\r", "");

                tmpFolderName = (tmpFolderName.Length > 50) ? tmpFolderName.Substring(0, 50) : tmpFolderName;

                this.fuAttachment.UserControlName = AttachmentDocumentType;
                this.fuAttachment.CustomFolder    = currentEntity.EntityID + "_" + tmpFolderName;
                this.fuAttachment.UserControlLoad();
                this.fuAttachment.BtnUploadFileEnabled = true;

                this.hdnRowMasterKey.Value = currentEntity.EntityID.ToString();
            }
            else
            {
                this.fuAttachment.UserControlName = AttachmentDocumentType;
                this.fuAttachment.ClearGrid();
                this.fuAttachment.BtnUploadFileEnabled = false;

                this.lbResultContext.Text = "";

                this.tbxDescription.Text    = string.Empty;
                this.tbxAttachmentDate.Text = DateTime.Now.ToString("dd.MM.yyyy");

                this.ddlAttachmentType.SelectedValue = Constants.INVALID_ID_STRING;

                this.hdnRowMasterKey.Value = string.Empty;
            }
        }