コード例 #1
0
ファイル: DataviewTabProperties.cs プロジェクト: egacheru/G2
        //public DataviewTabProperties(SharedUtils sharedUtils, DataviewProperties dataviewProperties, FormsData[] formsList)
        public DataviewTabProperties(WebServices webServices, DataviewProperties dataviewProperties)
        {
            InitializeComponent();

            // Create a SharedUtils object...
            SharedUtils sharedUtils = new SharedUtils(webServices.Url, webServices.Username, webServices.Password_ClearText, true);

            // Get the list of dataviews...
            DataSet _dataviewData = sharedUtils.GetWebServiceData("get_dataview_list", "", 0, 0);
            // Populate the combobox with the list of available dataviews...
            if (_dataviewData.Tables.Contains("get_dataview_list"))
            {
                _dataviewList = _dataviewData.Tables["get_dataview_list"].Copy();
                _dataviewList.Columns.Add("display_member", typeof(string));
                _dataviewList.Columns.Add("category_name", typeof(string));
                _dataviewList.Columns.Add("database_area", typeof(string));
                foreach (DataRow dr in _dataviewList.Rows)
                {
                    string friendlyName = "";
                    if (dr.Table.Columns.Contains("title")) friendlyName += dr["title"].ToString().Trim();
                    dr["display_member"] = friendlyName;
                    if (!string.IsNullOrEmpty(dr["category_code"].ToString()))
                    {
                        dr["category_name"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["category_code"].ToString(), dr.Table.Columns["category_code"].ExtendedProperties["group_name"].ToString(), dr["category_code"].ToString());
                    }
                    else
                    {
                        dr["category_name"] = "";
                    }

                    if (!string.IsNullOrEmpty(dr["database_area_code"].ToString()))
                    {
                        dr["database_area"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["database_area_code"].ToString(), dr.Table.Columns["database_area_code"].ExtendedProperties["group_name"].ToString(), dr["database_area_code"].ToString());
                    }
                    else
                    {
                        dr["database_area"] = "";
                    }
                }
                // Build the distinct list of categories and bind it to the combobox...
                _category = _dataviewList.DefaultView.ToTable(true, new string[] { "category_name" });
                _category.DefaultView.Sort = "category_name asc";
                ux_comboboxDataviewCategory.DisplayMember = "category_name";
                ux_comboboxDataviewCategory.ValueMember = "category_name";
                ux_comboboxDataviewCategory.DataSource = _category;

                // Bind the list to the dropdown combobox...
                if (_dataviewList.Columns.Contains("display_member")) _dataviewList.DefaultView.Sort = "display_member asc";
                ux_comboboxDataviews.DisplayMember = "display_member";
                ux_comboboxDataviews.ValueMember = "dataview_name";
                ux_comboboxDataviews.DataSource = _dataviewList;
            }
            else
            {
                // Did not return the dataview list - bail out now...
                return;
            }

            // Get the dataview record that matches what is in the dataviewProperties.dataviewname property (there should only be one with this name)...
            DataRow[] currentDataviewRows = _dataviewList.Select("is_enabled='Y' AND dataview_name='" + dataviewProperties.DataviewName + "'");
            DataRow currentDataviewRow = null;
            if (currentDataviewRows.Length > 0) currentDataviewRow = currentDataviewRows[0];

            // Build the list of compatible forms and bind it to the combobox...
            FormsData[] formsDataList = sharedUtils.GetDataviewFormsData();

            if (formsDataList != null &&
                formsDataList.Length > 0)
            {
                _formsList.Columns.Add("DisplayMember", typeof(string));
                _formsList.Columns.Add("ValueMember", typeof(string));
                _formsList.Columns.Add("PreferredDataviewName", typeof(string));
                //_formsList.PrimaryKey = new DataColumn[] { _formsList.Columns["ValueMember"] };
                foreach (FormsData fd in formsDataList)
                {
                    if (!string.IsNullOrEmpty(fd.PreferredDataviewName))
                    {
                        string[] preferredDataviews = fd.PreferredDataviewName.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string preferredDataview in preferredDataviews)
                        {
                            if (fd.ConstInfo != null &&
                                !string.IsNullOrEmpty(fd.StrongFormName))
                            {
                                DataRow newRow = _formsList.NewRow();
                                newRow["DisplayMember"] = fd.FormName + "   (" + fd.ConstInfo.Module.Name + ")";
                                newRow["ValueMember"] = fd.StrongFormName;
                                newRow["PreferredDataviewName"] = preferredDataview.Trim().ToLower();
                                _formsList.Rows.Add(newRow);
                            }
                        }
                    }
                }
            }
            // Set the tab properties to the values passed into the dialog...
            this.TabProperties = dataviewProperties;

            // Populate the controls with the currently chosen dataview (if this is not a brand new dataview)...
            // (order matters here - first choose category, then DB area, and finally dataview)
            // STEP 1 - Catetory
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviewCategory.SelectedValue = currentDataviewRow["category_name"].ToString();
            }
            // STEP 2 - Database Area
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDatabaseArea.SelectedValue = currentDataviewRow["database_area"].ToString();
            }
            // STEP 3 - Dataview
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviews.SelectedValue = currentDataviewRow["dataview_name"].ToString();
            }

            // Disable the OK button and the radio buttons for forms viewer (by default)...
            if (ux_comboboxDataviews.SelectedValue == null)
            {
                ux_buttonOK.Enabled = false;
                ux_radiobuttonFormStyle.Enabled = false;
                ux_radiobuttonBothStyle.Enabled = false;
                ux_comboboxForm.Enabled = false;
                ux_checkboxAlwayOnTop.Enabled = false;
                ux_checkboxAlwayOnTop.Hide();
            }
            sharedUtils.UpdateControls(this.Controls, this.Name);
        }
