protected void LoadAttributes()
        {
            string docCategoryName = "", docTypeName = "", docSourceName = "", docFileType = "";



            if (doc.DocCategoryId > 0)
            {
                DocCategoryEnt docCategory = new DocCategoryEnt();
                try
                {
                    docCategory.Load(doc.DocCategoryId);
                    docCategoryName = docCategory.Name;
                }
                catch (BipObjectNotFoundException)
                {
                    docCategoryName = "";
                }
                docCategory.Dispose();
            }



            if (doc.DocTypeId > 0)
            {
                DocTypeEnt docType = new DocTypeEnt();
                try
                {
                    docType.Load(doc.DocTypeId);
                    docTypeName = docType.Name;
                }
                catch (BipObjectNotFoundException)
                {
                    docTypeName = "";
                }
                docType.Dispose();
            }

            if (doc.DocSourceId > 0)
            {
                DocSourceEnt docSource = new DocSourceEnt();
                try
                {
                    docSource.Load(doc.DocSourceId);
                    docSourceName = docSource.Name;
                }
                catch (BipObjectNotFoundException)
                {
                    docSourceName = "";
                }
                docSource.Dispose();
            }
            if (doc.FileTypeId > 0)
            {
                docFileType = DocFileType.GetTypeName(doc.FileTypeId);
            }



            lblDocCategory.Text = docCategoryName;
            lblDocType.Text     = docTypeName;
            lblDocSource.Text   = docSourceName;
            lblFileType.Text    = docFileType;

            if (doc.IsPublic)
            {
                lblIsPublic.Text = "Yes";
            }
            else
            {
                lblIsPublic.Text = "No";
            }

            lblDateReceived.Text     = Utils.DateToText(doc.DateReceived);
            lblDocumentDate.Text     = Utils.DateToText(doc.DocumentDate);
            lblIncomingNumber.Text   = doc.IncomingNumber;
            lblOutgoingNumber.Text   = doc.OutgoingNumber;
            lblSubject.Text          = doc.Subject;
            lblHeader.Text           = doc.Header;
            lblFileName.Text         = doc.FileName;
            lblArchiveFileNames.Text = doc.ArchiveFileNames;
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (!DocumentTransaction.IsActive())
                {
                    throw new BipFatalException();
                }

                doc = DocumentTransaction.Current.Document;

                if (Request["btnCancel"] != null)
                {
                    DocumentTransaction.End();
                    Response.Redirect("~/CloseWindow.html");
                    return;
                }


                if (Page.IsPostBack == false)
                {
                    if (doc.Id < 1)
                    {
                        PanExistingDocAttrs.Visible = false;
                        btnBack.Text  = "< " + BipResources.GetString("StrBtnBackCaption");
                        btnBack.Width = new Unit("100px");
                    }

                    LoadDropDownList(ddlDocCategory, DocCategoryEnt.FindAll());
                    LoadDropDownList(ddlDocType, DocTypeEnt.FindAll());
                    LoadDropDownList(ddlDocSource, DocSourceEnt.FindAll());

                    dlGroups.DataSource = Bip.Components.GroupEnt.FindAll();
                    dlGroups.DataBind();


                    LoadAttributes();
                }

                // ParentDocID ---------------------------------
                if (Page.IsPostBack == false ||
                    Request["_BIP_ACTION"] == "SelectParentDoc")
                {
                    if (Request["_BIP_ACTION"] == "SelectParentDoc")
                    {
                        doc.ParentId = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
                    }
                    ShowParentDocLink(doc);
                }

                // PreviousVersionDocID ---------------------------------
                if (Page.IsPostBack == false ||
                    Request["_BIP_ACTION"] == "SelectPreviousVersionDoc")
                {
                    if (Request["_BIP_ACTION"] == "SelectPreviousVersionDoc")
                    {
                        doc.PreviousVersionId = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
                    }
                    ShowPreviousVersionDocLink(doc);
                }

                // RelatedDocs ---------------------------------
                if (Page.IsPostBack == false ||
                    Request["_BIP_ACTION"] == "AddRelatedDoc" ||
                    Request["_BIP_ACTION"] == "RemoveRelatedDoc")
                {
                    if (Request["_BIP_ACTION"] == "AddRelatedDoc" ||
                        Request["_BIP_ACTION"] == "RemoveRelatedDoc")
                    {
                        ArrayList docEnum = new ArrayList();
                        if (doc.RefDocuments != null)
                        {
                            foreach (int ids in doc.RefDocuments)
                            {
                                docEnum.Add(ids);
                            }
                        }

                        int id = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
                        if (Request["_BIP_ACTION"] == "AddRelatedDoc")
                        {
                            if (docEnum.IndexOf(id) == -1)
                            {
                                docEnum.Add(id);
                            }
                        }
                        else
                        {
                            docEnum.Remove(id);
                        }

                        doc.RefDocuments = docEnum;
                    }

                    grdDocRefRelated.DataSource = DocumentEnt.FindEnum(doc.RefDocuments);
                    grdDocRefRelated.DataBind();
                }

                string s1, s2;
                bool   showInBrowser = false;
                DocFileType.GetTypeInfo(doc.FileTypeId, out s1, out s2, out showInBrowser);
                btnShowHidePreview.Visible = showInBrowser;
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }