Пример #1
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);
        }
        //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);
        }