コード例 #2
0
ファイル: UserInterfaceUtils.cs プロジェクト: egacheru/G2
        public void ux_tabcontrolShowProperties(TabControl ux_tabcontrolDataview, int indexOfCurrentTab)
        {
            DataviewProperties dvp;
            if (ux_tabcontrolDataview.SelectedTab != null &&
                ux_tabcontrolDataview.SelectedTab.Tag != null &&
                ux_tabcontrolDataview.SelectedTab.Tag.GetType() == typeof(DataviewProperties) &&
                !string.IsNullOrEmpty(((DataviewProperties)ux_tabcontrolDataview.SelectedTab.Tag).TabName))
            {
                dvp = (DataviewProperties)ux_tabcontrolDataview.SelectedTab.Tag;
            }
            else
            {
                dvp = new DataviewProperties();
                dvp.TabName = ux_tabcontrolDataview.SelectedTab.Text;
                dvp.DataviewName = (string)ux_tabcontrolDataview.SelectedTab.Tag;
                dvp.StrongFormName = "";
                dvp.ViewerStyle = "Spreadsheet";
                dvp.AlwaysOnTop = "false";
            }

            DataviewTabProperties dataviewTabPropertiesDialog = new DataviewTabProperties(_webServices, dvp);
            dataviewTabPropertiesDialog.StartPosition = FormStartPosition.CenterParent;
            if (dataviewTabPropertiesDialog.ShowDialog() == DialogResult.OK)
            {
                ux_tabcontrolDataview.TabPages[indexOfCurrentTab].Tag = dataviewTabPropertiesDialog.TabProperties;
                ux_tabcontrolDataview.TabPages[indexOfCurrentTab].Text = ((DataviewProperties)ux_tabcontrolDataview.TabPages[indexOfCurrentTab].Tag).TabName;
            }
        }
