Exemplo n.º 1
0
 private void FillLBVis(int index)
 {
     foreach (string item in UserConfigOperator.GetVisibleBySector(index))
     {
         listBoxVisible.Items.Add(item);
     }
 }
Exemplo n.º 2
0
        private void SetColumnsForm_Load(object sender, EventArgs e)
        {
            foreach (string field in UserConfigOperator.GetVisible())
            {
                listBoxVisible.Items.Add(field);
            }

            foreach (string field in UserConfigOperator.FieldNames)
            {
                listBoxAll.Items.Add(field);
            }
        }
Exemplo n.º 3
0
        private static void FillDGV(DataGridView dGV, List <Company> companies, int index)
        {
            if (companies.Count < 1)
            {
                return;
            }
            List <string> visibleFields = UserConfigOperator.GetVisibleBySector(index);

            dGV.TopLeftHeaderCell.Value = "Название";

            dGV.ColumnCount         = visibleFields.Count;
            dGV.RowCount            = companies.Count;
            dGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            for (int i = 0; i < companies.Count; i++)
            {
                dGV.Rows[i].HeaderCell.Value = companies[i].Name;
                for (int j = 0; j < dGV.ColumnCount; j++)
                {
                    dGV.Columns[j].HeaderText = visibleFields[j];
                    dGV[j, i].Value           = companies[i].GetLastReport().GetFieldValue(visibleFields[j]);
                }
            }
        }
Exemplo n.º 4
0
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            if (listBoxVisible.Items.Count < 1)
            {
                MessageBox.Show("Пожалуйста, выберите хотя бы один столбец для отображения!");
                return;
            }
            for (int i = 0; i < UserConfigOperator.FieldNames.Count; i++)
            {
                UserConfigOperator.FieldNamesVisBySector[comboBox1.SelectedIndex][i] = false;

                foreach (string item in listBoxVisible.Items)
                {
                    if (item == UserConfigOperator.FieldNames[i])
                    {
                        UserConfigOperator.FieldNamesVisBySector[comboBox1.SelectedIndex][i] = true;
                    }
                }
            }

            UserConfigOperator.SaveFieldsFile();
            MessageBox.Show("Сохранено!");
        }
Exemplo n.º 5
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            Form l = new LoadingOptions();

            l.ShowDialog();

            Company.SectortsPath = ConfigurationManager.AppSettings["SectorsListPath"];
            Company[] c;
            if (isParallelEnabled)
            {
                loadScreen = new LoadingScreen();
                loadScreen.Show();
                loadingInProgress = true;
                c = await GetCompaniesAsync();

                loadingInProgress = false;
            }
            else
            {
                loadScreen = new LoadingScreen();
                loadScreen.Show();
                loadingInProgress = true;
                c = await Task.Run(() => GetCompanies());

                loadingInProgress = false;
            }

            UserConfigOperator.InitializeFields(c);
            LayoutTemplates.companies = c;
            this.сортироватьToolStripMenuItem.DropDownItems.AddRange(LayoutTemplates.GetSortMethodsList());
            TabPage tabPage = LayoutTemplates.GetTabPage(SortIndex);

            tabControl1.Controls.Add(tabPage);
            this.Enabled = true;
            loadScreen.Close();
            loadScreen.Dispose();
        }
