コード例 #1
0
        /// <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;
            }
        }
コード例 #2
0
        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();
            }
        }