コード例 #3
0
ファイル: UserInterfaceUtils.cs プロジェクト: egacheru/G2
        public void buildDataviewTabControl(TabControl ux_tabcontrolDataview, SharedUtils sharedUtils)
        {
            int numDataviewTabs = -1;

            // Clear the dataview tabs...
            ux_tabcontrolDataview.TabPages.Clear();

            // Now add back in the tabpage for adding new tabpages...
            if (!ux_tabcontrolDataview.TabPages.ContainsKey("ux_tabpageDataviewNewTab"))
            {
                ux_tabcontrolDataview.TabPages.Add("ux_tabpageDataviewNewTab", "...");
            }

            // Get the number of tabpages saved in the current user's settings...
            int.TryParse(sharedUtils.GetUserSetting("", ux_tabcontrolDataview.Name, "TabPages.Count", "-1"), out numDataviewTabs);

            // Create the user's saved dataview tabs...
            if (numDataviewTabs > 0)
            {
                for (int i = 0; i < numDataviewTabs; i++)
                {
                    DataviewProperties dp = new DataviewProperties();
                    dp.TabName = sharedUtils.GetUserSetting("", ux_tabcontrolDataview.Name, "TabPages[" + i.ToString() + "].TabName", "");
                    dp.DataviewName = sharedUtils.GetUserSetting("", ux_tabcontrolDataview.Name, "TabPages[" + i.ToString() + "].DataviewName", "");
                    dp.StrongFormName = sharedUtils.GetUserSetting("", ux_tabcontrolDataview.Name, "TabPages[" + i.ToString() + "].FormName", "");
                    dp.ViewerStyle = sharedUtils.GetUserSetting("", ux_tabcontrolDataview.Name, "TabPages[" + i.ToString() + "].ViewerStyle", "");
                    dp.AlwaysOnTop = sharedUtils.GetUserSetting("", ux_tabcontrolDataview.Name, "TabPages[" + i.ToString() + "].AlwaysOnTop", "");
                    ux_tabcontrolAddTab(ux_tabcontrolDataview, dp.TabName, dp, Math.Min(i, ux_tabcontrolDataview.TabPages.IndexOfKey("ux_tabpageDataviewNewTab")));
                }
            }
            else
            {
                // Make the default Accession dataview tab...
                DataviewProperties dp = new DataviewProperties();
                dp.TabName = "Accessions";
                dp.DataviewName = "get_accession";
                dp.StrongFormName = "";
                dp.ViewerStyle = "Spreadsheet";
                dp.AlwaysOnTop = "false";
                ux_tabcontrolAddTab(ux_tabcontrolDataview, dp.TabName, dp, Math.Min(0, ux_tabcontrolDataview.TabPages.IndexOfKey("ux_tabpageDataviewNewTab")));
                // Make the default Inventory dataview tab...
                dp = new DataviewProperties();
                dp.TabName = "Inventory";
                dp.DataviewName = "get_inventory";
                dp.StrongFormName = "";
                dp.ViewerStyle = "Spreadsheet";
                dp.AlwaysOnTop = "false";
                ux_tabcontrolAddTab(ux_tabcontrolDataview, dp.TabName, dp, Math.Min(1, ux_tabcontrolDataview.TabPages.IndexOfKey("ux_tabpageDataviewNewTab")));
                // Make the default Orders dataview tab...
                dp = new DataviewProperties();
                dp.TabName = "Orders";
                dp.DataviewName = "get_order_request";
                dp.StrongFormName = "";
                dp.ViewerStyle = "Spreadsheet";
                dp.AlwaysOnTop = "false";
                ux_tabcontrolAddTab(ux_tabcontrolDataview, dp.TabName, dp, Math.Min(2, ux_tabcontrolDataview.TabPages.IndexOfKey("ux_tabpageDataviewNewTab")));
                // Make the default Cooperators dataview tab...
                dp = new DataviewProperties();
                dp.TabName = "Cooperators";
                dp.DataviewName = "get_cooperator";
                dp.StrongFormName = "";
                dp.ViewerStyle = "Spreadsheet";
                dp.AlwaysOnTop = "false";
                ux_tabcontrolAddTab(ux_tabcontrolDataview, dp.TabName, dp, Math.Min(3, ux_tabcontrolDataview.TabPages.IndexOfKey("ux_tabpageDataviewNewTab")));
            }
            // Make the first tab active...
            ux_tabcontrolDataview.SelectedTab = ux_tabcontrolDataview.TabPages[0];
        }