Exemplo n.º 6
0
        public static TabPage GetTabPage(int index)
        {
            if (index == 0) // unsorted
            {
                DataGridView dataGridViewUnsorted = new DataGridView();
                ((System.ComponentModel.ISupportInitialize)(dataGridViewUnsorted)).BeginInit();
                dataGridViewUnsorted.Location = new System.Drawing.Point(0, 0);
                dataGridViewUnsorted.Name     = "dataGridViewUnsorted";
                dataGridViewUnsorted.TabIndex = 0;
                ((System.ComponentModel.ISupportInitialize)(dataGridViewUnsorted)).EndInit();
                dataGridViewUnsorted.Dock = DockStyle.Fill;


                { // dataGridView populate and fill
                    List <string> visibleFields = UserConfigOperator.GetVisible();

                    dataGridViewUnsorted.TopLeftHeaderCell.Value = "Название";

                    dataGridViewUnsorted.ColumnCount         = visibleFields.Count;
                    dataGridViewUnsorted.RowCount            = companies.Length;
                    dataGridViewUnsorted.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                    for (int i = 0; i < companies.Length; i++)
                    {
                        dataGridViewUnsorted.Rows[i].HeaderCell.Value = companies[i].Name;
                        dataGridViewUnsorted.RowHeadersWidth          = 300;
                        for (int j = 0; j < dataGridViewUnsorted.ColumnCount; j++)
                        {
                            dataGridViewUnsorted.Columns[j].HeaderText = visibleFields[j];
                            dataGridViewUnsorted[j, i].Value           = companies[i].GetLastReport().GetFieldValue(visibleFields[j]);
                        }
                    }
                    dataGridViewUnsorted.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                    dataGridViewUnsorted.Click        += DataGridViewUnsorted_Click;
                }

                Panel tabPanel = new Panel();
                tabPanel.Controls.Add(dataGridViewUnsorted);
                tabPanel.SuspendLayout();
                tabPanel.Location = new System.Drawing.Point(3, 3);
                tabPanel.Name     = "panel3";
                tabPanel.TabIndex = 0;
                tabPanel.Dock     = DockStyle.Fill;
                tabPanel.ResumeLayout(false);

                TabPage tabPage = new TabPage();
                tabPage.Controls.Add(tabPanel);
                tabPage.Text = "Все компании";
                return(tabPage);
            }

            else if (index == 1) // by sector
            {
                List <Company>[] companiesBySector = new List <Company> [Sectors.Count];
                for (int i = 0; i < companiesBySector.Length; i++)
                {
                    companiesBySector[i] = new List <Company>();
                }

                string[] listOfSectors = Sectors.GetAll();
                for (int i = 0; i < companies.Length; i++)
                {
                    for (int j = 0; j < listOfSectors.Length; j++)
                    {
                        if (companies[i].Sector == listOfSectors[j])
                        {
                            companiesBySector[j].Add(companies[i]);
                        }
                    }
                }

                Panel tabPanel = new Panel();
                tabPanel.SuspendLayout();
                tabPanel.Location   = new System.Drawing.Point(3, 3);
                tabPanel.Name       = "tabPanel";
                tabPanel.TabIndex   = 0;
                tabPanel.Dock       = DockStyle.Fill;
                tabPanel.AutoScroll = true;
                tabPanel.ResumeLayout(false);

                TabPage tabPage = new TabPage();
                tabPage.Text = "По секторам";
                tabPage.Controls.Add(tabPanel);

                string[]     sectorsInfo = Sectors.GetInfo();
                DataGridView previousDGV = null;
                for (int i = 0; i < Sectors.Count; i++)
                {
                    Label sectorLabel = new Label();
                    sectorLabel.Text     = sectorsInfo[i];
                    sectorLabel.AutoSize = true;
                    if (i == 0)
                    {
                        sectorLabel.Location = new System.Drawing.Point(80, 20);
                    }
                    else
                    {
                        sectorLabel.Location = new System.Drawing.Point(80, previousDGV.Location.Y + previousDGV.Size.Height + 10);
                    }
                    tabPanel.Controls.Add(sectorLabel);

                    DataGridView sectorDGV = new DataGridView();
                    ((System.ComponentModel.ISupportInitialize)(sectorDGV)).BeginInit();
                    sectorDGV.Location = new System.Drawing.Point(40, sectorLabel.Location.Y + sectorLabel.Size.Height + 2);
                    if (i == 0)
                    {
                        sectorDGV.Size = new System.Drawing.Size(tabPanel.Width - 80, 500);
                    }
                    else
                    {
                        sectorDGV.Size = new System.Drawing.Size(previousDGV.Size.Width, 500);
                    }

                    sectorDGV.Name            = "dataGridViewBySector" + listOfSectors[i];
                    sectorDGV.Anchor          = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                    sectorDGV.RowHeadersWidth = 300;
                    ((System.ComponentModel.ISupportInitialize)(sectorDGV)).EndInit();
                    FillDGV(sectorDGV, companiesBySector[i], i);


                    tabPanel.Controls.Add(sectorDGV);
                    previousDGV = sectorDGV;
                }

                return(tabPage);
            }
            else
            {
                throw new NullReferenceException("Sort index is invalid"); // if this appears check for conformity between
                                                                           // ToolStripMenyItems and existing index values
                                                                           // (prbably missing implementation)
            }
        }