/// <summary> Constructor for a new instance of the Groups_Needed_Serial_Hierarchy_Form class </summary>
        public Groups_Needed_Serial_Hierarchy_Form()
        {
            InitializeComponent();
            BackColor = Color.FromArgb(240, 240, 240);

            DataTable sourceTable = SobekCM_Database.Newspapers_Without_Serial_Info;

            iconPanel = new CustomGrid_Panel();
            iconPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom)
                                   | AnchorStyles.Left)
                                  | AnchorStyles.Right)));
            iconPanel.BorderStyle = BorderStyle.FixedSingle;
            iconPanel.DataTable = null;
            iconPanel.Location = new Point(16, 16);
            iconPanel.Name = "itemGridPanel";
            iconPanel.Size = new Size(mainPanel.Width - 32, mainPanel.Height - 32);
            iconPanel.TabIndex = 0;
            iconPanel.Double_Clicked += iconPanel_Double_Clicked;

            mainPanel.Controls.Add(iconPanel);

            // Configure some table level style settings
            iconPanel.Style.Default_Column_Width = 85;
            iconPanel.Style.Default_Column_Color = Color.LightBlue;
            iconPanel.Style.Header_Back_Color = Color.SteelBlue;
            iconPanel.Style.Header_Fore_Color = Color.White;

            // Use the table from the database as the data source
            iconPanel.DataTable = sourceTable;

            //// Configure some individual columns
            iconPanel.Style.Column_Styles[1].Header_Text = "Group Title";
            iconPanel.Style.Column_Styles[1].BackColor = Color.White;
            iconPanel.Style.Column_Styles[1].Width = 450;
        }
        /// <summary> Constructor for a DataGridPrinter object which will be used to
        /// print a DataGrid to a printer.  </summary>
        /// <param name="aGrid"> DataGrid whose <see cref="DataGridTableStyle"/> will be used to 
        /// determine the appearance of the printed page.  </param>
        /// <param name="aPrintDocument"> Print document to use while formatting the appearance
        /// of the information on the page </param>
        public CustomGrid_Printer( CustomGrid_Panel aGrid, PrintDocument aPrintDocument )
        {
            // Save the parameters
            TheGrid = aGrid;
            ThePrintDocument = aPrintDocument;

            // Save the default page settings from the print document
            ////			PageWidth = ThePrintDocument.DefaultPageSettings.PaperSize.Width;
            ////			PageHeight = ThePrintDocument.DefaultPageSettings.PaperSize.Height;
            ////			TopMargin = ThePrintDocument.DefaultPageSettings.Margins.Top;
            ////			BottomMargin = ThePrintDocument.DefaultPageSettings.Margins.Bottom;
        }
        /// <summary> Constructor for a new instance of the Ad_Hoc_Report_Display_Form form </summary>
        /// <param name="Display_Set">Set of titles/items to display within this form</param>
        public Ad_Hoc_Report_Display_Form( DataSet Display_Set )
        {
            InitializeComponent();
            BackColor = Color.FromArgb(240, 240, 240);

            displaySet = Display_Set;

            // Check for values at each hierarchical level and author and publisher
            bool hasLevel1Data = false;
            bool hasLevel2Data = false;
            bool hasLevel3Data = false;
            bool hasAuthorData = false;
            bool hasPublisherData = false;
            bool hasDateData = false;

            // Move the date column to the right spot
            Display_Set.Tables[0].Columns["PubDate"].SetOrdinal(8);

            // Get the columns
            DataColumn level1Column = displaySet.Tables[0].Columns["Level1_Text"];
            DataColumn level2Column = displaySet.Tables[0].Columns["Level2_Text"];
            DataColumn level3Column = displaySet.Tables[0].Columns["Level3_Text"];
            DataColumn publisherColumn = displaySet.Tables[0].Columns["Publisher"];
            DataColumn authorColumn = displaySet.Tables[0].Columns["Author"];
            DataColumn dateColumn = displaySet.Tables[0].Columns["PubDate"];

            // Step through each row and check for data existence
            foreach (DataRow thisRow in Display_Set.Tables[0].Rows )
            {
                if ((hasLevel1Data) && (hasLevel2Data) && (hasLevel3Data) && (hasPublisherData) && (hasAuthorData) && ( hasDateData ))
                    break;
                if ((!hasLevel1Data) && (thisRow[level1Column].ToString().Length > 0))
                    hasLevel1Data = true;
                if ((!hasLevel2Data) && (thisRow[level2Column].ToString().Length > 0))
                    hasLevel2Data = true;
                if ((!hasLevel3Data) && (thisRow[level3Column].ToString().Length > 0))
                    hasLevel3Data = true;
                if ((!hasPublisherData) && (thisRow[publisherColumn].ToString().Length > 0))
                    hasPublisherData = true;
                if ((!hasAuthorData) && (thisRow[authorColumn].ToString().Length > 0))
                    hasAuthorData = true;
                if ((!hasDateData) && (thisRow[dateColumn].ToString().Length > 0))
                    hasDateData = true;
            }

            // Create the custom grid
            gridPanel = new CustomGrid_Panel
                            {Size = new Size(panel1.Width - 2, panel1.Height - 2), Location = new Point(0, 0)};

            // Configure some table level style settings
            gridPanel.Style.Default_Column_Width = 80;
            gridPanel.Style.Default_Column_Color = Color.LightBlue;
            gridPanel.Style.Header_Back_Color = Color.DarkBlue;
            gridPanel.Style.Header_Fore_Color = Color.White;

            // Set the background and border style
            gridPanel.BackColor = Color.WhiteSmoke;
            gridPanel.BorderStyle = BorderStyle.FixedSingle;
            gridPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
            panel1.Controls.Add(gridPanel);

            gridPanel.DataTable = displaySet.Tables[0];

            gridPanel.Current_Sort_String = "BibID ASC, VID ASC";

            // Configure for this table
            gridPanel.Style.Column_Styles[1].Width = 50;
            gridPanel.Style.Column_Styles[2].Visible = false;
            gridPanel.Style.Column_Styles[3].Visible = false;
            gridPanel.Style.Column_Styles[4].Visible = false;
            gridPanel.Style.Column_Styles[5].Width = SMaRT_UserSettings.Ad_Hoc_Report_Form_Title_Width;
            gridPanel.Style.Column_Styles[5].BackColor = Color.White;
            gridPanel.Style.Column_Styles[6].BackColor = Color.White;

            if (!hasAuthorData)
                gridPanel.Style.Column_Styles[6].Width = SMaRT_UserSettings.Ad_Hoc_Report_Form_Author_Width;
            else
                gridPanel.Style.Column_Styles[6].Visible = false;

            gridPanel.Style.Column_Styles[7].BackColor = Color.White;
            if (hasPublisherData)
                gridPanel.Style.Column_Styles[7].Width = SMaRT_UserSettings.Ad_Hoc_Report_Form_Publisher_Width;
            else
                gridPanel.Style.Column_Styles[7].Visible = false;

            gridPanel.Style.Column_Styles[8].BackColor = Color.White;
            if (hasDateData)
                gridPanel.Style.Column_Styles[8].Width = SMaRT_UserSettings.Ad_Hoc_Report_Form_Date_Width;
            else
                gridPanel.Style.Column_Styles[8].Visible = false;

            if (hasLevel1Data)
                gridPanel.Style.Column_Styles[9].Width =  SMaRT_UserSettings.Ad_Hoc_Report_Form_Level1_Width;
            else
                gridPanel.Style.Column_Styles[9].Visible = false;

            gridPanel.Style.Column_Styles[9].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[10].Visible = false;
            if (hasLevel2Data)
                gridPanel.Style.Column_Styles[11].Width = SMaRT_UserSettings.Ad_Hoc_Report_Form_Level2_Width;
            else
                gridPanel.Style.Column_Styles[11].Visible = false;
            gridPanel.Style.Column_Styles[11].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[12].Visible = false;
            if (hasLevel3Data)
                gridPanel.Style.Column_Styles[13].Width = SMaRT_UserSettings.Ad_Hoc_Report_Form_Level3_Width;
            else
                gridPanel.Style.Column_Styles[13].Visible = false;
            gridPanel.Style.Column_Styles[13].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[14].Visible = false;
            gridPanel.Style.Column_Styles[15].Visible = false;
            gridPanel.Style.Column_Styles[16].Visible = false;
            gridPanel.Style.Column_Styles[17].Visible = false;
            gridPanel.Style.Column_Styles[18].Visible = false;

            gridPanel.Style.Column_Styles[20].Visible = false;
            gridPanel.Style.Column_Styles[21].Header_Text = "Comments";
            gridPanel.Style.Column_Styles[24].Header_Text = "Digitized";
            gridPanel.Style.Column_Styles[24].Short_Date_Format = true;
            gridPanel.Style.Column_Styles[25].Header_Text = "Processed";
            gridPanel.Style.Column_Styles[25].Short_Date_Format = true;
            gridPanel.Style.Column_Styles[26].Header_Text = "QC'd";
            gridPanel.Style.Column_Styles[26].Short_Date_Format = true;
            gridPanel.Style.Column_Styles[27].Header_Text = "Online";
            gridPanel.Style.Column_Styles[27].Short_Date_Format = true;
            gridPanel.Style.Column_Styles[38].Visible = false;

            // Set some sort values
            gridPanel.Style.Column_Styles[9].Ascending_Sort = "Level1_Index ASC, Level2_Index ASC, Level3_Index ASC";
            gridPanel.Style.Column_Styles[9].Descending_Sort = "Level1_Index DESC, Level2_Index DESC, Level3_Index DESC";
            gridPanel.Style.Column_Styles[11].Ascending_Sort = "Level2_Index ASC, Level3_Index ASC";
            gridPanel.Style.Column_Styles[11].Descending_Sort = "Level2_Index DESC, Level3_Index DESC";
            gridPanel.Style.Column_Styles[5].Ascending_Sort = "SortTitle ASC, Level1_Index ASC, Level2_Index ASC, Level3_Index ASC";
            gridPanel.Style.Column_Styles[5].Descending_Sort = "SortTitle DESC, Level1_Index DESC, Level2_Index DESC, Level3_Index DESC";
            gridPanel.Style.Column_Styles[8].Ascending_Sort = "SortDate ASC, SortTitle ASC, Level1_Index ASC, Level2_Index ASC, Level3_Index ASC";
            gridPanel.Style.Column_Styles[8].Descending_Sort = "SortDate DESC, SortTitle DESC, Level1_Index DESC, Level2_Index DESC, Level3_Index DESC";

            gridPanel.Double_Clicked += gridPanel_Double_Clicked;
            gridPanel.Clipboard_Copy_Requested += new CustomGrid_Panel_Delegate_Multiple(gridPanel_Clipboard_Copy_Requested);

            // Add the context menu
            gridPanel.Set_Context_Menus(null, contextMenu1);

            // Add the object to print
            gridPrinter = new CustomGrid_Printer(gridPanel, printDocument1);

            // Set the hits value
            hitCountLabel.Text = "Your search resulted in " + number_to_string(displaySet.Tables[0].Rows.Count) + " items in " + number_to_string(displaySet.Tables[1].Rows.Count) + " titles";

            // Set the size correctly
            Size = SMaRT_UserSettings.Ad_Hoc_Report_Form_Size;
            int screen_width = Screen.PrimaryScreen.WorkingArea.Width;
            int screen_height = Screen.PrimaryScreen.WorkingArea.Height;
            if ((Width > screen_width) || (Height > screen_height) || (SMaRT_UserSettings.Ad_Hoc_Report_Form_Maximized))
                WindowState = FormWindowState.Maximized;

            // GEt the username
            username = Environment.UserName;

            // Set the action on click
            if (SMaRT_UserSettings.Ad_Hoc_Form_Action_On_Click == View_Items_Form_Action_On_Click_Enum.Open_On_Web)
            {
                openItemFromWebMenuItem.Checked = true;
                viewItemFormMenuItem.Checked = false;
            }
            else
            {
                openItemFromWebMenuItem.Checked = false;
                viewItemFormMenuItem.Checked = true;
            }
        }
        private void Clear_Items( bool clear_search_boxes )
        {
            if ((gridPanel != null) && (mainPanel.Contains(gridPanel)))
            {
                mainPanel.Controls.Remove(gridPanel);
                gridPanel = null;
            }

            displayTable = null;

            // Clear the serach boxes and show instructions
            hitCountLabel.Text = "Select search criteria above and press SEARCH";
            if (clear_search_boxes)
            {
                sobekCM_Item_Discovery_Panel1.Clear_Search_Boxes();
            }
            instructionLabel.Show();

            // Disable the menu items which are no longer applicable
            saveAsMenuItem.Enabled = false;
            printMenuItem.Enabled = false;
            printTrackingSheetsMenuItem.Enabled = false;
            editSerialHierarchyToolStripMenuItem.Enabled = false;
            viewAdHocReportMenuItem.Enabled = false;
            setTrackingBoxToolStripMenuItem.Enabled = false;
            editDispositionAdviceMenuItem.Enabled = false;
            updateItemDispositionMenuItem.Enabled = false;
            addWorklogHistoryEntryMenuItem.Enabled = false;
            updateBornDigitalFlagMenuItem.Enabled = false;
            updateMaterialReceivedDateMenuItem.Enabled = false;
        }
        private void Show_Items(DataSet dataSet, string Code_for_browse)
        {
            database_dataset_to_tracking_bib_table(dataSet);

            if ((displayTable == null) || (displayTable.Rows.Count == 0))
            {
                if (gridPanel != null)
                {
                    mainPanel.Controls.Remove(gridPanel);
                    gridPanel = null;
                }
                Clear_Items(false);
                hitCountLabel.Text = "No Matches Found";
            }
            else
            {
                instructionLabel.Hide();
                if (gridPanel == null)
                {
                    gridPanel = new CustomGrid_Panel
                                    {
                                        Size = new Size(mainPanel.Width - 2, mainPanel.Height - 2),
                                        Location = new Point(0, 0)
                                    };

                    // Configure some table level style settings
                    gridPanel.Style.Default_Column_Width = 80;
                    gridPanel.Style.Default_Column_Color = Color.LightBlue;
                    gridPanel.Style.Header_Back_Color = Color.DarkBlue;
                    gridPanel.Style.Header_Fore_Color = Color.White;

                    //// initial the sort option
                    //if (this.Current_Sort_String.Length == 0)
                    //    this.Current_Sort_String = "BibID ASC";// Use the table from the database as the data source
                    //this.DataTable = sourceTable;

                    // Set the background and border style
                    gridPanel.BackColor = Color.WhiteSmoke;
                    gridPanel.BorderStyle = BorderStyle.FixedSingle;
                    gridPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
                    mainPanel.Controls.Add(gridPanel);

                    // Add the event to the grid panel
                    gridPanel.Double_Clicked += gridPanel_Double_Clicked;
                    gridPanel.Clipboard_Copy_Requested +=new CustomGrid_Panel_Delegate_Multiple(gridPanel_Clipboard_Copy_Requested);

                    // Add the context menu
                    gridPanel.Set_Context_Menus(null, contextMenu1);

                    // Add the object to print
                    gridPrinter = new CustomGrid_Printer(gridPanel, printDocument1);
                }
                else
                {
                    // Save the column sizes
                    SMaRT_UserSettings.Discovery_Form_Title_Width = gridPanel.Style.Column_Styles[5].Width;
                    SMaRT_UserSettings.Discovery_Form_Author_Width = gridPanel.Style.Column_Styles[6].Width;
                    SMaRT_UserSettings.Discovery_Form_Publisher_Width = gridPanel.Style.Column_Styles[7].Width;
                }

                gridPanel.DataTable = displayTable;

                gridPanel.Current_Sort_String = "BibID ASC";

                // Configure for this table
                gridPanel.Style.Primary_Key_Column = 0;
                gridPanel.Style.Column_Styles[0].Visible = false;
                gridPanel.Style.Column_Styles[1].Fixed_Print_Width = 100;
                gridPanel.Style.Column_Styles[2].Width = 85;
                gridPanel.Style.Column_Styles[2].Fixed_Print_Width = 65;
                gridPanel.Style.Column_Styles[3].Fixed_Print_Width = 100;
                gridPanel.Style.Column_Styles[4].Fixed_Print_Width = 100;
                gridPanel.Style.Column_Styles[5].Width = SMaRT_UserSettings.Discovery_Form_Title_Width;
                gridPanel.Style.Column_Styles[5].Text_Alignment = HorizontalAlignment.Left;
                gridPanel.Style.Column_Styles[5].BackColor = Color.White;
                gridPanel.Style.Column_Styles[6].Width = SMaRT_UserSettings.Discovery_Form_Author_Width;
                gridPanel.Style.Column_Styles[6].Text_Alignment = HorizontalAlignment.Left;
                gridPanel.Style.Column_Styles[6].BackColor = Color.White;
                gridPanel.Style.Column_Styles[7].Width = SMaRT_UserSettings.Discovery_Form_Publisher_Width;
                gridPanel.Style.Column_Styles[7].Text_Alignment = HorizontalAlignment.Left;
                gridPanel.Style.Column_Styles[7].BackColor = Color.White;
                gridPanel.Style.Column_Styles[8].Width = 100;
                gridPanel.Style.Column_Styles[9].Width = 120;
                gridPanel.Style.Column_Styles[10].Visible = false;
                gridPanel.Style.Column_Styles[11].Visible = false;

                gridPanel.Style.Column_Styles[3].Ascending_Sort = "ALEPH ASC, BibID ASC";
                gridPanel.Style.Column_Styles[3].Descending_Sort = "ALEPH DESC, BibID DESC";

                gridPanel.Style.Column_Styles[4].Ascending_Sort = "OCLC ASC, BibID ASC";
                gridPanel.Style.Column_Styles[4].Descending_Sort = "OCLC DESC, BibID DESC";

                gridPanel.Style.Column_Styles[5].Ascending_Sort = "SortTitle ASC, BibID ASC";
                gridPanel.Style.Column_Styles[5].Descending_Sort = "SortTitle DESC, BibID DESC";

                gridPanel.Style.Column_Styles[8].Ascending_Sort = "Material_Type ASC, BibID ASC";
                gridPanel.Style.Column_Styles[8].Descending_Sort = "Material_Type DESC, BibID DESC";

                gridPanel.Style.Column_Styles[9].Ascending_Sort = "Aggregations ASC, BibID ASC";
                gridPanel.Style.Column_Styles[9].Descending_Sort = "Aggregations DESC, BibID DESC";

                if (Code_for_browse.Length > 0)
                {
                    switch (displayTable.Rows.Count)
                    {
                        case 1: hitCountLabel.Text = "Your browse resulted in one matching title"; break;
                        default: hitCountLabel.Text = "Your browse resulted in " + number_to_string(displayTable.Rows.Count) + " matching titles"; break;
                    }
                }
                else
                {
                    hitCountLabel.Text = "Your search resulted in " + number_to_string(itemCount) + " items in " + number_to_string(titleCount) + " titles";
                }

                // Determine if any ALEPH, OCLC, AUTHOR, or PUBLISHER data is present
                bool checkingAleph = true;
                bool checkingOclc = true;
                bool checkingAuthor = true;
                bool checkingPublisher = true;
                DataColumn alephColumn = displayTable.Columns["Aleph"];
                DataColumn oclcColumn = displayTable.Columns["OCLC"];
                DataColumn authorColumn = displayTable.Columns["Author"];
                DataColumn publisherColumn = displayTable.Columns["Publisher"];
                foreach (DataRow thisRow in displayTable.Rows)
                {
                    if (checkingAleph)
                    {
                        if (thisRow[alephColumn].ToString().Trim().Length > 0)
                        {
                            checkingAleph = false;
                        }
                    }

                    if (checkingOclc)
                    {
                        if (thisRow[oclcColumn].ToString().Trim().Length > 0)
                        {
                            checkingOclc = false;
                        }
                    }

                    if (checkingAuthor)
                    {
                        if (thisRow[authorColumn].ToString().Trim().Length > 0)
                        {
                            checkingAuthor = false;
                        }
                    }

                    if (checkingPublisher)
                    {
                        if (thisRow[publisherColumn].ToString().Trim().Length > 0)
                        {
                            checkingPublisher = false;
                        }
                    }

                    if ((!checkingAleph) && (!checkingAuthor) && (!checkingOclc) && (!checkingPublisher))
                        break;
                }

                // Set the visibility of the columns based on the data
                gridPanel.Style.Column_Styles[3].Visible = !checkingAleph;
                gridPanel.Style.Column_Styles[4].Visible = !checkingOclc;
                gridPanel.Style.Column_Styles[6].Visible = !checkingAuthor;
                gridPanel.Style.Column_Styles[7].Visible = !checkingPublisher;

                // Enable the menu items which are now applicable
                saveAsMenuItem.Enabled = true;
                printMenuItem.Enabled = true;
                printTrackingSheetsMenuItem.Enabled = true;
                editSerialHierarchyToolStripMenuItem.Enabled = true;
                viewAdHocReportMenuItem.Enabled = true;
                setTrackingBoxToolStripMenuItem.Enabled = true;
                editDispositionAdviceMenuItem.Enabled = true;
                updateItemDispositionMenuItem.Enabled = true;
                addWorklogHistoryEntryMenuItem.Enabled = true;
                updateBornDigitalFlagMenuItem.Enabled = true;
                updateMaterialReceivedDateMenuItem.Enabled = true;

                // Now, some final code if there was only one result
                if ((displayTable.Rows.Count == 1) && (SMaRT_UserSettings.Item_Discovery_Form_Single_Result_Action == Single_Result_Action_Enum.Show_Details_For_Single_Item))
                {
                    // What is the currently selected action?
                    if (openItemGroupOnWebMenuItem.Checked)
                    {
                        string bibid = displayTable.Rows[0]["BibID"].ToString();
                        string vid = displayTable.Rows[0]["VID"].ToString();
                        string url = SobekCM_Library_Settings.System_Base_URL+ bibid;
                        if (vid.IndexOf("(") < 0)
                        {
                            url = url + "/" + vid;
                        }

                        try
                        {
                            Process openOnWeb = new Process {StartInfo = {FileName = url}};
                            openOnWeb.Start();
                        }
                        catch
                        {
                            MessageBox.Show("Error opening item group from the web.     ", "Browser Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        // Save the current size
                        SMaRT_UserSettings.Item_Discovery_Form_Size = Size;
                        SMaRT_UserSettings.Save();

                        // Now, show the row
                        View_Item_Group_Form showForm = new View_Item_Group_Form(displayTable.Rows[0]);
                        Hide();
                        showForm.ShowDialog();
                        Show();
                    }
                }

                gridPanel.ReDraw();
                gridPanel.Focus();
            }
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Results_Form));
     this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
     this.menuItem1 = new System.Windows.Forms.MenuItem();
     this.setupMenuItem = new System.Windows.Forms.MenuItem();
     this.previewMenuItem = new System.Windows.Forms.MenuItem();
     this.printMenuItem = new System.Windows.Forms.MenuItem();
     this.menuItem5 = new System.Windows.Forms.MenuItem();
     this.saveMenuItem = new System.Windows.Forms.MenuItem();
     this.exitMenuItem = new System.Windows.Forms.MenuItem();
     this.actionMenuItem = new System.Windows.Forms.MenuItem();
     this.detailsMenuItem = new System.Windows.Forms.MenuItem();
     this.helpMenuItem = new System.Windows.Forms.MenuItem();
     this.aboutMenuItem = new System.Windows.Forms.MenuItem();
     this.detailsMenuItem_ContextMenuItem = new System.Windows.Forms.MenuItem();
     this.commentsMenuItem_ContextMenuItem = new System.Windows.Forms.MenuItem();
     this.actionMI_ShowDetails = new System.Windows.Forms.MenuItem();
     this.contextMenu1 = new System.Windows.Forms.ContextMenu();
     this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
     this.printDocument1 = new System.Drawing.Printing.PrintDocument();
     this.printDialog1 = new System.Windows.Forms.PrintDialog();
     this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
     this.imageList1 = new System.Windows.Forms.ImageList(this.components);
     this.customGrid_Panel1 = new CustomGrid_Panel();
     this.closeButton = new System.Windows.Forms.Button();
     this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
     this.printButton = new System.Windows.Forms.Button();
     this.saveButton = new System.Windows.Forms.Button();
     this.SuspendLayout();
     //
     // mainMenu1
     //
     this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.menuItem1,
     this.actionMenuItem,
     this.helpMenuItem});
     //
     // menuItem1
     //
     this.menuItem1.Index = 0;
     this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.setupMenuItem,
     this.previewMenuItem,
     this.printMenuItem,
     this.menuItem5,
     this.saveMenuItem,
     this.exitMenuItem});
     this.menuItem1.Text = "File";
     //
     // setupMenuItem
     //
     this.setupMenuItem.Index = 0;
     this.setupMenuItem.OwnerDraw = true;
     this.setupMenuItem.Text = "Page Setup";
     this.setupMenuItem.Click += new System.EventHandler(this.setupMenuItem_Click);
     //
     // previewMenuItem
     //
     this.previewMenuItem.Index = 1;
     this.previewMenuItem.OwnerDraw = true;
     this.previewMenuItem.Text = "Print Preview";
     this.previewMenuItem.Click += new System.EventHandler(this.previewMenuItem_Click);
     //
     // printMenuItem
     //
     this.printMenuItem.Index = 2;
     this.printMenuItem.OwnerDraw = true;
     this.printMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
     this.printMenuItem.Text = "Print";
     this.printMenuItem.Click += new System.EventHandler(this.printMenuItem_Click);
     //
     // menuItem5
     //
     this.menuItem5.Index = 3;
     this.menuItem5.OwnerDraw = true;
     this.menuItem5.Text = "-";
     //
     // saveMenuItem
     //
     this.saveMenuItem.Index = 4;
     this.saveMenuItem.OwnerDraw = true;
     this.saveMenuItem.Text = "Save";
     this.saveMenuItem.Click += new System.EventHandler(this.saveMenuItem_Click);
     //
     // exitMenuItem
     //
     this.exitMenuItem.Index = 5;
     this.exitMenuItem.OwnerDraw = true;
     this.exitMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
     this.exitMenuItem.Text = "Close";
     this.exitMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click);
     //
     // actionMenuItem
     //
     this.actionMenuItem.Index = 1;
     this.actionMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.detailsMenuItem});
     this.actionMenuItem.Text = "Action";
     //
     // detailsMenuItem
     //
     this.detailsMenuItem.Index = 0;
     this.detailsMenuItem.OwnerDraw = true;
     this.detailsMenuItem.Text = "Show MARC";
     this.detailsMenuItem.Click += new System.EventHandler(this.detailsMenuItem_Click);
     //
     // helpMenuItem
     //
     this.helpMenuItem.Index = 2;
     this.helpMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.aboutMenuItem});
     this.helpMenuItem.Text = "Help";
     //
     // aboutMenuItem
     //
     this.aboutMenuItem.Index = 0;
     this.aboutMenuItem.OwnerDraw = true;
     this.aboutMenuItem.Text = "About";
     //
     // detailsMenuItem_ContextMenuItem
     //
     this.detailsMenuItem_ContextMenuItem.Index = 0;
     this.detailsMenuItem_ContextMenuItem.OwnerDraw = true;
     this.detailsMenuItem_ContextMenuItem.Text = "Show MARC";
     this.detailsMenuItem_ContextMenuItem.Click += new System.EventHandler(this.detailsMenuItem_Click);
     //
     // commentsMenuItem_ContextMenuItem
     //
     this.commentsMenuItem_ContextMenuItem.Index = 0;
     this.commentsMenuItem_ContextMenuItem.OwnerDraw = true;
     this.commentsMenuItem_ContextMenuItem.Text = "Show Comments";
     this.commentsMenuItem_ContextMenuItem.Click += new System.EventHandler(this.commentsMenuItem_Click);
     //
     // actionMI_ShowDetails
     //
     this.actionMI_ShowDetails.Index = -1;
     this.actionMI_ShowDetails.OwnerDraw = true;
     this.actionMI_ShowDetails.Text = "";
     //
     // contextMenu1
     //
     this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.detailsMenuItem_ContextMenuItem,
     this.commentsMenuItem_ContextMenuItem});
     //
     // printPreviewDialog1
     //
     this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
     this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
     this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
     this.printPreviewDialog1.Document = this.printDocument1;
     this.printPreviewDialog1.Enabled = true;
     this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
     this.printPreviewDialog1.Name = "printPreviewDialog1";
     this.printPreviewDialog1.Visible = false;
     //
     // printDocument1
     //
     this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
     //
     // printDialog1
     //
     this.printDialog1.Document = this.printDocument1;
     //
     // pageSetupDialog1
     //
     this.pageSetupDialog1.Document = this.printDocument1;
     //
     // imageList1
     //
     this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
     this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
     this.imageList1.Images.SetKeyName(0, "");
     this.imageList1.Images.SetKeyName(1, "");
     this.imageList1.Images.SetKeyName(2, "");
     this.imageList1.Images.SetKeyName(3, "");
     this.imageList1.Images.SetKeyName(4, "");
     //
     // customGrid_Panel1
     //
     this.customGrid_Panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                 | System.Windows.Forms.AnchorStyles.Left)
                 | System.Windows.Forms.AnchorStyles.Right)));
     this.customGrid_Panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.customGrid_Panel1.Current_Sort_String = "";
     this.customGrid_Panel1.DataTable = null;
     this.customGrid_Panel1.Location = new System.Drawing.Point(8, 0);
     this.customGrid_Panel1.Name = "customGrid_Panel1";
     this.customGrid_Panel1.Size = new System.Drawing.Size(776, 600);
     this.customGrid_Panel1.TabIndex = 0;
     //
     // closeButton
     //
     this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.closeButton.Location = new System.Drawing.Point(704, 608);
     this.closeButton.Name = "closeButton";
     this.closeButton.Size = new System.Drawing.Size(75, 23);
     this.closeButton.TabIndex = 1;
     this.closeButton.Text = "EXIT";
     this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
     //
     // saveFileDialog1
     //
     this.saveFileDialog1.Filter = "Comma-seperated Values File (*.csv)|*.csv|Tab-delimited Text File (*.txt)|*.txt|E" +
         "xcel Spreadsheet (*.xls)|*.xls";
     this.saveFileDialog1.FilterIndex = 3;
     this.saveFileDialog1.Title = "Save As";
     //
     // printButton
     //
     this.printButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     this.printButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.printButton.ImageIndex = 2;
     this.printButton.ImageList = this.imageList1;
     this.printButton.Location = new System.Drawing.Point(113, 608);
     this.printButton.Name = "printButton";
     this.printButton.Size = new System.Drawing.Size(80, 23);
     this.printButton.TabIndex = 3;
     this.printButton.Text = "    Print";
     this.printButton.Click += new System.EventHandler(this.printButton_Click);
     //
     // saveButton
     //
     this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     this.saveButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.saveButton.ImageIndex = 3;
     this.saveButton.ImageList = this.imageList1;
     this.saveButton.Location = new System.Drawing.Point(17, 608);
     this.saveButton.Name = "saveButton";
     this.saveButton.Size = new System.Drawing.Size(80, 23);
     this.saveButton.TabIndex = 4;
     this.saveButton.Text = "    Save";
     this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
     //
     // Results_Form
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
     this.BackColor = System.Drawing.SystemColors.Control;
     this.ClientSize = new System.Drawing.Size(792, 641);
     this.Controls.Add(this.saveButton);
     this.Controls.Add(this.printButton);
     this.Controls.Add(this.closeButton);
     this.Controls.Add(this.customGrid_Panel1);
     this.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Menu = this.mainMenu1;
     this.Name = "Results_Form";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Text = "DLC Importer - Results Form";
     this.ResumeLayout(false);
 }
        private void show_milestones_worklog()
        {
            // Pull the tracking information
            trackingInfo = SobekCM_Database.Tracking_Get_History_Archives(itemid, null);

            // Pull out the standard tracking milestones
            trackingInfoObj = new Tracking_Info();
            trackingInfoObj.Set_Tracking_Info(trackingInfo);
            if (trackingInfoObj.Digital_Acquisition_Milestone.HasValue)
                acquisitionLabel.Text = trackingInfoObj.Digital_Acquisition_Milestone.Value.ToShortDateString();
            if (trackingInfoObj.Image_Processing_Milestone.HasValue)
                imageProcessingLabel.Text = trackingInfoObj.Image_Processing_Milestone.Value.ToShortDateString();
            if (trackingInfoObj.Quality_Control_Milestone.HasValue)
                qcLabel.Text = trackingInfoObj.Quality_Control_Milestone.Value.ToShortDateString();
            if (trackingInfoObj.Online_Complete_Milestone.HasValue)
                onlineCompleteLabel.Text = trackingInfoObj.Online_Complete_Milestone.Value.ToShortDateString();

            if (trackingInfoObj.Born_Digital)
            {
                if (trackingInfoObj.Material_Received_Date.HasValue)
                {
                    if (trackingInfoObj.Material_Rec_Date_Estimated)
                    {
                        receivedLabel.Text = trackingInfoObj.Material_Received_Date.Value.ToShortDateString() + " (estimated - Born Digital)";
                    }
                    else
                    {
                        receivedLabel.Text = trackingInfoObj.Material_Received_Date.Value.ToShortDateString() + " (Born Digital)";
                    }
                }
                else
                {
                    receivedLabel.Text = "Born Digital";
                }
            }
            else
            {
                if (trackingInfoObj.Material_Received_Date.HasValue)
                {
                    if (trackingInfoObj.Material_Rec_Date_Estimated)
                    {
                        receivedLabel.Text = trackingInfoObj.Material_Received_Date.Value.ToShortDateString() + " (estimated)";
                    }
                    else
                    {
                        receivedLabel.Text = trackingInfoObj.Material_Received_Date.Value.ToShortDateString();
                    }
                }
            }
            if (trackingInfoObj.Disposition_Date.HasValue)
            {
                adviceLinkLabel.Hide();
                adviceLabel.Show();
                dispositionLabel.Show();
                dispositionLinkLabel.Hide();
                string disposition = SobekCM_Library_Settings.Disposition_Term_Past(trackingInfoObj.Disposition_Type).ToUpper();
                if (trackingInfoObj.Disposition_Notes.Trim().Length > 0)
                {
                    dispositionLabel.Text = disposition + " " + trackingInfoObj.Disposition_Date.Value.ToShortDateString() + " - " + trackingInfoObj.Disposition_Notes;
                }
                else
                {
                    dispositionLabel.Text = disposition + " " + trackingInfoObj.Disposition_Date.Value.ToShortDateString();
                }
            }
            else
            {
                adviceLabel.Hide();
                adviceLinkLabel.Show();
                dispositionLabel.Hide();
                dispositionLinkLabel.Show();
            }

            if (trackingInfoObj.Disposition_Advice > 0)
            {
                string disposition = SobekCM_Library_Settings.Disposition_Term_Future(trackingInfoObj.Disposition_Advice).ToUpper();
                if (trackingInfoObj.Disposition_Advice_Notes.Trim().Length > 0)
                {
                    adviceLinkLabel.Text = disposition + " - " + trackingInfoObj.Disposition_Advice_Notes;
                    adviceLabel.Text = disposition + " - " + trackingInfoObj.Disposition_Advice_Notes;
                }
                else
                {
                    adviceLinkLabel.Text = disposition;
                    adviceLabel.Text = disposition;
                }
            }

            if ((!trackingInfoObj.Locally_Archived) && (!trackingInfoObj.Remotely_Archived))
            {
                archivingLabel1.Text = "NOT ARCHIVED";
                archivingLabel2.Text = String.Empty;
            }
            else
            {
                if (trackingInfoObj.Locally_Archived)
                {
                    archivingLabel1.Text = "Locally Stored on CD or Tape";
                    archivingLabel2.Text = trackingInfoObj.Remotely_Archived ? "Archived Remotely (FDA)" : String.Empty;
                }
                else
                {
                    archivingLabel1.Text = "Archived Remotely (FDA)";
                    archivingLabel2.Text = String.Empty;
                }
            }
            if (trackingInfoObj.Tracking_Box.Length > 0)
            {
                trackingBoxLabel.Text = trackingInfoObj.Tracking_Box;
            }

            // Show the history table
            if (historyPanel == null)
            {
                historyPanel = new CustomGrid_Panel
                                   {
                                       Size = new Size(historyTabPage.Width - 20, historyTabPage.Height - 20),
                                       Location = new Point(10, 10)
                                   };
                historyPanel.Style.Default_Column_Width = 80;
                historyPanel.Style.Default_Column_Color = Color.LightBlue;
                historyPanel.Style.Header_Back_Color = Color.DarkBlue;
                historyPanel.Style.Header_Fore_Color = Color.White;
                historyPanel.BackColor = Color.White;
                historyPanel.BorderStyle = BorderStyle.FixedSingle;
                historyPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
                historyTabPage.Controls.Add(historyPanel);
            }

            historyPanel.DataTable = trackingInfo.Tables[1];
            historyPanel.Style.Column_Styles[0].Visible = false;
            historyPanel.Style.Column_Styles[1].BackColor = Color.White;
            historyPanel.Style.Column_Styles[1].Width = 150;
            historyPanel.Style.Column_Styles[2].Width = 80;
            historyPanel.Style.Column_Styles[2].Header_Text = "Completed";
            historyPanel.Style.Column_Styles[3].Header_Text = "User";
            historyPanel.Style.Column_Styles[3].Width = 100;
            historyPanel.Style.Column_Styles[4].Header_Text = "Location";
            historyPanel.Style.Column_Styles[5].Width = 200;
        }
        /// <summary> Constructor for a new instance of the View_Item_Form form </summary>
        /// <param name="ItemID"> Primary key for this item in the SobekCM database </param>
        /// <param name="BibID"> Bibliographic identifier for the title related to this item </param>
        /// <param name="VID"> Volume identifier for this item within the title </param>
        public View_Item_Form( int ItemID, string BibID, string VID )
        {
            InitializeComponent();
            BackColor = Color.FromArgb(240, 240, 240);

            bibid = BibID;
            vid = VID;
            itemid = ItemID;

            mainLinkLabel.Text = BibID + ":" + VID;

            show_milestones_worklog();

            // Show the media table
            if (trackingInfo.Tables[0].Rows.Count > 0)
            {
                mediaPanel = new CustomGrid_Panel
                                 {
                                     Size = new Size(mediaTabPage.Width - 20, mediaTabPage.Height - 20),
                                     Location = new Point(10, 10)
                                 };
                mediaPanel.Style.Default_Column_Width = 80;
                mediaPanel.Style.Default_Column_Color = Color.LightBlue;
                mediaPanel.Style.Header_Back_Color = Color.DarkBlue;
                mediaPanel.Style.Header_Fore_Color = Color.White;
                mediaPanel.BackColor = Color.White;
                mediaPanel.BorderStyle = BorderStyle.FixedSingle;
                mediaPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
                mediaTabPage.Controls.Add(mediaPanel);
                mediaPanel.DataTable = trackingInfo.Tables[0];
                mediaPanel.Style.Column_Styles[1].Width = 400;
                mediaPanel.Style.Column_Styles[1].BackColor = Color.White;
                mediaPanel.Style.Column_Styles[2].Width = 70;
                mediaPanel.Style.Column_Styles[3].Width = 70;
                mediaPanel.Style.Column_Styles[4].Width = 90;
            }
            else
            {
                tabControl1.TabPages.Remove(mediaTabPage);
            }

            // Show the archives table
            if (trackingInfo.Tables[2].Rows.Count > 0)
            {
                archivePanel = new CustomGrid_Panel
                                   {
                                       Size = new Size(archiveTabPage.Width - 20, archiveTabPage.Height - 20),
                                       Location = new Point(10, 10)
                                   };
                archivePanel.Style.Default_Column_Width = 80;
                archivePanel.Style.Default_Column_Color = Color.LightBlue;
                archivePanel.Style.Header_Back_Color = Color.DarkBlue;
                archivePanel.Style.Header_Fore_Color = Color.White;
                archivePanel.BackColor = Color.White;
                archivePanel.BorderStyle = BorderStyle.FixedSingle;
                archivePanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
                archiveTabPage.Controls.Add(archivePanel);
                archivePanel.DataTable = trackingInfo.Tables[2];
                archivePanel.Style.Column_Styles[0].Visible = false;
                archivePanel.Style.Column_Styles[1].Visible = false;
                archivePanel.Style.Column_Styles[2].Visible = false;
                archivePanel.Style.Column_Styles[3].Width = 300;
                archivePanel.Style.Column_Styles[3].BackColor = Color.White;
                archivePanel.Style.Column_Styles[5].Width = 140;
                archivePanel.Style.Column_Styles[5].Header_Text = "Last Modified";
                archivePanel.Style.Column_Styles[6].Width = 140;
                archivePanel.Style.Column_Styles[6].Header_Text = "Date Archived";
            }
            else
            {
                tabControl1.TabPages.Remove(archiveTabPage);
                archiveRetrieveButton.Button_Enabled = false;
            }

            // Show the aggregation membership
            if (( trackingInfo.Tables.Count > 4 ) && ( trackingInfo.Tables[4].Rows.Count > 0))
            {
                aggrPanel = new CustomGrid_Panel
                                {
                                    Size = new Size(aggregationsTabPage.Width - 20, aggregationsTabPage.Height - 20),
                                    Location = new Point(10, 10)
                                };
                aggrPanel.Style.Default_Column_Width = 80;
                aggrPanel.Style.Default_Column_Color = Color.LightBlue;
                aggrPanel.Style.Header_Back_Color = Color.DarkBlue;
                aggrPanel.Style.Header_Fore_Color = Color.White;
                aggrPanel.BackColor = Color.White;
                aggrPanel.BorderStyle = BorderStyle.FixedSingle;
                aggrPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
                aggregationsTabPage.Controls.Add(aggrPanel);
                aggrPanel.DataTable = trackingInfo.Tables[4];
                aggrPanel.Style.Column_Styles[0].Width = 100;
                aggrPanel.Style.Column_Styles[1].Width = 200;
                aggrPanel.Style.Column_Styles[1].BackColor = Color.White;
                aggrPanel.Style.Column_Styles[2].Width = 200;
                aggrPanel.Style.Column_Styles[2].BackColor = Color.White;
                aggrPanel.Style.Column_Styles[2].Header_Text = "Short Name";
                aggrPanel.Style.Column_Styles[3].Width = 100;
                aggrPanel.Style.Column_Styles[4].Width = 65;
                aggrPanel.Style.Column_Styles[4].Header_Text = "Implied?";
                aggrPanel.Style.Column_Styles[5].Width = 60;
                aggrPanel.Style.Column_Styles[5].Header_Text = "Hidden?";
                aggrPanel.Style.Column_Styles[6].Width = 60;
                aggrPanel.Style.Column_Styles[6].Header_Text = "Active?";
            }
            else
            {
                tabControl1.TabPages.Remove(aggregationsTabPage);
            }

            // Pull the IP restriction, dark info, etc..
            DataRow volumeInfo = trackingInfo.Tables[3].Rows[0];
            titleLabel.Text = volumeInfo["Title"].ToString();

            authorLabel.Text = volumeInfo["Author"].ToString();
            if (authorLabel.Text.Length == 0)
            {
                authorLabel.Text = "( none )";
                authorLabel.ForeColor = Color.Gray;
            }
            publisherLabel.Text = volumeInfo["Publisher"].ToString();
            if (publisherLabel.Text.Length == 0)
            {
                publisherLabel.Text = "( none )";
                publisherLabel.ForeColor = Color.Gray;
            }

            dateLabel.Text = volumeInfo["PubDate"].ToString();
            if (dateLabel.Text.Length == 0)
            {
                dateLabel.Text = "( none )";
                dateLabel.ForeColor = Color.Gray;
            }

            level1Label.Text = volumeInfo["Level1_Text"].ToString();
            if (level1Label.Text.Length == 0)
            {
                level1Label.Text = "( none )";
                level1Label.ForeColor = Color.Gray;
            }

            level2Label.Text = volumeInfo["Level2_Text"].ToString();
            if (level2Label.Text.Length == 0)
            {
                level2Label.Text = "( none )";
                level2Label.ForeColor = Color.Gray;
            }

            level3Label.Text = volumeInfo["Level3_Text"].ToString();
            if (level3Label.Text.Length == 0)
            {
                level3Label.Text = "( none )";
                level3Label.ForeColor = Color.Gray;
            }

            // Set the restriction info
            int restriction = Convert.ToInt16(volumeInfo["IP_Restriction_Mask"]);
            bool dark = Convert.ToBoolean(volumeInfo["Dark"]);

            // Add the directory
            directoryLinkLabel.Text = SobekCM_Library_Settings.Image_Server_Network + bibid.Substring(0, 2) + "\\" + bibid.Substring(2, 2) + "\\" + bibid.Substring(4, 2) + "\\" + bibid.Substring(6, 2) + "\\" + bibid.Substring(8, 2) + "\\" + vid;

            if (dark)
            {
                visibilityPictureBox.Image = imageList1.Images[3];
            }
            else
            {
                if (restriction < 0)
                {
                    visibilityPictureBox.Image = imageList1.Images[0];
                }
                else
                {
                    visibilityPictureBox.Image = restriction == 0 ? imageList1.Images[2] : imageList1.Images[1];
                }
            }

            // Set the form size correctly
            Size = SMaRT_UserSettings.View_Item_Form_Size;
            int screen_width = Screen.PrimaryScreen.WorkingArea.Width;
            int screen_height = Screen.PrimaryScreen.WorkingArea.Height;
            if ((Width > screen_width) || (Height > screen_height) || ( SMaRT_UserSettings.View_Item_Form_Maximized ))
                WindowState = FormWindowState.Maximized;

            if (!Windows_Appearance_Checker.is_XP_Theme)
            {
                titleLabel.BackColor = SystemColors.Control;
                authorLabel.BackColor = SystemColors.Control;
                publisherLabel.BackColor = SystemColors.Control;
                dateLabel.BackColor = SystemColors.Control;
                level1Label.BackColor = SystemColors.Control;
                level2Label.BackColor = SystemColors.Control;
                level3Label.BackColor = SystemColors.Control;

            }
        }
        /// <summary> Constructor for a new instance of the Items_Pending_Online_Complete_Form form </summary>
        public Items_Pending_Online_Complete_Form()
        {
            InitializeComponent();
            BackColor = Color.FromArgb(240, 240, 240);

            DataTable sourceTable = SobekCM_Database.Items_Pending_Online_Complete;

            // Add two columns
            DataColumn accessColumn = sourceTable.Columns.Add("Access");
            DataColumn aggregationColumn = sourceTable.Columns["AggregationCodes"];
            DataColumn restrictionColumn = sourceTable.Columns["IP_Restriction_Mask"];
            foreach (DataRow thisRow in sourceTable.Rows)
            {
                thisRow[aggregationColumn] = thisRow[aggregationColumn].ToString().Trim().Replace("  ", " ").Replace(" ", ",");

                int access = Convert.ToInt16(thisRow[restrictionColumn]);
                if (access < 0)
                    thisRow[accessColumn] = "private";
                if (access == 0)
                    thisRow[accessColumn] = "public";
                if (access > 0)
                    thisRow[accessColumn] = "restricted";
            }

            iconPanel = new CustomGrid_Panel
                            {
                                Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom)
                                             | AnchorStyles.Left)
                                            | AnchorStyles.Right))),
                                BorderStyle = BorderStyle.FixedSingle,
                                DataTable = null,
                                Location = new Point(16, 16),
                                Name = "itemGridPanel",
                                Size = new Size(mainPanel.Width - 32, mainPanel.Height - 32),
                                TabIndex = 0
                            };
            iconPanel.Double_Clicked += iconPanel_Double_Clicked;

            mainPanel.Controls.Add(iconPanel);

            // Configure some table level style settings
            iconPanel.Style.Default_Column_Width = 85;
            iconPanel.Style.Default_Column_Color = Color.LightBlue;
            iconPanel.Style.Header_Back_Color = Color.SteelBlue;
            iconPanel.Style.Header_Fore_Color = Color.White;

            // Use the table from the database as the data source
            iconPanel.DataTable = sourceTable;

            ////// Configure some individual columns
            iconPanel.Style.Column_Styles[1].Width = 50;
            iconPanel.Style.Column_Styles[2].Width = 150;
            iconPanel.Style.Column_Styles[2].Header_Text = "QC Milestone";
            iconPanel.Style.Column_Styles[3].Visible = false;
            iconPanel.Style.Column_Styles[4].Visible = false;
            iconPanel.Style.Column_Styles[5].Header_Text = "Pages";
            iconPanel.Style.Column_Styles[5].Width = 50;
            iconPanel.Style.Column_Styles[6].Width = 250;
            iconPanel.Style.Column_Styles[6].BackColor = Color.White;
            iconPanel.Style.Column_Styles[7].Width = 100;
            iconPanel.Style.Column_Styles[7].BackColor = Color.White;
            iconPanel.Style.Column_Styles[8].Width = 120;
            iconPanel.Style.Column_Styles[8].Header_Text = "Aggregations";
        }
        private void show_all_volumes()
        {
            SobekCM_Items_In_Title testSet1 = SobekCM_Database.Tracking_Multiple_Volumes(bibid, null);
            if (testSet1 == null) return;

            childTable = testSet1.Item_Table;

            // Create the table to display now
            displayTable = new DataTable("Items");
            DataColumn returnItemIdColumn = displayTable.Columns.Add("ItemID", Type.GetType("System.Int32"));
            DataColumn returnVidColumn = displayTable.Columns.Add("VID");
            DataColumn returnTitleColumn = displayTable.Columns.Add("Volume_Title");
            DataColumn returnAuthorColumn = displayTable.Columns.Add("Author");
            DataColumn returnPublisherColumn = displayTable.Columns.Add("Publisher");
            DataColumn returnDateColumn = displayTable.Columns.Add("PubDate");
            DataColumn returnLevel1TextColumn = displayTable.Columns.Add("Level1_Text");
            DataColumn returnLevel1IndexColumn = displayTable.Columns.Add("Level1_Index", Type.GetType("System.Int32"));
            DataColumn returnLevel2TextColumn = displayTable.Columns.Add("Level2_Text");
            DataColumn returnLevel2IndexColumn = displayTable.Columns.Add("Level2_Index", Type.GetType("System.Int32"));
            DataColumn returnLevel3TextColumn = displayTable.Columns.Add("Level3_Text");
            DataColumn returnLevel3IndexColumn = displayTable.Columns.Add("Level3_Index", Type.GetType("System.Int32"));
            DataColumn returnAggregationsColumn = displayTable.Columns.Add("Aggregations");
            DataColumn returnAccessColumn = displayTable.Columns.Add("Access");
            //   DataColumn returnInHandColumn = displayTable.Columns.Add("In_Hand", Type.GetType("System.Boolean"));
            DataColumn returnTrackingBoxColumn = displayTable.Columns.Add("Tracking_Box");
            DataColumn returnMilestoneBoxColumn = displayTable.Columns.Add("Last_Milestone");
            DataColumn returnArchivedColumn = displayTable.Columns.Add("Archived");
            //   DataColumn returnBornDigitalColumn = displayTable.Columns.Add("Born_Digital", Type.GetType("System.Boolean"));
            DataColumn returnDispositionColumn = displayTable.Columns.Add("Disposition_Date");
            DataColumn returnSortTitleColumn = displayTable.Columns.Add("SortTitle");
            DataColumn returnSortDateColumn = displayTable.Columns.Add("SortDate");

            // Add this to a set to facilitate saving to XML later
            DataSet displaySet = new DataSet("Items_In_Title");
            displaySet.Tables.Add(displayTable);

            // Get column references for the source table
            DataColumn itemIdColumn = childTable.Columns["ItemID"];
            DataColumn vidColumn = childTable.Columns["VID"];
            DataColumn titleColumn = childTable.Columns["Title"];
            DataColumn authorColumn = childTable.Columns["Author"];
            DataColumn publisherColumn = childTable.Columns["Publisher"];
            DataColumn level1TextColumn = childTable.Columns["Level1_Text"];
            DataColumn level1IndexColumn = childTable.Columns["Level1_Index"];
            DataColumn level2TextColumn = childTable.Columns["Level2_Text"];
            DataColumn level2IndexColumn = childTable.Columns["Level2_Index"];
            DataColumn level3TextColumn = childTable.Columns["Level3_Text"];
            DataColumn level3IndexColumn = childTable.Columns["Level3_Index"];
            DataColumn accessColumn = childTable.Columns["IP_Restriction_Mask"];
            DataColumn aggregationsColumn = childTable.Columns["AggregationCodes"];
            DataColumn trackingBoxColumn = childTable.Columns["Tracking_Box"];
            DataColumn dispositionColumn = childTable.Columns["Disposition_Date"];
            DataColumn dateColumn = childTable.Columns["PubDate"];
            DataColumn sortDateColumn = childTable.Columns["SortDate"];
            DataColumn sortTitleColumn = childTable.Columns["SortTitle"];
            DataColumn milestoneColumn = childTable.Columns["Last_Milestone"];
            DataColumn localArchiveColumn = childTable.Columns["Locally_Archived"];
            DataColumn remoteArchiveColumn = childTable.Columns["Remotely_Archived"];

            // Check for values at each hierarchical level
            bool hasLevel1Data = false;
            bool hasLevel2Data = false;
            bool hasLevel3Data = false;
            bool hasPublisherData = false;
            bool hasAuthorData = false;
            bool hasDateData = false;

            // Copy over the applicable rows
            foreach (DataRow thisRow in childTable.Rows)
            {
                DataRow newRow = displayTable.NewRow();
                newRow[returnItemIdColumn] = thisRow[itemIdColumn];
                newRow[returnVidColumn] = thisRow[vidColumn];
                newRow[returnTitleColumn] = thisRow[titleColumn];
                newRow[returnAuthorColumn] = thisRow[authorColumn];
                newRow[returnPublisherColumn] = thisRow[publisherColumn];
                newRow[returnDateColumn] = thisRow[dateColumn];
                newRow[returnLevel1TextColumn] = thisRow[level1TextColumn];
                newRow[returnLevel1IndexColumn] = thisRow[level1IndexColumn];
                newRow[returnLevel2TextColumn] = thisRow[level2TextColumn];
                newRow[returnLevel2IndexColumn] = thisRow[level2IndexColumn];
                newRow[returnLevel3TextColumn] = thisRow[level3TextColumn];
                newRow[returnLevel3IndexColumn] = thisRow[level3IndexColumn];
                newRow[returnAggregationsColumn] = thisRow[aggregationsColumn].ToString().Trim().Replace("  ", "").Replace(" ", ",");
                newRow[returnTrackingBoxColumn] = thisRow[trackingBoxColumn];
                newRow[returnDispositionColumn] = thisRow[dispositionColumn];
                newRow[returnSortDateColumn] = thisRow[sortDateColumn];
                newRow[returnSortTitleColumn] = thisRow[sortTitleColumn];

                int access = Convert.ToInt32(thisRow[accessColumn]);
                if (access < 0)
                    newRow[returnAccessColumn] = "private";
                if (access == 0)
                    newRow[returnAccessColumn] = "public";
                if (access > 0)
                    newRow[returnAccessColumn] = "restricted";
                displayTable.Rows.Add(newRow);

                // Compute the last milestone
                int last_milestone = Convert.ToInt32(thisRow[milestoneColumn]);
                switch( last_milestone )
                {
                    case 1:
                        newRow[returnMilestoneBoxColumn] = "Digital Acquisition";
                        break;

                    case 2:
                        newRow[returnMilestoneBoxColumn] = "Post-Acquisition Processing";
                        break;

                    case 3:
                        newRow[returnMilestoneBoxColumn] = "Quality Control";
                        break;

                    case 4:
                        newRow[returnMilestoneBoxColumn] = "Online Complete";
                        break;

                    default:
                        newRow[returnMilestoneBoxColumn] = String.Empty;
                        break;
                }

                // Determine the archiving
                bool locally_archived = false;
                bool remotely_archived = false;
                if (( thisRow[localArchiveColumn] != DBNull.Value ) && (  thisRow[localArchiveColumn] != null ))
                    locally_archived = true;
                if ((thisRow[remoteArchiveColumn] != DBNull.Value) && (thisRow[remoteArchiveColumn] != null))
                    remotely_archived = true;
                if (( !locally_archived ) && ( !remotely_archived ))
                    newRow[returnArchivedColumn] = String.Empty;
                if ((!locally_archived) && (remotely_archived))
                    newRow[returnArchivedColumn] = "Remote";
                if ((locally_archived) && (!remotely_archived))
                    newRow[returnArchivedColumn] = "Local";
                if ((locally_archived) && (remotely_archived))
                    newRow[returnArchivedColumn] = "Both";

                if (!hasAuthorData)
                {
                    if (newRow[returnAuthorColumn].ToString().Length > 0)
                        hasAuthorData = true;
                }
                if (!hasPublisherData)
                {
                    if (newRow[returnPublisherColumn].ToString().Length > 0)
                        hasPublisherData = true;
                }
                if (!hasLevel1Data)
                {
                    if (newRow[returnLevel1TextColumn].ToString().Length > 0)
                        hasLevel1Data = true;
                }
                if (!hasLevel2Data)
                {
                    if (newRow[returnLevel2TextColumn].ToString().Length > 0)
                        hasLevel2Data = true;
                }
                if (!hasLevel3Data)
                {
                    if (newRow[returnLevel3TextColumn].ToString().Length > 0)
                        hasLevel3Data = true;
                }
                if (!hasDateData)
                {
                    if (newRow[returnDateColumn].ToString().Length > 0)
                        hasDateData = true;
                }
            }

            if (gridPanel == null)
            {
                gridPanel = new CustomGrid_Panel
                                {
                                    Size = new Size(volumesPanel.Width - 2, volumesPanel.Height - 2),
                                    Location = new Point(0, 0)
                                };
                gridPanel.Clipboard_Copy_Requested += new CustomGrid_Panel_Delegate_Multiple(gridPanel_Clipboard_Copy_Requested);

            }
            else
            {
                SMaRT_UserSettings.View_Item_Group_Form_Title_Width = gridPanel.Style.Column_Styles[2].Width;
                if (gridPanel.Style.Column_Styles[3].Visible)
                    SMaRT_UserSettings.View_Item_Group_Form_Author_Width = gridPanel.Style.Column_Styles[3].Width;
                if (gridPanel.Style.Column_Styles[4].Visible)
                    SMaRT_UserSettings.View_Item_Group_Form_Publisher_Width = gridPanel.Style.Column_Styles[4].Width;
                if (gridPanel.Style.Column_Styles[5].Visible)
                    SMaRT_UserSettings.View_Item_Group_Form_Date_Width = gridPanel.Style.Column_Styles[5].Width;
                if (gridPanel.Style.Column_Styles[6].Visible)
                    SMaRT_UserSettings.View_Item_Group_Form_Level1_Width = gridPanel.Style.Column_Styles[6].Width;
                if (gridPanel.Style.Column_Styles[8].Visible)
                    SMaRT_UserSettings.View_Item_Group_Form_Level2_Width = gridPanel.Style.Column_Styles[8].Width;
                if (gridPanel.Style.Column_Styles[10].Visible)
                    SMaRT_UserSettings.View_Item_Group_Form_Level3_Width = gridPanel.Style.Column_Styles[10].Width;
            }

            // Configure some table level style settings
            gridPanel.Style.Default_Column_Width = 80;
            gridPanel.Style.Default_Column_Color = Color.LightBlue;
            gridPanel.Style.Header_Back_Color = Color.DarkBlue;
            gridPanel.Style.Header_Fore_Color = Color.White;

            //// initial the sort option
            //if (this.Current_Sort_String.Length == 0)
            //    this.Current_Sort_String = "BibID ASC";// Use the table from the database as the data source
            //this.DataTable = sourceTable;

            // Set the background and border style
            gridPanel.BackColor = Color.WhiteSmoke;
            gridPanel.BorderStyle = BorderStyle.FixedSingle;
            gridPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
            volumesPanel.Controls.Add(gridPanel);

            gridPanel.DataTable = displayTable;

            gridPanel.Current_Sort_String = "VID ASC";

            // Configure for this table
            gridPanel.Style.Column_Styles[0].Visible = false;
            gridPanel.Style.Column_Styles[1].Width = 50;
            gridPanel.Style.Column_Styles[1].Header_Text = "VID #";
            gridPanel.Style.Column_Styles[1].Fixed_Print_Width = 65;
            gridPanel.Style.Column_Styles[2].Width = SMaRT_UserSettings.View_Item_Group_Form_Title_Width;
            gridPanel.Style.Column_Styles[2].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[2].BackColor = Color.White;

            if (hasAuthorData)
                gridPanel.Style.Column_Styles[3].Width = SMaRT_UserSettings.View_Item_Group_Form_Author_Width;
            else
                gridPanel.Style.Column_Styles[3].Visible = false;

            if (hasPublisherData)
                gridPanel.Style.Column_Styles[4].Width = SMaRT_UserSettings.View_Item_Group_Form_Publisher_Width;
            else
                gridPanel.Style.Column_Styles[4].Visible = false;

            if ( hasDateData)
                gridPanel.Style.Column_Styles[5].Width = SMaRT_UserSettings.View_Item_Group_Form_Date_Width;
            else
                gridPanel.Style.Column_Styles[5].Visible = false;

            if (hasLevel1Data)
                gridPanel.Style.Column_Styles[6].Width = SMaRT_UserSettings.View_Item_Group_Form_Level1_Width;
            else
                gridPanel.Style.Column_Styles[6].Visible = false;

            gridPanel.Style.Column_Styles[6].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[7].Visible = false;
            if (hasLevel2Data)
                gridPanel.Style.Column_Styles[8].Width = SMaRT_UserSettings.View_Item_Group_Form_Level2_Width;
            else
                gridPanel.Style.Column_Styles[8].Visible = false;
            gridPanel.Style.Column_Styles[8].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[9].Visible = false;
            if (hasLevel3Data)
                gridPanel.Style.Column_Styles[10].Width = SMaRT_UserSettings.View_Item_Group_Form_Level3_Width;
            else
                gridPanel.Style.Column_Styles[10].Visible = false;
            gridPanel.Style.Column_Styles[10].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[11].Visible = false;
            gridPanel.Style.Column_Styles[12].Width = 60;
            gridPanel.Style.Column_Styles[12].Text_Alignment = HorizontalAlignment.Left;
            gridPanel.Style.Column_Styles[12].BackColor = Color.White;
            gridPanel.Style.Column_Styles[13].Width = 120;
            gridPanel.Style.Column_Styles[13].BackColor = Color.White;
            gridPanel.Style.Column_Styles[14].Width = 100;
            gridPanel.Style.Column_Styles[14].BackColor = Color.White;
            gridPanel.Style.Column_Styles[15].Width = 125;
            gridPanel.Style.Column_Styles[16].Width = 80;
            gridPanel.Style.Column_Styles[17].Visible = false;
            gridPanel.Style.Column_Styles[18].Visible = false;
            gridPanel.Style.Column_Styles[19].Visible = false;

            // Set some sort values
            gridPanel.Style.Column_Styles[2].Ascending_Sort = "SortTitle ASC, Level1_Index ASC, Level2_Index ASC, Level3_Index ASC, SortDate ASC";
            gridPanel.Style.Column_Styles[2].Descending_Sort = "SortTitle DESC, Level1_Index DESC, Level2_Index DESC, Level3_Index DESC, SortDate DESC";
            gridPanel.Style.Column_Styles[5].Ascending_Sort = "SortDate ASC, PubDate ASC";
            gridPanel.Style.Column_Styles[5].Descending_Sort = "SortDate DESC, PubDate DESC";
            gridPanel.Style.Column_Styles[6].Ascending_Sort = "Level1_Index ASC, Level2_Index ASC, Level3_Index ASC, SortDate ASC";
            gridPanel.Style.Column_Styles[6].Descending_Sort = "Level1_Index DESC, Level2_Index DESC, Level3_Index DESC, SortDate DESC";
            gridPanel.Style.Column_Styles[8].Ascending_Sort = "Level2_Index ASC, Level3_Index ASC";
            gridPanel.Style.Column_Styles[8].Descending_Sort = "Level2_Index DESC, Level3_Index DESC";

            // Add the event to the grid panel
            gridPanel.Double_Clicked += gridPanel_Double_Clicked;

            // Add the context menu
            gridPanel.Set_Context_Menus(null, contextMenu1);

            // Add the object to print
            gridPrinter = new CustomGrid_Printer(gridPanel, printDocument1);

            // Determine if any ALEPH, OCLC, AUTHOR, or PUBLISHER data is present
            bool checkingAuthor = true;
            bool checkingPublisher = true;
            foreach (DataRow thisRow in displayTable.Rows)
            {
                if (checkingAuthor)
                {
                    if (thisRow[returnAuthorColumn].ToString().Trim().Length > 0)
                    {
                        checkingAuthor = false;
                    }
                }

                if (checkingPublisher)
                {
                    if (thisRow[returnPublisherColumn].ToString().Trim().Length > 0)
                    {
                        checkingPublisher = false;
                    }
                }

                if ((!checkingAuthor) && (!checkingPublisher))
                    break;
            }

            // Set the visibility of the columns based on the data
            gridPanel.Style.Column_Styles[3].Visible = !checkingAuthor;
            gridPanel.Style.Column_Styles[4].Visible = !checkingPublisher;

            // Set focus
            gridPanel.Focus();
        }