コード例 #4
0
ファイル: UserInterfaceUtils.cs プロジェクト: egacheru/G2
        public void ux_tabcontrolCreateNewTab(TabControl ux_tabcontrolDataview, int indexOfNewTab)
        {
            DataviewProperties dvp = new DataviewProperties();
            dvp.TabName = "";
            dvp.DataviewName = "";
            dvp.StrongFormName = "";
            dvp.ViewerStyle = "Spreadsheet";
            dvp.AlwaysOnTop = "false";

            DataviewTabProperties newTabDialog = new DataviewTabProperties(_webServices, dvp);
            newTabDialog.StartPosition = FormStartPosition.CenterParent;
            if (newTabDialog.ShowDialog() == DialogResult.OK)
            {
                ux_tabcontrolAddTab(ux_tabcontrolDataview, newTabDialog.TabProperties.TabName, newTabDialog.TabProperties, indexOfNewTab);
                ux_tabcontrolDataview.SelectedIndex = indexOfNewTab;
                //SetDGVMainDataviewUserSettings();
            }
            else
            {
                ux_tabcontrolDataview.DeselectTab(indexOfNewTab);
            }
        }
コード例 #5
0
ファイル: UserInterfaceUtils.cs プロジェクト: egacheru/G2
 public void ux_tabcontrolAddTab(TabControl ux_tabcontrolDataview, string text, DataviewProperties tag, int position)
 {
     foreach (TabPage tp in ux_tabcontrolDataview.TabPages)
     {
         // If this tab page is already in the collection - bail out...
         if (tp.Text.ToUpper() == text.ToUpper() && ((DataviewProperties)tp.Tag).DataviewName == tag.DataviewName) return;
     }
     TabPage newTabPage = new TabPage();
     newTabPage.Text = text;
     newTabPage.Tag = tag;
     ux_tabcontrolDataview.TabPages.Insert(position, newTabPage);
 }
コード例 #6
0
ファイル: SharedUtils.cs プロジェクト: egacheru/G2
 public void ux_tabcontrolAddTab(TabControl ux_tabcontrolDataview, string text, DataviewProperties tag, int position)
 {
     _userInterfaceUtils.ux_tabcontrolAddTab(ux_tabcontrolDataview, text, tag, position);
 }
コード例 #7
0
        //public DataviewTabProperties(SharedUtils sharedUtils, DataviewProperties dataviewProperties, FormsData[] formsList)
        public DataviewTabProperties(WebServices webServices, DataviewProperties dataviewProperties)
        {
            InitializeComponent();

            // Create a SharedUtils object...
            SharedUtils sharedUtils = new SharedUtils(webServices.Url, webServices.Username, webServices.Password_ClearText, true);

            // Get the list of dataviews...
            DataSet _dataviewData = sharedUtils.GetWebServiceData("get_dataview_list", "", 0, 0);

            // Populate the combobox with the list of available dataviews...
            if (_dataviewData.Tables.Contains("get_dataview_list"))
            {
                _dataviewList = _dataviewData.Tables["get_dataview_list"].Copy();
                _dataviewList.Columns.Add("display_member", typeof(string));
                _dataviewList.Columns.Add("category_name", typeof(string));
                _dataviewList.Columns.Add("database_area", typeof(string));
                foreach (DataRow dr in _dataviewList.Rows)
                {
                    string friendlyName = "";
                    if (dr.Table.Columns.Contains("title"))
                    {
                        friendlyName += dr["title"].ToString().Trim();
                    }
                    dr["display_member"] = friendlyName;
                    if (!string.IsNullOrEmpty(dr["category_code"].ToString()))
                    {
                        dr["category_name"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["category_code"].ToString(), dr.Table.Columns["category_code"].ExtendedProperties["group_name"].ToString(), dr["category_code"].ToString());
                    }
                    else
                    {
                        dr["category_name"] = "";
                    }

                    if (!string.IsNullOrEmpty(dr["database_area_code"].ToString()))
                    {
                        dr["database_area"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["database_area_code"].ToString(), dr.Table.Columns["database_area_code"].ExtendedProperties["group_name"].ToString(), dr["database_area_code"].ToString());
                    }
                    else
                    {
                        dr["database_area"] = "";
                    }
                }
                // Build the distinct list of categories and bind it to the combobox...
                _category = _dataviewList.DefaultView.ToTable(true, new string[] { "category_name" });
                _category.DefaultView.Sort = "category_name asc";
                ux_comboboxDataviewCategory.DisplayMember = "category_name";
                ux_comboboxDataviewCategory.ValueMember   = "category_name";
                ux_comboboxDataviewCategory.DataSource    = _category;

                // Bind the list to the dropdown combobox...
                if (_dataviewList.Columns.Contains("display_member"))
                {
                    _dataviewList.DefaultView.Sort = "display_member asc";
                }
                ux_comboboxDataviews.DisplayMember = "display_member";
                ux_comboboxDataviews.ValueMember   = "dataview_name";
                ux_comboboxDataviews.DataSource    = _dataviewList;
            }
            else
            {
                // Did not return the dataview list - bail out now...
                return;
            }

            // Get the dataview record that matches what is in the dataviewProperties.dataviewname property (there should only be one with this name)...
            DataRow[] currentDataviewRows = _dataviewList.Select("is_enabled='Y' AND dataview_name='" + dataviewProperties.DataviewName + "'");
            DataRow   currentDataviewRow  = null;

            if (currentDataviewRows.Length > 0)
            {
                currentDataviewRow = currentDataviewRows[0];
            }

            // Build the list of compatible forms and bind it to the combobox...
            FormsData[] formsDataList = sharedUtils.GetDataviewFormsData();

            if (formsDataList != null &&
                formsDataList.Length > 0)
            {
                _formsList.Columns.Add("DisplayMember", typeof(string));
                _formsList.Columns.Add("ValueMember", typeof(string));
                _formsList.Columns.Add("PreferredDataviewName", typeof(string));
                //_formsList.PrimaryKey = new DataColumn[] { _formsList.Columns["ValueMember"] };
                foreach (FormsData fd in formsDataList)
                {
                    if (!string.IsNullOrEmpty(fd.PreferredDataviewName))
                    {
                        string[] preferredDataviews = fd.PreferredDataviewName.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string preferredDataview in preferredDataviews)
                        {
                            if (fd.ConstInfo != null &&
                                !string.IsNullOrEmpty(fd.StrongFormName))
                            {
                                DataRow newRow = _formsList.NewRow();
                                newRow["DisplayMember"]         = fd.FormName + "   (" + fd.ConstInfo.Module.Name + ")";
                                newRow["ValueMember"]           = fd.StrongFormName;
                                newRow["PreferredDataviewName"] = preferredDataview.Trim().ToLower();
                                _formsList.Rows.Add(newRow);
                            }
                        }
                    }
                }
            }
            // Set the tab properties to the values passed into the dialog...
            this.TabProperties = dataviewProperties;

            // Populate the controls with the currently chosen dataview (if this is not a brand new dataview)...
            // (order matters here - first choose category, then DB area, and finally dataview)
            // STEP 1 - Catetory
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviewCategory.SelectedValue = currentDataviewRow["category_name"].ToString();
            }
            // STEP 2 - Database Area
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDatabaseArea.SelectedValue = currentDataviewRow["database_area"].ToString();
            }
            // STEP 3 - Dataview
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviews.SelectedValue = currentDataviewRow["dataview_name"].ToString();
            }

            // Disable the OK button and the radio buttons for forms viewer (by default)...
            if (ux_comboboxDataviews.SelectedValue == null)
            {
                ux_buttonOK.Enabled             = false;
                ux_radiobuttonFormStyle.Enabled = false;
                ux_radiobuttonBothStyle.Enabled = false;
                ux_comboboxForm.Enabled         = false;
                ux_checkboxAlwayOnTop.Enabled   = false;
                ux_checkboxAlwayOnTop.Hide();
            }
            sharedUtils.UpdateControls(this.Controls, this.Name);
        }
コード例 #8
0
 public void ux_tabcontrolAddTab(TabControl ux_tabcontrolDataview, string text, DataviewProperties tag, int position)
 {
     _userInterfaceUtils.ux_tabcontrolAddTab(ux_tabcontrolDataview, text, tag, position);
 }