예제 #1
0
        private void светлаяToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Supports.textWhite == Supports.ColorSetLite.textWhite)
            {
                return;
            }

            dataBase.SimpleRequest("UPDATE [MainSettings] SET [Content] = 'Lite'  WHERE [Who] = 'ColorStyle' AND [What] = '" + Profile.userLogin + "'");

            Supports.headGrey     = Supports.ColorSetLite.headGrey;
            Supports.headliteGrey = Supports.ColorSetLite.headliteGrey;
            Supports.textBlack    = Supports.ColorSetLite.textBlack;
            Supports.darkBlue     = Supports.ColorSetLite.darkBlue;
            Supports.backBlack    = Supports.ColorSetLite.backBlack;
            Supports.textGray     = Supports.ColorSetLite.textGray;
            Supports.liteTextGray = Supports.ColorSetLite.liteTextGray;
            Supports.headBlue     = Supports.ColorSetLite.headBlue;
            Supports.headOrange   = Supports.ColorSetLite.headOrange;
            Supports.textWhite    = Supports.ColorSetLite.textWhite;
            Supports.groupGrey    = Supports.ColorSetLite.groupGrey;
            Supports.Red          = Supports.ColorSetLite.Red;
            Supports.Green        = Supports.ColorSetLite.Green;
            Supports.LiteHeadBlue = Supports.ColorSetLite.LiteHeadBlue;
            Supports.LiteTextBlue = Supports.ColorSetLite.LiteTextBlue;
            Supports.StringBrush  = Supports.ColorSetLite.StringBrush;
            Supports.StringPen    = Supports.ColorSetLite.StringPen;


            Supports.GangeGroup(this);
            panel2.BackColor = Supports.headBlue;

            if (panel4.BackColor.R < 122)
            {
                x1 = Resources.x1tw;
                x2 = Resources.x2tw;
                x3 = Resources.x3tw;
                x4 = Resources.x7tw;
            }
            else
            {
                x1 = Resources.x1tb;
                x2 = Resources.x2tb;
                x3 = Resources.x3tb;
                x4 = Resources.x7tb;
            }

            pictureBox1.Image = x1;
            pictureBox2.Image = x2;
            pictureBox3.Image = x3;

            tabControl1.Invalidate();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
예제 #2
0
        public SidePanel(string name)
        {
            try
            {
                BackColor = Supports.backBlack;

                Dock = DockStyle.Fill;

                Controls.Add(new Panel()
                {
                    Name = "Body",
                    Dock = DockStyle.Fill,
                });

                (Controls.Find("Body", false).FirstOrDefault() as Panel).ControlAdded += (s, e) =>
                {
                    Supports.GangeGroup(this);
                };


                Controls.Add(new Panel()
                {
                    Name = "Head",

                    Dock      = DockStyle.Top,
                    Height    = 20,
                    BackColor = Supports.groupGrey,
                });

                (Controls.Find("Head", false).FirstOrDefault() as Panel).Controls.Add(new Label
                {
                    TextAlign = System.Drawing.ContentAlignment.BottomLeft,
                    Dock      = DockStyle.Fill,
                    AutoSize  = true,
                    Text      = name,
                });

                (Controls.Find("Head", false).FirstOrDefault() as Panel).Controls.Add(new PictureBox()
                {
                    Name     = "HeadCloser",
                    Dock     = DockStyle.Right,
                    Width    = 20,
                    Image    = Resources.ex,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                    Padding  = new Padding(2),
                });

                (Controls.Find("HeadCloser", true).FirstOrDefault() as PictureBox).MouseEnter += (s, e) => (s as PictureBox).BackColor = Supports.LiteHeadBlue;

                (Controls.Find("HeadCloser", true).FirstOrDefault() as PictureBox).MouseLeave += (s, e) => (s as PictureBox).BackColor = Color.Transparent;

                (Controls.Find("HeadCloser", true).FirstOrDefault() as PictureBox).MouseDown += (s, e) =>
                {
                    if (MouseButtons.Left == e.Button)
                    {
                        (Controls.Find("HeadCloser", true).FirstOrDefault() as PictureBox).BackColor = Supports.darkBlue;
                    }
                };

                (Controls.Find("HeadCloser", true).FirstOrDefault() as PictureBox).MouseUp += (s, e) =>
                {
                    if (MouseButtons.Left == e.Button && (s as PictureBox).ClientRectangle.Contains((s as PictureBox).PointToClient(MousePosition)))
                    {
                        Dispose();
                    }
                };
            }
            catch (Exception e)
            {
                MessageBoxTi.Show("SidePanel " + e.Message);
            }
        }
예제 #3
0
        public SQLRequestFilter(DataGridView dataGridView, string[] columnsToFilter)
        {
            try
            {
                if (dataGridView == null)
                {
                    return;
                }

                columnsFilter = columnsToFilter;
                Width         = 200;
                lastWidth     = Width;
                Name          = "filterPanel";
                Padding       = new Padding(0, 0, 5, 0);

                Controls.Add(new TreeView()
                {
                    CheckBoxes = true,
                    Dock       = DockStyle.Fill,
                    Scrollable = true,
                    Name       = "filterTreeView",
                });

                Controls.Add(new Button()
                {
                    Dock  = DockStyle.Top,
                    Width = 37,
                    Name  = "filterButton",
                    Text  = "Сбросить все фильтры",
                });

                Controls.Add(new Panel()
                {
                    Dock       = DockStyle.Bottom,
                    Height     = 600,
                    Name       = "Panel",
                    AutoScroll = true,
                });

                Controls.Add(new Button()
                {
                    Dock  = DockStyle.Right,
                    Name  = "hideFilterButton",
                    Width = 15,
                    Image = Resources.left,
                });

                (Controls.Find("hideFilterButton", false).FirstOrDefault() as Button).Click += (s, e) =>
                {
                    if (Controls.Find("filterTreeView", false).FirstOrDefault().Visible)
                    {
                        Controls.Find("filterTreeView", false).FirstOrDefault().Visible = false;
                        Controls.Find("filterButton", false).FirstOrDefault().Visible   = false;
                        Controls.Find("Panel", false).FirstOrDefault().Visible          = false;
                        lastWidth = Width;
                        Width     = 20;
                        (Controls.Find("hideFilterButton", false).FirstOrDefault() as Button).Image = Resources.right;
                        if (Parent.Controls.Find("filterSplitter", false).Count() != 0)
                        {
                            (Parent.Controls.Find("filterSplitter", false).FirstOrDefault() as Splitter).Visible = false;
                        }
                    }
                    else
                    {
                        Controls.Find("filterTreeView", false).FirstOrDefault().Visible = true;
                        Controls.Find("filterButton", false).FirstOrDefault().Visible   = true;
                        Controls.Find("Panel", false).FirstOrDefault().Visible          = true;
                        Width = lastWidth;
                        (Controls.Find("hideFilterButton", false).FirstOrDefault() as Button).Image = Resources.left;
                        if (Parent.Controls.Find("filterSplitter", false).Count() != 0)
                        {
                            (Parent.Controls.Find("filterSplitter", false).FirstOrDefault() as Splitter).Visible = true;
                        }
                    }
                };

                (Controls.Find("filterButton", false).FirstOrDefault() as Button).Click += (s, e) =>
                {
                    resetOn = true;
                    ResetAllNodes();
                    ResetAllText(this);
                    textBoxesFilter            = null;
                    checkBoxesFilter           = null;
                    rangeTextBoxesFilter       = null;
                    rangeDateTimePickersFilter = null;
                    OnFilterChanged?.Invoke(this, new EventArgs());
                    resetOn = false;
                };

                tree = (Controls.Find("filterTreeView", false).FirstOrDefault() as TreeView);

                tree.BeforeCheck += (s, e) =>
                {
                    if (e.Node.Parent == null)
                    {
                        e.Cancel = true;
                    }
                };

                tree.AfterCheck += (s, e) =>
                {
                    if (resetOn)
                    {
                        return;
                    }

                    if (e.Node.Parent != null)
                    {
                        bool checkedCol = false;
                        checkBoxesFilter = null;
                        foreach (TreeNode node in tree.Nodes)
                        {
                            foreach (TreeNode nod in node.Nodes)
                            {
                                if (nod.Checked)
                                {
                                    checkBoxesFilter += '(';
                                    checkedCol        = true;
                                    break;
                                }
                            }
                            if (checkedCol)
                            {
                                foreach (TreeNode nod in node.Nodes)
                                {
                                    if (nod.Checked)
                                    {
                                        checkBoxesFilter += "[" + node.Name + "] = '" + nod.Name + "' OR ";
                                    }
                                }
                                checkedCol        = false;
                                checkBoxesFilter  = checkBoxesFilter.Remove(checkBoxesFilter.Length - 4, 4);
                                checkBoxesFilter += ") AND ";
                            }
                        }
                        if (checkBoxesFilter != null)
                        {
                            checkBoxesFilter  = checkBoxesFilter.Remove(checkBoxesFilter.Length - 6, 6);
                            checkBoxesFilter += ')';
                        }


                        OnFilterChanged?.Invoke(this, new EventArgs());
                    }
                };


                foreach (DataGridViewColumn col in dataGridView.Columns)
                {
                    if (col.Name == "ID")
                    {
                        continue;
                    }
                    if ((col.ValueType == typeof(string) || col.ValueType == typeof(bool)) && !columnsFilter.Contains(col.Name))
                    {
                        List <string> distinctConditions = dataGridView.Rows.Cast <DataGridViewRow>().Select(x => x.Cells[col.Name].Value.ToString()).Where(x => x != "").OrderBy(x => x).Distinct().ToList();

                        Type k = col.ValueType;

                        if (distinctConditions.Count < 2)
                        {
                            continue;
                        }

                        tree.Nodes.Add(col.Name, col.HeaderText);

                        foreach (string str in distinctConditions)
                        {
                            if (col.ValueType != typeof(bool))
                            {
                                tree.Nodes.Find(col.Name, false).FirstOrDefault().Nodes.Add(str.ToString(), str.ToString());
                            }
                            else
                            {
                                if (str == "True")
                                {
                                    tree.Nodes.Find(col.Name, false).FirstOrDefault().Nodes.Add(str.ToString(), "Вкл.");
                                }
                                else
                                {
                                    tree.Nodes.Find(col.Name, false).FirstOrDefault().Nodes.Add(str.ToString(), "Выкл.");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (col.ValueType == typeof(string))
                        {
                            Controls.Find("Panel", true).FirstOrDefault().Controls.Add(new GroupBox()
                            {
                                Text   = col.Name,
                                Name   = col.Name + "GroupBox",
                                Dock   = DockStyle.Top,
                                Height = 37,
                            });

                            Controls.Find(col.Name + "GroupBox", true).FirstOrDefault().Controls.Add(new TextBox()
                            {
                                Dock = DockStyle.Fill,
                                Name = col.Name + "TextBox",
                            });
                            (Controls.Find(col.Name + "TextBox", true).FirstOrDefault() as TextBox).TextChanged += (s, e) =>
                            {
                                if (resetOn)
                                {
                                    return;
                                }


                                textBoxesFilter = null;
                                foreach (string text in columnsToFilter)
                                {
                                    if ((Controls.Find(text + "TextBox", true).FirstOrDefault() as TextBox).Text == "")
                                    {
                                        continue;
                                    }
                                    textBoxesFilter += '[' + text + "] LIKE '%" + (Controls.Find(text + "TextBox", true).FirstOrDefault() as TextBox).Text + "%' AND ";
                                }
                                if (textBoxesFilter != null)
                                {
                                    textBoxesFilter = textBoxesFilter.Remove(textBoxesFilter.Length - 4, 4);
                                }

                                OnFilterChanged?.Invoke(this, new EventArgs());
                            };
                        }
                        else if (col.ValueType == typeof(DateTime))
                        {
                            rangeDateTimePickers.Add(col.Name);
                            Controls.Find("Panel", true).FirstOrDefault().Controls.Add(new GroupBox()
                            {
                                Text   = col.Name,
                                Name   = col.Name + "GroupBox",
                                Dock   = DockStyle.Top,
                                Height = 65,
                            });

                            Controls.Find(col.Name + "GroupBox", true).FirstOrDefault().Controls.Add(new DateTimePicker()
                            {
                                Name = col.Name + "1",
                                Dock = DockStyle.Top,
                            });

                            Controls.Find(col.Name + "GroupBox", true).FirstOrDefault().Controls.Add(new DateTimePicker()
                            {
                                Name = col.Name + "2",
                                Dock = DockStyle.Bottom,
                            });

                            Controls.Find(col.Name + "1", true).FirstOrDefault().TextChanged += (s, e) =>
                            {
                                if (resetOn)
                                {
                                    return;
                                }

                                string old = rangeDateTimePickersFilter;
                                rangeDateTimePickersFilter = null;



                                foreach (string text in rangeDateTimePickers)
                                {
                                    if ((Controls.Find(text + "1", true).FirstOrDefault() as DateTimePicker).Value >= (Controls.Find(text + "2", true).FirstOrDefault() as DateTimePicker).Value)
                                    {
                                        continue;
                                    }

                                    rangeDateTimePickersFilter += "([" + text + "] > '" + (Controls.Find(text + "1", true).FirstOrDefault() as DateTimePicker).Value.Date + "' AND [" + text + "] < '" + (Controls.Find(text + "2", true).FirstOrDefault() as DateTimePicker).Value.Date + "') AND ";
                                }
                                if (rangeDateTimePickersFilter != null)
                                {
                                    rangeDateTimePickersFilter = rangeDateTimePickersFilter.Remove(rangeDateTimePickersFilter.Length - 4, 4);
                                }

                                if (rangeDateTimePickersFilter != null)
                                {
                                    if (!rangeDateTimePickersFilter.Equals(old))
                                    {
                                        OnFilterChanged?.Invoke(this, new EventArgs());
                                    }
                                }
                            };

                            Controls.Find(col.Name + "2", true).FirstOrDefault().TextChanged += (s, e) =>
                            {
                                if (resetOn)
                                {
                                    return;
                                }

                                string old = rangeDateTimePickersFilter;
                                rangeDateTimePickersFilter = null;

                                foreach (string text in rangeDateTimePickers)
                                {
                                    if ((Controls.Find(text + "1", true).FirstOrDefault() as DateTimePicker).Value >= (Controls.Find(text + "2", true).FirstOrDefault() as DateTimePicker).Value)
                                    {
                                        continue;
                                    }

                                    rangeDateTimePickersFilter += "([" + text + "] > '" + (Controls.Find(text + "1", true).FirstOrDefault() as DateTimePicker).Value + "' AND [" + text + "] < '" + (Controls.Find(text + "2", true).FirstOrDefault() as DateTimePicker).Value + "') AND ";
                                }
                                if (rangeDateTimePickersFilter != null)
                                {
                                    rangeDateTimePickersFilter = rangeDateTimePickersFilter.Remove(rangeDateTimePickersFilter.Length - 4, 4);
                                }

                                if (rangeDateTimePickersFilter != null)
                                {
                                    if (!rangeDateTimePickersFilter.Equals(old))
                                    {
                                        OnFilterChanged?.Invoke(this, new EventArgs());
                                    }
                                }
                            };
                        }
                        else
                        {
                            rangeTextBoxes.Add(col.Name);
                            Controls.Find("Panel", true).FirstOrDefault().Controls.Add(new GroupBox()
                            {
                                Text   = col.Name,
                                Name   = col.Name + "GroupBox",
                                Dock   = DockStyle.Top,
                                Height = 65,
                            });

                            Controls.Find(col.Name + "GroupBox", true).FirstOrDefault().Controls.Add(new TextBoxTi()
                            {
                                Name        = col.Name + "1",
                                Dock        = DockStyle.Top,
                                OnlyNumbers = true,
                                MaxLength   = 9,
                            });

                            Controls.Find(col.Name + "GroupBox", true).FirstOrDefault().Controls.Add(new TextBoxTi()
                            {
                                Name        = col.Name + "2",
                                Dock        = DockStyle.Bottom,
                                OnlyNumbers = true,
                                MaxLength   = 9,
                            });

                            Controls.Find(col.Name + "1", true).FirstOrDefault().TextChanged += (s, e) =>
                            {
                                if (resetOn)
                                {
                                    return;
                                }

                                string old = rangeTextBoxesFilter;
                                rangeTextBoxesFilter = null;

                                foreach (string text in rangeTextBoxes)
                                {
                                    if (Controls.Find(text + "1", true).FirstOrDefault().Text == "" || Controls.Find(text + "2", true).FirstOrDefault().Text == "")
                                    {
                                        continue;
                                    }
                                    if (Convert.ToInt32(Controls.Find(text + "1", true).FirstOrDefault().Text) - Convert.ToInt32(Controls.Find(text + "2", true).FirstOrDefault().Text) > 0)
                                    {
                                        continue;
                                    }

                                    rangeTextBoxesFilter += "([" + text + "] > '" + Controls.Find(text + "1", true).FirstOrDefault().Text + "' AND [" + text + "] < '" + Controls.Find(text + "2", true).FirstOrDefault().Text + "') AND ";
                                }
                                if (rangeTextBoxesFilter != null)
                                {
                                    rangeTextBoxesFilter = rangeTextBoxesFilter.Remove(rangeTextBoxesFilter.Length - 4, 4);
                                }

                                if (rangeTextBoxesFilter != null)
                                {
                                    if (!rangeTextBoxesFilter.Equals(old))
                                    {
                                        OnFilterChanged?.Invoke(this, new EventArgs());
                                    }
                                }
                            };

                            Controls.Find(col.Name + "2", true).FirstOrDefault().TextChanged += (s, e) =>
                            {
                                if (resetOn)
                                {
                                    return;
                                }

                                string old = rangeTextBoxesFilter;
                                rangeTextBoxesFilter = null;

                                foreach (string text in rangeTextBoxes)
                                {
                                    if (Controls.Find(text + "1", true).FirstOrDefault().Text == "" || Controls.Find(text + "2", true).FirstOrDefault().Text == "")
                                    {
                                        continue;
                                    }
                                    if (Convert.ToInt32(Controls.Find(text + "1", true).FirstOrDefault().Text) - Convert.ToInt32(Controls.Find(text + "2", true).FirstOrDefault().Text) > 0)
                                    {
                                        continue;
                                    }

                                    rangeTextBoxesFilter += "([" + text + "] > '" + Controls.Find(text + "1", true).FirstOrDefault().Text + "' AND [" + text + "] < '" + Controls.Find(text + "2", true).FirstOrDefault().Text + "') AND ";
                                }
                                if (rangeTextBoxesFilter != null)
                                {
                                    rangeTextBoxesFilter = rangeTextBoxesFilter.Remove(rangeTextBoxesFilter.Length - 4, 4);
                                }

                                if (rangeTextBoxesFilter != null)
                                {
                                    if (!rangeTextBoxesFilter.Equals(old))
                                    {
                                        OnFilterChanged?.Invoke(this, new EventArgs());
                                    }
                                }
                            };
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBoxTi.Show("SQLRequestFilter " + e.Message);
            }

            Supports.GangeGroup(this);
        }
예제 #4
0
        public NS2()
        {
            BorderStyle             = BorderStyle.None;
            Name                    = "tabPageNS2";
            Text                    = "Статистика пользования";
            BackColor               = Supports.headGrey;
            ForeColor               = Supports.headGrey;
            UseVisualStyleBackColor = true;
            bool painted = false;

            AutoScroll = true;


            Timer t = new Timer();

            t.Interval = 3000;
            t.Tick    += (s, e) =>
            {
                UpdateUsersCondition();
            };

            Enter += (s, e) =>
            {
                Profile.DownSign = null;
            };

            Paint += (s, e) =>
            {
                if (painted)
                {
                    return;
                }

                Supports.GangeGroup(this);

                (Controls.Find("logDataGridView", true).FirstOrDefault() as DataGridView).Columns["Пользователь"].Width = 220;
                (Controls.Find("logDataGridView", true).FirstOrDefault() as DataGridView).Columns["What"].Width         = 720;
                Users.Columns["Пользователь"].Width = 220;
                Users.Columns["What"].Width         = 220;
                Users.Columns["Allowed"].Visible    = false;
                Users.Columns["Login"].Visible      = false;
                Users.Columns["Face"].Visible       = false;
                Users.Columns["Rank"].Visible       = false;
                Users.Columns["Department"].Visible = false;
                Users.Columns["NSNote"].Visible     = false;
                (Controls.Find("CurrentUserCardDataGridView", true).FirstOrDefault() as DataGridView).Columns["What"].Width = 470;
                RefreshUser();
                Users.SelectionChanged += (se, arg) =>
                                          RefreshUser();

                painted = true;
            };

            dataBase.ToDisplay("MainSettings");

            NS2Controls();

            Users.DataBindingComplete += (s, e) =>
            {
                foreach (DataGridViewRow row in Users.Rows)
                {
                    if (row.Cells["What"].Value.ToString().Equals("Вошел в систему") || row.Cells["What"].Value.ToString().Equals("Вернулся"))
                    {
                        row.Cells["What"].Style.BackColor              = Supports.Green;
                        row.Cells["What"].Style.SelectionBackColor     = System.Drawing.Color.DarkGreen;
                        row.Cells["LastSeen"].Style.BackColor          = Supports.Green;
                        row.Cells["LastSeen"].Style.SelectionBackColor = System.Drawing.Color.DarkGreen;
                    }
                    else if (row.Cells["What"].Value.ToString().Equals("Вышел из системы") || row.Cells["What"].Value.ToString().Equals(""))
                    {
                        row.Cells["What"].Style.BackColor              = Supports.Red;
                        row.Cells["What"].Style.SelectionBackColor     = Color.DarkRed;
                        row.Cells["LastSeen"].Style.BackColor          = Supports.Red;
                        row.Cells["LastSeen"].Style.SelectionBackColor = Color.DarkRed;
                    }
                    else if (row.Cells["What"].Value.ToString().Equals("Отошел"))
                    {
                        row.Cells["What"].Style.BackColor              = Supports.Yellow;
                        row.Cells["What"].Style.SelectionBackColor     = Color.DarkGoldenrod;
                        row.Cells["LastSeen"].Style.BackColor          = Supports.Yellow;
                        row.Cells["LastSeen"].Style.SelectionBackColor = Color.DarkGoldenrod;
                    }
                    if (Convert.ToBoolean(row.Cells["Allowed"].Value).Equals(true))
                    {
                        row.Cells["Пользователь"].Style.BackColor          = Color.Green;
                        row.Cells["Пользователь"].Style.SelectionBackColor = Color.Green;
                    }
                    else
                    {
                        row.Cells["Пользователь"].Style.BackColor          = Color.Red;
                        row.Cells["Пользователь"].Style.SelectionBackColor = Color.Red;
                    }
                }
            };

            if (dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").Count() != 0)
            {
                Controls.Find("NS2DocumentationTextBox", true).FirstOrDefault().Text = dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").FirstOrDefault()["Content"].ToString();
            }
            if (dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox1").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").Count() != 0)
            {
                Controls.Find("NS2DocumentationTextBox1", true).FirstOrDefault().Text = dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox1").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").FirstOrDefault()["Content"].ToString();
            }
            if (dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox2").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").Count() != 0)
            {
                Controls.Find("NS2DocumentationTextBox2", true).FirstOrDefault().Text = dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox2").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").FirstOrDefault()["Content"].ToString();
            }

            CheckedListBox ch = (Controls.Find("NS2DocumentationCheckedListBox", true).FirstOrDefault() as CheckedListBox);

            foreach (DataRow st in dataBase.SimpleData("SatelliteList WHERE Принадлежность = 'MIL' OR Принадлежность IS NULL OR Принадлежность = 'TWO'").Rows)
            {
                ch.Items.Add(st["НаименованиеИСЗ"].ToString());
                if (dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox").Where(x => x["Content"].ToString() == st["НаименованиеИСЗ"].ToString()).Count() != 0)
                {
                    ch.SetItemChecked(ch.Items.Count - 1, true);
                }
            }

            ch = (Controls.Find("NS2DocumentationCheckedListBox1", true).FirstOrDefault() as CheckedListBox);
            foreach (DataRow st in dataBase.SimpleData("SatelliteList WHERE Принадлежность = 'MIL' OR Принадлежность IS NULL OR Принадлежность = 'TWO'").Rows)
            {
                ch.Items.Add(st["НаименованиеИСЗ"].ToString());
                if (dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox1").Where(x => x["Content"].ToString() == st["НаименованиеИСЗ"].ToString()).Count() != 0)
                {
                    ch.SetItemChecked(ch.Items.Count - 1, true);
                }
            }

            (Controls.Find("NS2DocumentationButton", true).FirstOrDefault() as Button).Click += (s, a) =>
            {
                ch = (Controls.Find("NS2DocumentationCheckedListBox", true).FirstOrDefault() as CheckedListBox);
                DataRow dr;
                if (dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").Count() != 0)
                {
                    dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").FirstOrDefault()["Content"] = (Controls.Find("DeilyReport202", true).FirstOrDefault() as FlowLayoutPanel).Controls.Find("NS2DocumentationTextBox", false).FirstOrDefault().Text;
                }
                else
                {
                    dr            = dataBase.dataset.Tables["MainSettings"].NewRow();
                    dr["Who"]     = "SatelliteForDailyReport";
                    dr["What"]    = "NS2DocumentationTextBox";
                    dr["Content"] = (Controls.Find("DeilyReport202", true).FirstOrDefault() as FlowLayoutPanel).Controls.Find("NS2DocumentationTextBox", false).FirstOrDefault().Text;
                    dataBase.dataset.Tables["MainSettings"].Rows.Add(dr);
                }

                if (dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox1").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").Count() != 0)
                {
                    dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox1").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").FirstOrDefault()["Content"] = (Controls.Find("DeilyReport202", true).FirstOrDefault() as FlowLayoutPanel).Controls.Find("NS2DocumentationTextBox1", false).FirstOrDefault().Text;
                }
                else
                {
                    dr            = dataBase.dataset.Tables["MainSettings"].NewRow();
                    dr["Who"]     = "SatelliteForDailyReport";
                    dr["What"]    = "NS2DocumentationTextBox1";
                    dr["Content"] = Controls.Find("NS2DocumentationTextBox1", false).FirstOrDefault().Text;
                    dataBase.dataset.Tables["MainSettings"].Rows.Add(dr);
                }
                if (dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox2").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").Count() != 0)
                {
                    dataBase.dataset.Tables["MainSettings"].Select().Where(x => x["What"].ToString() == "NS2DocumentationTextBox2").Where(x => x["Who"].ToString() == "SatelliteForDailyReport").FirstOrDefault()["Content"] = (Controls.Find("DeilyReport202", true).FirstOrDefault() as FlowLayoutPanel).Controls.Find("NS2DocumentationTextBox2", false).FirstOrDefault().Text;
                }
                else
                {
                    dr            = dataBase.dataset.Tables["MainSettings"].NewRow();
                    dr["Who"]     = "SatelliteForDailyReport";
                    dr["What"]    = "NS2DocumentationTextBox2";
                    dr["Content"] = (Controls.Find("DeilyReport202", true).FirstOrDefault() as FlowLayoutPanel).Controls.Find("NS2DocumentationTextBox2", false).FirstOrDefault().Text;
                    dataBase.dataset.Tables["MainSettings"].Rows.Add(dr);
                }

                List <string> deletedRows = new List <string>();

                for (var i = 0; i < ch.Items.Count; i++)
                {
                    if (dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox").Where(x => x["Content"].ToString() == ch.Items[i].ToString()).Count() != 0 && ch.GetItemChecked(i) == false)
                    {
                        deletedRows.Add(ch.Items[i].ToString());
                        continue;
                    }
                    if (dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox").Where(x => x["Content"].ToString() == ch.Items[i].ToString()).Count() == 0 && ch.GetItemChecked(i) == true)
                    {
                        dr            = dataBase.dataset.Tables["MainSettings"].NewRow();
                        dr["Who"]     = "SatelliteForDailyReport";
                        dr["What"]    = "NS2DocumentationCheckedListBox";
                        dr["Content"] = ch.Items[i];
                        dataBase.dataset.Tables["MainSettings"].Rows.Add(dr);
                        continue;
                    }
                }

                foreach (string st in deletedRows)
                {
                    dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox").Where(x => x["Content"].ToString() == st).FirstOrDefault().Delete();
                    dataBase.sqlAdapter.Update(dataBase.dataset.Tables["MainSettings"]);
                    dataBase.dataset.Tables["MainSettings"].Clear();
                    dataBase.sqlAdapter.Fill(dataBase.dataset.Tables["MainSettings"]);
                }


                deletedRows.Clear();
                ch = ((Controls.Find("DeilyReport202", true).FirstOrDefault() as FlowLayoutPanel).Controls.Find("NS2DocumentationCheckedListBox1", false).FirstOrDefault() as CheckedListBox);

                for (var i = 0; i < ch.Items.Count; i++)
                {
                    if (dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox1").Where(x => x["Content"].ToString() == ch.Items[i].ToString()).Count() != 0 && ch.GetItemChecked(i) == false)
                    {
                        deletedRows.Add(ch.Items[i].ToString());
                        continue;
                    }
                    if (dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox1").Where(x => x["Content"].ToString() == ch.Items[i].ToString()).Count() == 0 && ch.GetItemChecked(i) == true)
                    {
                        dr            = dataBase.dataset.Tables["MainSettings"].NewRow();
                        dr["Who"]     = "SatelliteForDailyReport";
                        dr["What"]    = "NS2DocumentationCheckedListBox1";
                        dr["Content"] = ch.Items[i];
                        dataBase.dataset.Tables["MainSettings"].Rows.Add(dr);
                        continue;
                    }
                }

                foreach (string st in deletedRows)
                {
                    dataBase.dataset.Tables["MainSettings"].Rows.Cast <DataRow>().Where(x => x["What"].ToString() == "NS2DocumentationCheckedListBox1").Where(x => x["Content"].ToString() == st).FirstOrDefault().Delete();
                    dataBase.sqlAdapter.Update(dataBase.dataset.Tables["MainSettings"]);
                    dataBase.dataset.Tables["MainSettings"].Clear();
                    dataBase.sqlAdapter.Fill(dataBase.dataset.Tables["MainSettings"]);
                }

                dataBase.ToDisplay("MainSettings", onlyAdapter: true);
                dataBase.sqlAdapter.Update(dataBase.dataset.Tables["MainSettings"]);
                dataBase.dataset.Tables["MainSettings"].Clear();
                dataBase.sqlAdapter.Fill(dataBase.dataset.Tables["MainSettings"]);
            };

            string filt = null;

            if (!Profile.userLogin.Equals("Kalter"))
            {
                filt = "WHERE [Department] = " + Profile.userDepartment + " AND [Rank] < 9";
            }
            foreach (DataRow st in dataBase.SimpleData("Login " + filt).Rows.Cast <DataRow>())
            {
                (Controls.Find("logHeadMenCheckedListBox", true).FirstOrDefault() as CheckedListBox).Items.Add(st["Пользователь"]);
            }

            (Controls.Find("logHeadWhatCheckedListBox", true).FirstOrDefault() as CheckedListBox).Items.Add("Удалил");
            (Controls.Find("logHeadWhatCheckedListBox", true).FirstOrDefault() as CheckedListBox).Items.Add("Вошел");
            (Controls.Find("logHeadWhatCheckedListBox", true).FirstOrDefault() as CheckedListBox).Items.Add("Отошел");
            (Controls.Find("logHeadWhatCheckedListBox", true).FirstOrDefault() as CheckedListBox).Items.Add("Добавил");
            (Controls.Find("logHeadWhatCheckedListBox", true).FirstOrDefault() as CheckedListBox).Items.Add("Изменил");

            (Controls.Find("logHeadMenCheckedListBox", true).FirstOrDefault() as CheckedListBox).ItemCheck += (s, e) =>
            {
                RefreshLog(2);
            };

            (Controls.Find("logHeadWhatCheckedListBox", true).FirstOrDefault() as CheckedListBox).ItemCheck += (s, e) =>
            {
                RefreshLog(2);
            };

            (Controls.Find("logHeadTime1DateTimePicker", true).FirstOrDefault() as DateTimePicker).ValueChanged += (s, e) =>
            {
                RefreshLog(2);
            };

            (Controls.Find("logHeadTime2DateTimePicker", true).FirstOrDefault() as DateTimePicker).ValueChanged += (s, e) =>
            {
                RefreshLog(2);
            };

            RefreshLog();

            Users.DataSource = dataBase.dataset.Tables["LoginNS"];

            (Controls.Find("logDataGridView", true).FirstOrDefault() as DataGridView).DataSource = dataBase.dataset.Tables["MainLog"];

            (Controls.Find("CurrentUserCardDataGridView", true).FirstOrDefault() as DataGridView).DataSource = dataBase.dataset.Tables["UserMainLog"];

            UpdateUsersCondition();
            t.Start();
        }
예제 #5
0
        public SatelliteList()
        {
            Name = "tabPageSatelliteList";
            Text = "ИСЗ";

            SatelliteListControls();
            LoadComboUp();
            Supports.GangeGroup(this);

            switch (dataBase.ToCount("SELECT [SatellitesType] FROM [Login] WHERE [Login].[Login] = '" + Profile.userLogin + "'").ToString())
            {
            case "CIV":
                membership                = " WHERE Принадлежность = 'CIV' OR Принадлежность IS NULL OR Принадлежность = 'TWO'";
                Диапазон.SelectedIndex    = 5;
                Поляризация.SelectedIndex = 3;
                break;

            case "MIL":
                membership                = " WHERE Принадлежность = 'MIL' OR Принадлежность IS NULL OR Принадлежность = 'TWO'";
                Диапазон.SelectedIndex    = 4;
                Поляризация.SelectedIndex = 0;
                break;

            default:
                Диапазон.SelectedIndex    = 3;
                Поляризация.SelectedIndex = 3;
                break;
            }



            Enter += (s, e) =>
            {
                if (binded)
                {
                    dataBase.ToDisplay(addCount + membership + " ORDER BY [НаименованиеИСЗ]", dataTableName: "SatelliteList", requestJustByMyself: true);
                    dgv.CurrentCell = dgv["НаименованиеИСЗ", currentRow];
                }
            };
            Leave += (s, e) =>
            {
                currentRow = dgv.CurrentCell.RowIndex;
            };

            dgv.DataBindingComplete += (s, args) =>
            {
                foreach (DataGridViewRow r in dgv.Rows)
                {
                    r.HeaderCell.Value = String.Format("{0}", r.Index + 1);
                }

                if (binded)
                {
                    return;
                }
                binded = true;

                dgv.Columns["ID"].Visible             = false;
                dgv.Columns["Примечание"].Visible     = false;
                dgv.Columns["Описание"].Visible       = false;
                dgv.Columns["Принадлежность"].Visible = false;
                dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

                dgv.SelectionChanged += DownControlsUpdate;

                Диапазон.SelectedValueChanged    += (es, e) => DownSignUpdate();
                Поляризация.SelectedValueChanged += (se, e) => DownSignUpdate();
            };

            dgv.UserDeletedRow  += (s, e) => dataBase.sqlAdapter.Update(dataBase.dataset.Tables["SSALoading"]);
            dgv.UserDeletingRow += (sender, e) =>
            {
                dataBase.ToUpdate(Profile.userLogin, "Удалил запись о спутнике " + '"' + e.Row.Cells["НаименованиеИСЗ"].Value.ToString() + '"' + "\"");
                e.Cancel = false;
            };

            dgv.CellMouseClick += (sender, e) =>
            {
                if (dgv != null)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        Supports.MenuPanel(dgv, e.RowIndex, e.ColumnIndex, typeof(SatelliteList));
                    }
                    if (e.Button == MouseButtons.Left)
                    {
                    }
                }
            };
            dgv.MouseMove += (se, arg) =>
            {
                if (dgv.ContextMenuStrip != null)
                {
                    dgv.ContextMenuStrip.Dispose();
                }
            };
            dgv.KeyDown += (s, e) =>
            {
                if (e.KeyData == Keys.Delete)
                {
                    e.Handled = true;
                }
            };

            editSatellite.Click += (s, e) =>
            {
                if (dgv.SelectedCells.Count == 0)
                {
                    return;
                }

                bool red = false;

                dgv.CurrentCell = dgv.Rows.Cast <DataGridViewRow>().Where(x => x.Cells["НаименованиеИСЗ"].Value.ToString() == НаименованиеИСЗ.Text).FirstOrDefault().Cells["НаименованиеИСЗ"];

                if (MessageBoxTi.Show("Вы действительно хотите редактировать данные этого спутника?", "Редактирование") == MessageResult.Yes)
                {
                    var ind = dgv.SelectedRows[0].Index;

                    if (!dgv.SelectedRows[0].Cells["МеждНомер"].Value.ToString().Equals(МеждНомер.Text))
                    {
                        dataBase.ToUpdate(Profile.userLogin, "Изменил запись о спутнике \"" + НаименованиеИСЗ.Text + "\" в графе \"МеждНомер\" с \"" + МеждНомер.Text + "\" на \"" + МеждНомер.Text + "\"");
                        dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["МеждНомер"] = МеждНомер.Text;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ПСТ"].Value.ToString().Equals(ПСТ.Text))
                    {
                        dataBase.ToUpdate(Profile.userLogin, "Изменил запись о спутнике \"" + НаименованиеИСЗ.Text + "\" в графе \"ПСТ\" с \"" + ПСТ.Text + "\" на \"" + ПСТ.Text + "\"");
                        dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["ПСТ"] = ПСТ.Text;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Производитель"].Value.ToString().Equals(Производитель.Text))
                    {
                        dataBase.ToUpdate(Profile.userLogin, "Изменил запись о спутнике \"" + НаименованиеИСЗ.Text + "\" в графе \"Производитель\" с \"" + Производитель.Text + "\" на \"" + Производитель.Text + "\"");
                        dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["Производитель"] = Производитель.Text;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Описание"].Value.ToString().Equals(Описание.Text))
                    {
                        dataBase.ToUpdate(Profile.userLogin, "Изменил запись о спутнике \"" + НаименованиеИСЗ.Text + "\" в графе \"Описание\" с \"" + Описание.Text + "\" на \"" + Описание.Text + "\"");
                        dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["Описание"] = Описание.Text;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Состояние"].Value.ToString().Equals(Состояние.Text))
                    {
                        dataBase.ToUpdate(Profile.userLogin, "Изменил запись о спутнике \"" + НаименованиеИСЗ.Text + "\" в графе \"Состояние\" с \"" + Состояние.Text + "\" на \"" + Состояние.Text + "\"");
                        dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["Состояние"] = Состояние.Text;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Примечание"].Value.ToString().Equals(Примечание.Text))
                    {
                        dataBase.ToUpdate(Profile.userLogin, "Изменил запись о спутнике \"" + НаименованиеИСЗ.Text + "\" в графе \"Примечание\" с \"" + Примечание.Text + "\" на \"" + Примечание.Text + "\"");
                        dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["Примечание"] = Примечание.Text;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Принадлежность"].Value.ToString().Equals(Принадлежность.Text))
                    {
                        dataBase.ToUpdate(Profile.userLogin, "Изменил запись о спутнике \"" + НаименованиеИСЗ.Text + "\" в графе \"Принадлежность\" с \"" + Принадлежность.Text + "\" на \"" + Принадлежность.Text + "\"");
                        dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["Принадлежность"] = Принадлежность.Text;
                        red = true;
                    }

                    if (red == false)
                    {
                        return;
                    }
                    dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["ID"].ToString().Equals(dgv["ID", ind].Value.ToString())).FirstOrDefault()["Тредакт"] = dataBase.ToCount("SELECT GETDATE()");
                    dataBase.sqlAdapter.Update(dataBase.dataset.Tables["SatelliteList"]);
                    LoadComboUp();
                }
            };
            addSatellite.Click += (s, e) =>
            {
                string h = MessageBoxTi.Show("Добавление спутника", "Введите название спутника", HorizontalAlignment.Left);
                while ((int)dataBase.ToCount("SELECT COUNT(*) FROM[dbo].[SatelliteList] WHERE[dbo].[SatelliteList].[НаименованиеИСЗ] = '" + h + "'") != 0)
                {
                    h = MessageBoxTi.Show("Добавление спутника", "Такой спутник уже есть! Введите другое название спутника", HorizontalAlignment.Left);
                }
                if (h == null || h == "")
                {
                    return;
                }
                DataRow p = dataBase.dataset.Tables["SatelliteList"].NewRow();
                p["НаименованиеИСЗ"] = h;
                p["МеждНомер"]       = МеждНомер.Text;
                p["ПСТ"]             = ПСТ.Text;
                p["Производитель"]   = Производитель.Text;
                p["Описание"]        = Описание.Text;
                p["Состояние"]       = Состояние.Text;
                p["Примечание"]      = Примечание.Text;
                p["Тредакт"]         = dataBase.ToCount("SELECT GETDATE()");
                p["Принадлежность"]  = Принадлежность.Text;

                if (p["НаименованиеИСЗ"].ToString() != "")
                {
                    if (dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["НаименованиеИСЗ"].Equals(p["НаименованиеИСЗ"])).Count() == 0)
                    {
                        dataBase.dataset.Tables["SatelliteList"].Rows.Add(p);
                        dataBase.ToUpdate(Profile.userLogin, "Добавил спутник \"" + p["НаименованиеИСЗ"] + "\"");
                        dataBase.sqlAdapter.Update(dataBase.dataset.Tables["SatelliteList"]);
                        dataBase.ToDisplay(addCount + membership + " ORDER BY [НаименованиеИСЗ]", dataTableName: "SatelliteList", requestJustByMyself: true);
                        dgv.CurrentCell = dgv.Rows.Cast <DataGridViewRow>().Where(x => x.Cells["НаименованиеИСЗ"].Value.ToString() == h).FirstOrDefault().Cells[1];
                    }
                    else
                    {
                        MessageBoxTi.Show("Спутник с таким названием уже есть");
                    }
                }
            };
            goToBand.Click += (s, e) =>
            {
                if (Profile.tabControl1.TabPages.IndexOfKey("WHERE Спутник = \'" + НаименованиеИСЗ.Text + "\' AND Диапазон = \'" + Диапазон.Text + "\' AND Поляризация = \'" + Поляризация.Text + "\'") == -1)
                {
                    if (НаименованиеИСЗ.Text == "")
                    {
                        MessageBoxTi.Show("Введите название спутника");
                    }
                    else
                    {
                        if (dataBase.dataset.Tables["SatelliteList"].Select().Where(x => x["НаименованиеИСЗ"].Equals(НаименованиеИСЗ.Text)).Count() != 0)
                        {
                            if (Convert.ToInt32(Излучения.Text) != 0)
                            {
                                Profile.tabControl1.TabPages.Add(new Loading(НаименованиеИСЗ.Text, Диапазон.Text, Поляризация.Text));
                                Profile.tabControl1.SelectedTab = Profile.tabControl1.TabPages["WHERE Спутник = \'" + НаименованиеИСЗ.Text + "\' AND Диапазон = \'" + Диапазон.Text + "\' AND Поляризация = \'" + Поляризация.Text + "\'"];
                            }
                            else
                            {
                                if (MessageBoxTi.Show("Нет такого типа излучений", "Добавить новое излучение?") == MessageResult.Yes)
                                {
                                    Profile.tabControl1.TabPages.Add(new Loading(НаименованиеИСЗ.Text, Диапазон.Text, Поляризация.Text));
                                    Profile.tabControl1.SelectedTab = Profile.tabControl1.TabPages["WHERE Спутник = \'" + НаименованиеИСЗ.Text + "\' AND Диапазон = \'" + Диапазон.Text + "\' AND Поляризация = \'" + Поляризация.Text + "\'"];
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MessageBoxTi.Show("Спутника с таким названием не существует");
                        }
                    }
                }
                else
                {
                    Profile.tabControl1.SelectedTab = Profile.tabControl1.TabPages["WHERE Спутник = \'" + НаименованиеИСЗ.Text + "\' AND Диапазон = \'" + Диапазон.Text + "\' AND Поляризация = \'" + Поляризация.Text + "\'"];
                    return;
                }
            };

            dataBase.ToDisplay(addCount + membership + " ORDER BY [НаименованиеИСЗ]", dataTableName: "SatelliteList", requestJustByMyself: true);
            dgv.DataSource = dataBase.dataset.Tables["SatelliteList"];
        }
예제 #6
0
        private void LoadControls()
        {
            DataTable load = dataBase.SimpleData("SSALoading");

            Controls.Add(chartTabs);
            chartTabs.TabPages.Add(satellitesStatistics);
            chartTabs.TabPages.Add(beamsStatistics);



            satellitesStatistics.Controls.Add(satellitesStatisticsChart);
            beamsStatistics.Controls.Add(beamsStatisticsChart);

            satellitesStatistics.Controls.Add(satellitesStatisticsPanel);
            beamsStatistics.Controls.Add(beamsStatisticsPanel);


            #region satellitesStatistics

            satellitesStatisticsPanel.Controls.Add(new TreeView()
            {
                Name       = "FilterTreeView",
                Dock       = DockStyle.Fill,
                CheckBoxes = true,
            });

            foreach (string data in load.Columns.Cast <DataColumn>().Select(x => x.ColumnName))
            {
                switch (data)
                {
                case "ID":
                    break;

                case "Частота":
                    break;

                case "ВремяВкл":
                    break;

                case "Тактовая":
                    break;

                case "RПУК":
                    break;

                case "ПУК":
                    break;

                case "Скорость":
                    break;

                case "Протоколы":
                    break;

                case "ХарактерИнфо":
                    break;

                case "Принадлежность":
                    break;

                case "ВидИсточника":
                    break;

                case "ВидОбъекта":
                    break;

                case "ХарРаботы":
                    break;

                case "ВозмСобытие":
                    break;

                case "СостДеятельности":
                    break;

                case "Примечание":
                    break;

                default:
                    (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Add(data, data);

                    if (data == "Состояние")
                    {
                        (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes["Состояние"].BackColor = Supports.darkBlue;
                    }

                    List <string> distinctConditions = load.Rows.Cast <DataRow>().Select(x => x[data].ToString()).OrderBy(x => x).Distinct().ToList();

                    if (distinctConditions.Count < 2)
                    {
                        continue;
                    }

                    foreach (string str in distinctConditions)
                    {
                        if (str == "True")
                        {
                            (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Find(data, false).FirstOrDefault().Nodes.Add(str.ToString(), "Вкл.");
                        }
                        else if (str == "False")
                        {
                            (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Find(data, false).FirstOrDefault().Nodes.Add(str.ToString(), "Выкл.");
                        }
                        else
                        {
                            (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Find(data, false).FirstOrDefault().Nodes.Add(str.ToString(), str.ToString());
                        }
                    }
                    break;
                }
            }

            (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).BeforeCheck += (s, e) =>
            {
                if (e.Node.Parent == null && e.Node.Name != "Состояние")
                {
                    e.Cancel = true;
                }
            };

            (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).AfterCheck += (s, e) =>
            {
                if (e.Node.Parent != null)
                {
                    if (e.Node.Parent.Name == "Состояние" && e.Node.Checked)
                    {
                        e.Node.Parent.Checked = false;
                    }

                    bool checkedCol = false;
                    satelliteCheckBoxesFilter = null;
                    foreach (TreeNode node in (satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes)
                    {
                        foreach (TreeNode nod in node.Nodes)
                        {
                            if (nod.Checked)
                            {
                                satelliteCheckBoxesFilter += '(';
                                checkedCol = true;
                                break;
                            }
                        }
                        if (checkedCol)
                        {
                            foreach (TreeNode nod in node.Nodes)
                            {
                                if (nod.Checked)
                                {
                                    satelliteCheckBoxesFilter += "[" + node.Name + "] = '" + nod.Name + "' OR ";
                                }
                            }
                            checkedCol = false;
                            satelliteCheckBoxesFilter  = satelliteCheckBoxesFilter.Remove(satelliteCheckBoxesFilter.Length - 4, 4);
                            satelliteCheckBoxesFilter += ") AND ";
                        }
                    }
                    if (satelliteCheckBoxesFilter != null)
                    {
                        satelliteCheckBoxesFilter  = satelliteCheckBoxesFilter.Remove(satelliteCheckBoxesFilter.Length - 6, 6);
                        satelliteCheckBoxesFilter += ')';
                    }
                }
                else if (e.Node.Name == "Состояние" && e.Node.Checked)
                {
                    foreach (TreeNode tn in e.Node.Nodes)
                    {
                        tn.Checked = false;
                    }
                }
            };

            satellitesStatisticsPanel.Controls.Add(new GroupBox()
            {
                Name   = "TimeFirstTabControlGroupBox",
                Dock   = DockStyle.Top,
                Text   = "Время",
                Height = 60,
            });

            (satellitesStatisticsPanel.Controls.Find("TimeFirstTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(new DateTimePicker()
            {
                Name = "maxDateTimePicker",
                Dock = DockStyle.Bottom,
            });

            (satellitesStatisticsPanel.Controls.Find("TimeFirstTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(new DateTimePicker()
            {
                Name = "minDateTimePicker",
                Dock = DockStyle.Top,
            });

            satellitesStatisticsPanel.Controls.Add(satellitesCurrentSeriesPanel);

            satellitesStatisticsPanel.Controls.Add(satellitesApply);

            satellitesStatisticsPanel.Controls.Add(satellitesExportExel);

            Point?  satellitesPrevPosition = null;
            ToolTip satellitesToolTip      = new ToolTip();

            satellitesStatisticsChart.MouseMove += (s, e) =>
            {
                var pos = e.Location;
                if (satellitesPrevPosition.HasValue && pos == satellitesPrevPosition.Value)
                {
                    return;
                }
                satellitesToolTip.RemoveAll();
                satellitesPrevPosition = pos;
                var results = satellitesStatisticsChart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);

                foreach (var result in results)
                {
                    if (result.ChartElementType == ChartElementType.DataPoint)
                    {
                        var prop = result.Object as DataPoint;

                        if (prop != null)
                        {
                            var pointXPixel = result.ChartArea.AxisX.ValueToPixelPosition(prop.XValue);
                            var pointYPixel = result.ChartArea.AxisY.ValueToPixelPosition(prop.YValues[0]);

                            if (Math.Abs(pos.X - pointXPixel) < 4)
                            {
                                satellitesToolTip.Show("Время - " + DateTime.FromOADate(prop.XValue), satellitesStatisticsChart, pos.X, pos.Y);
                            }
                        }
                    }
                }
            };

            #endregion

            #region beamsStatistics

            beamsStatisticsPanel.Controls.Add(new TreeView()
            {
                Name       = "FilterTreeView",
                Dock       = DockStyle.Fill,
                CheckBoxes = true,
            });

            foreach (string data in load.Columns.Cast <DataColumn>().Select(x => x.ColumnName))
            {
                switch (data)
                {
                case "ID":
                    break;

                case "Спутник":
                    break;

                case "Диапазон":
                    break;

                case "Поляризация":
                    break;

                case "Частота":
                    break;

                case "ВремяВкл":
                    break;

                case "Тактовая":
                    break;

                case "RПУК":
                    break;

                case "ПУК":
                    break;

                case "Скорость":
                    break;

                case "Протоколы":
                    break;

                case "ХарактерИнфо":
                    break;

                case "Принадлежность":
                    break;

                case "ВидИсточника":
                    break;

                case "ВидОбъекта":
                    break;

                case "ХарРаботы":
                    break;

                case "ВозмСобытие":
                    break;

                case "СостДеятельности":
                    break;

                case "Примечание":
                    break;

                default:
                    (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Add(data, data);

                    if (data == "Состояние")
                    {
                        (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes["Состояние"].BackColor = Supports.darkBlue;
                    }

                    List <string> distinctConditions = load.Rows.Cast <DataRow>().Select(x => x[data].ToString()).OrderBy(x => x).Distinct().ToList();

                    if (distinctConditions.Count < 2)
                    {
                        continue;
                    }

                    foreach (string str in distinctConditions)
                    {
                        if (str == "True")
                        {
                            (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Find(data, false).FirstOrDefault().Nodes.Add(str.ToString(), "Вкл.");
                        }
                        else if (str == "False")
                        {
                            (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Find(data, false).FirstOrDefault().Nodes.Add(str.ToString(), "Выкл.");
                        }
                        else
                        {
                            (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes.Find(data, false).FirstOrDefault().Nodes.Add(str.ToString(), str.ToString());
                        }
                    }
                    break;
                }
            }

            (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).BeforeCheck += (s, e) =>
            {
                if (e.Node.Parent == null)
                {
                    e.Cancel = true;
                }
            };

            (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).AfterCheck += (s, e) =>
            {
                if (e.Node.Parent != null)
                {
                    bool checkedCol = false;
                    beamsCheckBoxesFilter = null;
                    foreach (TreeNode node in (beamsStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes)
                    {
                        foreach (TreeNode nod in node.Nodes)
                        {
                            if (nod.Checked)
                            {
                                beamsCheckBoxesFilter += '(';
                                checkedCol             = true;
                                break;
                            }
                        }
                        if (checkedCol)
                        {
                            foreach (TreeNode nod in node.Nodes)
                            {
                                if (nod.Checked)
                                {
                                    beamsCheckBoxesFilter += "[" + node.Name + "] = '" + nod.Name + "' OR ";
                                }
                            }
                            checkedCol             = false;
                            beamsCheckBoxesFilter  = beamsCheckBoxesFilter.Remove(beamsCheckBoxesFilter.Length - 4, 4);
                            beamsCheckBoxesFilter += ") AND ";
                        }
                    }
                    if (beamsCheckBoxesFilter != null)
                    {
                        beamsCheckBoxesFilter  = beamsCheckBoxesFilter.Remove(beamsCheckBoxesFilter.Length - 6, 6);
                        beamsCheckBoxesFilter += ')';
                    }
                }
                else if (e.Node.Name == "Состояние" && e.Node.Checked)
                {
                    foreach (TreeNode tn in e.Node.Nodes)
                    {
                        tn.Checked = false;
                    }
                }

                RefreshBeams();
            };

            beamsStatisticsPanel.Controls.Add(new GroupBox()
            {
                Name   = "PolarSecondTabControlGroupBox",
                Dock   = DockStyle.Top,
                Height = 37,
                Text   = "Поляризация",
            });

            (beamsStatisticsPanel.Controls.Find("PolarSecondTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(beamsStatisticsPolarizationComboBox);

            beamsStatisticsPanel.Controls.Add(new GroupBox()
            {
                Name   = "BandsSecondTabControlGroupBox",
                Dock   = DockStyle.Top,
                Height = 37,
                Text   = "Диапазон",
            });

            (beamsStatisticsPanel.Controls.Find("BandsSecondTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(beamsStatisticsBandComboBox);

            beamsStatisticsPanel.Controls.Add(new GroupBox()
            {
                Name   = "SatelliteSecondTabControlGroupBox",
                Dock   = DockStyle.Top,
                Height = 37,
                Text   = "Спутники",
            });

            (beamsStatisticsPanel.Controls.Find("SatelliteSecondTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(beamsStatisticsSatelliteComboBox);

            foreach (string sat in dataBase.SimpleData("SatelliteList").Rows.Cast <DataRow>().Select(x => x["НаименованиеИСЗ"].ToString()).OrderBy(x => x).Distinct().ToList())
            {
                beamsStatisticsSatelliteComboBox.Items.Add(sat);
            }

            foreach (string sat in dataBase.SimpleData("FrequencyBand").Rows.Cast <DataRow>().Select(x => x["Наименование диапазона"].ToString()).ToList())
            {
                beamsStatisticsBandComboBox.Items.Add(sat);
            }

            beamsStatisticsPolarizationComboBox.Items.Add("L");
            beamsStatisticsPolarizationComboBox.Items.Add("R");
            beamsStatisticsPolarizationComboBox.Items.Add("V");
            beamsStatisticsPolarizationComboBox.Items.Add("H");

            beamsStatisticsPolarizationComboBox.SelectedIndex = 0;
            beamsStatisticsBandComboBox.SelectedIndex         = 0;
            beamsStatisticsSatelliteComboBox.SelectedIndex    = 0;

            beamsStatisticsSatelliteComboBox.SelectedIndexChanged    += (s, e) => RefreshBeams();
            beamsStatisticsPolarizationComboBox.SelectedIndexChanged += (s, e) => RefreshBeams();
            beamsStatisticsBandComboBox.SelectedIndexChanged         += (s, e) => RefreshBeams();

            beamsStatisticsPanel.Controls.Add(new GroupBox()
            {
                Name   = "TimeFirstTabControlGroupBox",
                Dock   = DockStyle.Top,
                Text   = "Время",
                Height = 60,
            });

            (beamsStatisticsPanel.Controls.Find("TimeFirstTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(new DateTimePicker()
            {
                Name = "maxDateTimePicker",
                Dock = DockStyle.Bottom,
            });

            (beamsStatisticsPanel.Controls.Find("TimeFirstTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(new DateTimePicker()
            {
                Name = "minDateTimePicker",
                Dock = DockStyle.Top,
            });

            beamsStatisticsPanel.Controls.Add(new GroupBox()
            {
                Name   = "BeamsSecondTabControlGroupBox",
                Dock   = DockStyle.Bottom,
                Height = 200,
                Text   = "Излучения",
            });

            (beamsStatisticsPanel.Controls.Find("BeamsSecondTabControlGroupBox", true).FirstOrDefault() as GroupBox).Controls.Add(beamsStatisticsCheckedListBox);

            beamsStatisticsPanel.Controls.Add(beamsCurrentSeriesPanel);

            beamsStatisticsPanel.Controls.Add(beamsApply);

            beamsStatisticsPanel.Controls.Add(beamsExportExel);



            Point?  beamsPrevPosition = null;
            ToolTip beamsToolTip      = new ToolTip();

            beamsStatisticsChart.MouseMove += (s, e) =>
            {
                var pos = e.Location;
                if (beamsPrevPosition.HasValue && pos == beamsPrevPosition.Value)
                {
                    return;
                }
                beamsToolTip.RemoveAll();
                beamsPrevPosition = pos;
                var results = beamsStatisticsChart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);

                foreach (var result in results)
                {
                    if (result.ChartElementType == ChartElementType.DataPoint)
                    {
                        var prop = result.Object as DataPoint;

                        if (prop != null)
                        {
                            var pointXPixel = result.ChartArea.AxisX.ValueToPixelPosition(prop.XValue);
                            var pointYPixel = result.ChartArea.AxisY.ValueToPixelPosition(prop.YValues[0]);

                            if (Math.Abs(pos.X - pointXPixel) < 4)
                            {
                                beamsToolTip.Show("Время - " + DateTime.FromOADate(prop.XValue), beamsStatisticsChart, pos.X, pos.Y);
                            }
                        }
                    }
                }
            };

            #endregion

            beamsApply.Click += (s, e) =>
            {
                beamsStatisticsChart.chartArea.AxisX.Title = "Дата";
                beamsStatisticsChart.chartArea.AxisY.Title = "";
                beamsStatisticsChart.chartArea.AxisY.LabelStyle.ForeColor = Supports.headGrey;

                foreach (string beam in beamsStatisticsCheckedListBox.CheckedItems)
                {
                    int i = 0;
                    int j = 0;
                    foreach (Panel pan in beamsCurrentSeriesPanel.Controls)
                    {
                        if (pan.Controls.Find("Series" + i + "Label", true).FirstOrDefault().Text.Contains("График Состояний для"))
                        {
                            j++;
                        }

                        if (pan.Name == "Series" + i)
                        {
                            i++;
                        }
                    }


                    beamsCurrentSeriesPanel.Controls.Add(new Panel()
                    {
                        Name      = "Series" + i,
                        Dock      = DockStyle.Top,
                        Height    = 20,
                        BackColor = Supports.headGrey,
                    });
                    (beamsStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).MouseClick += (se, a) =>
                    {
                        foreach (Panel pa in beamsCurrentSeriesPanel.Controls)
                        {
                            pa.BackColor = Supports.headGrey;
                        }

                        (beamsStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).BackColor = Supports.headBlue;
                    };
                    (beamsStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).Controls.Add(new TransLabel()
                    {
                        Name      = "Series" + i + "Label",
                        Text      = "График Состояний для " + beam,
                        Dock      = DockStyle.Fill,
                        TextAlign = System.Drawing.ContentAlignment.MiddleCenter,
                        ForeColor = Supports.textWhite,
                    });
                    (beamsStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).Controls.Add(new Button()
                    {
                        Name      = "Series" + i + "Button",
                        Dock      = DockStyle.Right,
                        Width     = 20,
                        Image     = Resources.x1tb,
                        FlatStyle = FlatStyle.Flat,
                    });
                    (beamsStatisticsPanel.Controls.Find("Series" + i + "Button", true).FirstOrDefault() as Button).Click += (se, ar) =>
                    {
                        beamsCurrentSeriesPanel.Controls.RemoveByKey("Series" + i);
                        beamsStatisticsChart.Series.Remove(beamsStatisticsChart.Series["Series" + i]);
                    };
                    beamsStatisticsChart.Series.Add("Series" + i);
                    beamsStatisticsChart.Series["Series" + i].BorderWidth = 3;
                    beamsStatisticsChart.Series["Series" + i].ChartType   = SeriesChartType.StepLine;
                    beamsStatisticsChart.Series["Series" + i].XValueType  = ChartValueType.DateTime;
                    beamsStatisticsChart.Series["Series" + i].LegendText  = " Частота " + beam;
                    beamsStatisticsChart.Series["Series" + i].Points.AddXY((beamsStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date, j * 2);
                    int lastState = j * 2;
                    foreach (DataRow state in dataBase.SimpleData("SSALoading WHERE [ВремяВкл] < '" + (beamsStatisticsPanel.Controls.Find("maxDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date + "' AND [ВремяВкл] > '" +
                                                                  (beamsStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date + "' AND [Спутник] = '" +
                                                                  beamsStatisticsSatelliteComboBox.Text + "' AND [Диапазон] = '" +
                                                                  beamsStatisticsBandComboBox.Text + "' AND [Поляризация] = '" +
                                                                  beamsStatisticsPolarizationComboBox.Text + "' AND [Частота] > '" + (Convert.ToInt32(beam) - 50).ToString()
                                                                  + "' AND [Частота] < '" + (Convert.ToInt32(beam) + 50).ToString() + "'").Rows)
                    {
                        DateTime gf = (DateTime)state["ВремяВкл"];
                        beamsStatisticsChart.Series["Series" + i].Points.AddXY(state["ВремяВкл"], Convert.ToInt32(state["Состояние"]) + j * 2);
                        lastState = Convert.ToInt32(state["Состояние"]) + j * 2;
                    }

                    beamsStatisticsChart.Series["Series" + i].Points.AddXY((beamsStatisticsPanel.Controls.Find("maxDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date, lastState);
                }
            };

            beamsExportExel.Click += (s, e) =>
            {
                if (beamsStatisticsChart.Series.Count == 0)
                {
                    return;
                }
                Documentation.Graphics1(beamsStatisticsChart.Series[0].Points.ToList <DataPoint>(), "Этот график", "Спутник1", Microsoft.Office.Interop.Excel.XlChartType.xlXYScatterLines);
            };

            satellitesApply.Click += (s, e) =>
            {
                satellitesStatisticsChart.chartArea.AxisX.Title = "Дата";
                satellitesStatisticsChart.chartArea.AxisY.Title = "Количество излучений";
                satellitesStatisticsChart.chartArea.AxisY.LabelStyle.ForeColor = Supports.textBlack;

                int i = 0;
                foreach (Panel pan in satellitesCurrentSeriesPanel.Controls)
                {
                    if (pan.Name == "Series" + i)
                    {
                        i++;
                    }
                }


                satellitesCurrentSeriesPanel.Controls.Add(new Panel()
                {
                    Name      = "Series" + i,
                    Dock      = DockStyle.Top,
                    Height    = 20,
                    BackColor = Supports.headGrey,
                });

                (satellitesStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).MouseClick += (se, a) =>
                {
                    foreach (Panel pa in satellitesCurrentSeriesPanel.Controls)
                    {
                        pa.BackColor = Supports.headGrey;
                    }

                    (satellitesStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).BackColor = Supports.headBlue;
                };

                (satellitesStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).Controls.Add(new TransLabel()
                {
                    Name      = "Series" + i + "Label",
                    Text      = "График " + i,
                    Dock      = DockStyle.Fill,
                    TextAlign = ContentAlignment.MiddleCenter,
                    ForeColor = Supports.textWhite,
                });

                (satellitesStatisticsPanel.Controls.Find("Series" + i, true).FirstOrDefault() as Panel).Controls.Add(new Button()
                {
                    Name      = "Series" + i + "Button",
                    Dock      = DockStyle.Right,
                    Width     = 20,
                    Image     = Resources.x1tb,
                    FlatStyle = FlatStyle.Flat,
                });

                (satellitesStatisticsPanel.Controls.Find("Series" + i + "Button", true).FirstOrDefault() as Button).Click += (se, ar) =>
                {
                    satellitesCurrentSeriesPanel.Controls.RemoveByKey("Series" + i);
                    satellitesStatisticsChart.Series.Remove(satellitesStatisticsChart.Series["Series" + i]);
                };

                satellitesStatisticsChart.Series.Add("Series" + i);

                satellitesStatisticsChart.Series["Series" + i].XValueType = ChartValueType.Date;
                satellitesStatisticsChart.Series["Series" + i].LegendText = satelliteCheckBoxesFilter.Replace("(", string.Empty).Replace(")", string.Empty).Replace("AND", ",").Replace("=", ":").Replace("OR", ",").Replace("]", string.Empty).Replace("[", string.Empty).Replace("'", string.Empty);
                //  satellitesStatisticsChart.Series["123"].ChartType = SeriesChartType.Spline;
                //   satellitesStatisticsChart.Series[0].Points.Clear();

                if ((satellitesStatisticsPanel.Controls.Find("FilterTreeView", true).FirstOrDefault() as TreeView).Nodes["Состояние"].Checked)
                {
                    for (int j = 0; j < Convert.ToInt32(((satellitesStatisticsPanel.Controls.Find("maxDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date - (satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date).TotalDays); j++)
                    {
                        satellitesStatisticsChart.Series["Series" + i].Points.AddXY((satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date.AddDays(j), dataBase.ToCount("SELECT " +
                                                                                                                                                                                                                                    "(SELECT COUNT(*) FROM SSALoading WHERE " + satelliteCheckBoxesFilter + " AND [Состояние] = 0 AND [ВремяВкл] > '" + (satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date.AddDays(j).AddHours(9) + "' AND [ВремяВкл] < GETDATE()) - "
                                                                                                                                                                                                                                    + "(SELECT COUNT(*) FROM SSALoading WHERE " + satelliteCheckBoxesFilter + " AND [Состояние] = 1 AND [ВремяВкл] > '" + (satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date.AddDays(j).AddHours(9) + "' AND [ВремяВкл] < GETDATE()) + "
                                                                                                                                                                                                                                    + "(SELECT COUNT(*) FROM Loading WHERE " + satelliteCheckBoxesFilter + " AND [Состояние] = 1)"));
                    }
                }
                else
                {
                    for (int j = 0; j < Convert.ToInt32(((satellitesStatisticsPanel.Controls.Find("maxDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date - (satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date).TotalDays); j++)
                    {
                        satellitesStatisticsChart.Series["Series" + i].Points.AddXY((satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date.AddDays(j), dataBase.ToCount("SELECT COUNT(*) FROM SSALoading WHERE " + satelliteCheckBoxesFilter + " AND [ВремяВкл] > '" + (satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date.AddDays(j) + "' AND [ВремяВкл] < '" + (satellitesStatisticsPanel.Controls.Find("minDateTimePicker", true).FirstOrDefault() as DateTimePicker).Value.Date.AddDays(j + 1) + "'"));
                    }
                }
            };

            satellitesExportExel.Click += (s, e) =>
            {
                if (satellitesStatisticsChart.Series.Count == 0)
                {
                    return;
                }
                Documentation.Graphics1(satellitesStatisticsChart.Series[0].Points.ToList <DataPoint>(), "Этот график", "Спутник1");
            };

            Supports.GangeGroup(this);
        }
예제 #7
0
        public SSALoading()
        {
            Name = "tabPageSSALoading";
            Text = "ССА";

            SSALoadingControls();
            FillBottomControls();
            AddFreeSpase(Controls.Find("SSALoadingPanel0", false).FirstOrDefault());
            Supports.GangeGroup(this);

            dgv.DataBindingComplete += (s, e) =>
            {
                RefreshDGV();

                if (firstBind)
                {
                    return;
                }

                dgv.Columns["ID"].Visible        = false;
                dgv.Columns["Состояние"].Visible = false;

                firstBind = true;

                filter                  = new SQLRequestFilter(dgv, new string[] { "Примечание" });
                filter.Dock             = DockStyle.Left;
                filter.OnFilterChanged += (se, ar) => dataBase.ToDisplay("SSALoading WHERE [ВремяВкл] > '" + dtp.Value + "' AND [ВремяВкл] < '" + dtp.Value.AddDays(1) + "'" + filter.CurrentFilter, dataTableName: "SSALoading");
                Controls.Add(filter);
            };
            dgv.SelectionChanged += UpdateBottomControls;
            Enter += (s, e) =>
            {
                if (firstBind)
                {
                    dataBase.ToDisplay("SSALoading WHERE [ВремяВкл] > '" + dtp.Value + "' AND [ВремяВкл] < '" + dtp.Value.AddDays(1) + "'" + filter.CurrentFilter, dataTableName: "SSALoading", onlyAdapter: true);
                }
            };

            dgv.UserDeletedRow += (sender, e) => dataBase.sqlAdapter.Update(dataBase.dataset.Tables["SSALoading"]);
            dgv.CellMouseClick += (sender, e) =>
            {
                if (dgv != null)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        Supports.MenuPanel(dgv, e.RowIndex, e.ColumnIndex, typeof(SSALoading));
                    }
                    if (e.Button == MouseButtons.Left)
                    {
                    }
                }
            };
            dgv.MouseMove += (s, e) =>
            {
                if (dgv.ContextMenuStrip != null)
                {
                    dgv.ContextMenuStrip.Dispose();
                }
            };

            dgv.KeyUp += (se, e) =>
            {
                if (e.KeyData == Keys.Left)
                {
                    dtp.Value = dtp.Value.AddDays(-1);
                }
                if (e.KeyData == Keys.Right)
                {
                    dtp.Value = dtp.Value.AddDays(1);
                }
                if (e.KeyData == Keys.Tab || e.KeyData == Keys.Enter)
                {
                    e.Handled = true;
                }
            };
            subtractTimeButton.Click += (sender, e) => dtp.Value = dtp.Value.AddDays(-1);
            addTimeButton.Click      += (sender, e) => dtp.Value = dtp.Value.AddDays(1);
            dtp.ValueChanged         += (se, e) =>
            {
                dataBase.ToDisplay("SSALoading WHERE [ВремяВкл] > '" + dtp.Value + "' AND [ВремяВкл] < '" + dtp.Value.AddDays(1) + "'" + filter.CurrentFilter, dataTableName: "SSALoading");
                filter.RefreshNodes(dgv);
            };

            editButton.Click += (s, e) =>
            {
                if (MessageBoxTi.Show("Редактировать?", "Редактирование излучения") == MessageResult.Yes && dgv.RowCount != 0)
                {
                    bool red = false;

                    if (!dgv.SelectedRows[0].Cells["Спутник"].Value.Equals(Спутник.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Спутник"] = Спутник.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Диапазон"].Value.Equals(Диапазон.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Диапазон"] = Диапазон.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Поляризация"].Value.Equals(Поляризация.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Поляризация"] = Поляризация.SelectedItem;
                        red = true;
                    }

                    if (!Convert.ToDecimal(dgv.SelectedRows[0].Cells["Частота"].Value).Equals(Частота.Value))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Частота"] = Частота.Value;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ВремяВкл"].Value.Equals(ВремяВкл.Value))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ВремяВкл"] = ВремяВкл.Value;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ВидДоступа"].Value.Equals(ВидДоступа.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ВидДоступа"] = ВидДоступа.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Модуляция"].Value.Equals(Модуляция.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Модуляция"] = Модуляция.SelectedItem;
                        red = true;
                    }

                    if (!Convert.ToDecimal(dgv.SelectedRows[0].Cells["Тактовая"].Value).Equals(Тактовая.Value))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Тактовая"] = Тактовая.Value;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["RПУК"].Value.Equals(RПУК.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["RПУК"] = RПУК.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ПУК"].Value.Equals(ПУК.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ПУК"] = ПУК.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Скремб"].Value.Equals(Скремб.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Скремб"] = Скремб.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["СистемаСвязи"].Value.Equals(СистемаСвязи.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["СистемаСвязи"] = СистемаСвязи.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Протоколы"].Value.Equals(Протоколы.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Протоколы"] = Протоколы.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ХарактерИнфо"].Value.Equals(ХарактерИнфо.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ХарактерИнфо"] = ХарактерИнфо.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Принадлежность"].Value.Equals(Принадлежность.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Принадлежность"] = Принадлежность.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ВидИсточника"].Value.Equals(ВидИсточника.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ВидИсточника"] = ВидИсточника.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ВидОбъекта"].Value.Equals(ВидОбъекта.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ВидОбъекта"] = ВидОбъекта.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ХарРаботы"].Value.Equals(ХарРаботы.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ХарРаботы"] = ХарРаботы.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["ВозмСобытие"].Value.Equals(ВозмСобытие.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["ВозмСобытие"] = ВозмСобытие.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["СостДеятельности"].Value.Equals(СостДеятельности.SelectedItem))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["СостДеятельности"] = СостДеятельности.SelectedItem;
                        red = true;
                    }

                    if (!dgv.SelectedRows[0].Cells["Примечание"].Value.ToString().Equals(Примечание.Text))
                    {
                        dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Примечание"] = Примечание.Text;
                        red = true;
                    }



                    if (red == false)
                    {
                        return;
                    }

                    dataBase.dataset.Tables["SSALoading"].Select().Where(x => x["ID"].Equals(dgv.SelectedRows[0].Cells["ID"].Value)).FirstOrDefault()["Пользователь"] = Profile.userName;

                    dataBase.sqlAdapter.Update(dataBase.dataset.Tables["SSALoading"]);
                }
            };
            addButton.Click += (s, e) =>
            {
                if (MessageBoxTi.Show("Добавить?", "Добавление излучения") == MessageResult.Yes && dgv.RowCount != 0)
                {
                    DataRow p = (dgv.DataSource as DataTable).NewRow();

                    p["Спутник"]          = Supports.NullOrObjectIfEmpty(Спутник.SelectedItem);
                    p["Диапазон"]         = Supports.NullOrObjectIfEmpty(Диапазон.SelectedItem);
                    p["Поляризация"]      = Supports.NullOrObjectIfEmpty(Поляризация.SelectedItem);
                    p["Частота"]          = Частота.Value;
                    p["ВремяВкл"]         = ВремяВкл.Value;
                    p["Состояние"]        = MessageBoxTi.Show("Состояние", "Излучение включилось или выключилось", new string[] { "Включилось", "Выключилось" }) == MessageResult.Btn0 ? true : false;
                    p["ВидДоступа"]       = Supports.NullOrObjectIfEmpty(ВидДоступа.SelectedItem);
                    p["Модуляция"]        = Supports.NullOrObjectIfEmpty(Модуляция.SelectedItem);
                    p["Тактовая"]         = Тактовая.Value;
                    p["RПУК"]             = Supports.NullOrObjectIfEmpty(RПУК.SelectedItem);
                    p["ПУК"]              = Supports.NullOrObjectIfEmpty(ПУК.SelectedItem);
                    p["Скремб"]           = Supports.NullOrObjectIfEmpty(Скремб.SelectedItem);
                    p["СистемаСвязи"]     = Supports.NullOrObjectIfEmpty(СистемаСвязи.SelectedItem);
                    p["Протоколы"]        = Supports.NullOrObjectIfEmpty(Протоколы.SelectedItem);
                    p["ХарактерИнфо"]     = Supports.NullOrObjectIfEmpty(ХарактерИнфо.SelectedItem);
                    p["Принадлежность"]   = Supports.NullOrObjectIfEmpty(Принадлежность.SelectedItem);
                    p["ВидИсточника"]     = Supports.NullOrObjectIfEmpty(ВидИсточника.SelectedItem);
                    p["ВидОбъекта"]       = Supports.NullOrObjectIfEmpty(ВидОбъекта.SelectedItem);
                    p["ХарРаботы"]        = Supports.NullOrObjectIfEmpty(ХарРаботы.SelectedItem);
                    p["ВозмСобытие"]      = Supports.NullOrObjectIfEmpty(ВозмСобытие.SelectedItem);
                    p["СостДеятельности"] = Supports.NullOrObjectIfEmpty(СостДеятельности.SelectedItem);
                    p["Примечание"]       = Supports.NullOrObjectIfEmpty(Примечание.Text);
                    p["Пользователь"]     = Profile.userName;

                    decimal fer = Частота.Value;
                    dataBase.dataset.Tables["SSALoading"].Rows.Add(p);
                    dataBase.sqlAdapter.Update(dataBase.dataset.Tables["SSALoading"]);
                    dataBase.ToDisplay("SSALoading WHERE [ВремяВкл] > '" + dtp.Value + "' AND [ВремяВкл] < '" + dtp.Value.AddDays(1) + "'" + filter.CurrentFilter, dataTableName: "SSALoading");

                    dgv.CurrentCell = dgv.Rows.Cast <DataGridViewRow>().Where(x => Convert.ToDecimal(x.Cells["Частота"].Value).Equals(fer) && x.Cells["Пользователь"].Value.ToString().Equals(Profile.userName)).FirstOrDefault().Cells["Частота"];
                }
            };

            dataBase.ToDisplay("SSALoading WHERE [ВремяВкл] > '" + dtp.Value + "' AND [ВремяВкл] < '" + dtp.Value.AddDays(1) + "'", dataTableName: "SSALoading");
            dgv.DataSource = dataBase.dataset.Tables["SSALoading"];
        }
예제 #8
0
        public static bool Show(HorizontalAlignment textAlign)
        {
            bool result = false;

            using (var form = new MessageBox("Проверка доступа", 180, 300))
            {
                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new TableLayoutPanel()
                {
                    Name   = "TableLayoutPanel",
                    Dock   = DockStyle.Bottom,
                    Height = 40,
                });


                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new GroupBox()
                {
                    Font = new Font("Times New Roman", 10),
                    Text = "Пароль",
                    Name = "PasswordGroupBox",
                    Dock = DockStyle.Top,
                });

                form.Controls.Find("PasswordGroupBox", true).FirstOrDefault().Controls.Add(new TextBox()
                {
                    Font      = new Font("Times New Roman", 12),
                    Name      = "PasswordTextBox",
                    Dock      = DockStyle.Fill,
                    TextAlign = textAlign,
                });


                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new GroupBox()
                {
                    Font   = new Font("Times New Roman", 10),
                    Text   = "Логин",
                    Name   = "LoginGroupBox",
                    Dock   = DockStyle.Top,
                    Height = 40,
                });

                form.Controls.Find("LoginGroupBox", true).FirstOrDefault().Controls.Add(new TextBox()
                {
                    Font      = new Font("Times New Roman", 12),
                    Name      = "LoginTextBox",
                    Dock      = DockStyle.Fill,
                    TextAlign = textAlign,
                });

                TableLayoutPanel body = (form.Controls.Find("TableLayoutPanel", true).FirstOrDefault() as TableLayoutPanel);
                body.RowStyles.Clear();
                body.ColumnStyles.Clear();
                body.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));

                body.Controls.Add(new Button()
                {
                    Name = "OK",
                    Text = "OK",
                    Dock = DockStyle.Fill,
                }, 1, 0);
                body.Controls.Find("OK", false).FirstOrDefault().Click += (s, e) =>
                {
                    if (Convert.ToInt32(dataBase.ToCount("SELECT COUNT(*) FROM [Login] WHERE [Login] = '" + form.Controls.Find("LoginTextBox", true).FirstOrDefault().Text + "' AND [Password] = '" + form.Controls.Find("PasswordTextBox", true).FirstOrDefault().Text + "' AND [Rank] > 9")) == 0)
                    {
                        result = false;
                    }
                    else
                    {
                        result = true;
                    }

                    form.Dispose();
                };

                body.Controls.Add(new Button()
                {
                    Name = "Cancel",
                    Text = "Отменить",
                    Dock = DockStyle.Fill,
                }, 2, 0);
                body.Controls.Find("Cancel", false).FirstOrDefault().Click += (s, e) =>
                {
                    result = false;
                    form.Dispose();
                };

                Supports.GangeGroup(body);
                form.ShowDialog();

                return(result);
            }
        }
예제 #9
0
        public Profile(string login, Image face = null)
        {
            try
            {
                string name = dataBase.ToCount("SELECT [Пользователь] FROM [Login] WHERE [Login].[Login] = '" + login + "'").ToString();
                userDepartment = Convert.ToInt32(dataBase.ToCount("SELECT [Department] FROM [Login] WHERE [Login].[Login] = '" + login + "'"));
                InitializeComponent();
                Name              = "Department2Base";
                Text              = name;
                userName          = name;
                userLogin         = login;
                pictureBox4.Image = face;
                prepare();
                Supports.GangeGroup(this);

                dataBase.ToUpdate(login, "Вошел в систему");

                new ToolTip().SetToolTip(pictureBox4, userName);

                Supports.GangeGroup(this);
                panel2.BackColor = Supports.headBlue;

                tabControl1.TabPages.Add(new SatelliteList());
                tabControl1.TabPages["tabPageSatelliteList"].Select();

                foreach (string appointment in dataBase.SimpleData("[Appointment] WHERE Login = '******'").Rows.Cast <DataRow>().Select(x => x["Occupation"].ToString()))
                {
                    switch (appointment)
                    {
                    case "ССА":
                        tabControl1.TabPages.Add(new SSALoading());
                        break;

                    case "Администратор":
                        tabControl1.TabPages.Add(new Admin());
                        break;

                    case "Графики":
                        графикToolStripMenuItem.Enabled = true;
                        break;

                    case "НС":
                        tabControl1.TabPages.Add(new NS2());
                        break;

                    case "Документация":
                        splitContainer1.Panel1.Controls.Add(new SidePanel("Документация")
                        {
                            Name = "Report"
                        });
                        splitContainer1.Panel1.Controls.Find("Report", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new RaportsForOperators());
                        break;
                    }
                }

                splitContainer1.Panel2.Controls.Add(new SidePanel("Документация")
                {
                    Name = "Chat"
                });
                splitContainer1.Panel2.Controls.Find("Chat", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new NoteForOperators());


                foreach (TabPage tp in tabControl1.TabPages)
                {
                    окнаToolStripMenuItem.DropDownItems.Add(new ToolStripMenuItem {
                        Name = tp.Name, Text = tp.Text
                    });
                }
                foreach (ToolStripItem tp in окнаToolStripMenuItem.DropDownItems)
                {
                    tp.Click += (s, e) =>
                    {
                        if (tabControl1.TabPages.IndexOfKey(tp.Name) != -1)
                        {
                            tabControl1.SelectTab(tp.Name);
                        }
                        else
                        {
                            switch (tp.Name)
                            {
                            case "tabPageSatelliteList":
                                tabControl1.TabPages.Add(new SatelliteList());
                                tabControl1.TabPages["tabPageSatelliteList"].Select();
                                break;

                            case "tabPageNS2":
                                tabControl1.TabPages.Add(new NS2());
                                tabControl1.TabPages["tabPageNS2"].Select();

                                break;

                            case "tabPageSSALoading":
                                tabControl1.TabPages.Add(new SSALoading());
                                tabControl1.TabPages["tabPageSSALoading"].Select();
                                break;
                            }
                        }
                    };
                }

                пенелиToolStripMenuItem.DropDownItems.Add(new ToolStripMenuItem {
                    Name = "Report", Text = "Отчёты"
                });
                пенелиToolStripMenuItem.DropDownItems.Add(new ToolStripMenuItem {
                    Name = "Chat", Text = "Записи пользователя"
                });

                foreach (ToolStripItem tp in пенелиToolStripMenuItem.DropDownItems)
                {
                    tp.Click += (s, e) =>
                    {
                        switch (tp.Name)
                        {
                        case "Report":
                            if (splitContainer1.Panel1.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Report").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer1.Panel1.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Report"
                                });
                                splitContainer1.Panel1.Controls.Find("Report", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new RaportsForOperators());
                            }
                            else if (splitContainer1.Panel2.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Report").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer1.Panel2.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Report"
                                });
                                splitContainer1.Panel2.Controls.Find("Report", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new RaportsForOperators());
                            }
                            else if (splitContainer2.Panel1.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Report").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer2.Panel1.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Report"
                                });
                                splitContainer2.Panel1.Controls.Find("Report", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new RaportsForOperators());
                            }
                            else if (splitContainer2.Panel2.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Report").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Report").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer2.Panel2.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Report"
                                });
                                splitContainer2.Panel2.Controls.Find("Report", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new RaportsForOperators());
                            }
                            break;

                        case "Chat":

                            if (splitContainer1.Panel1.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Chat").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer1.Panel1.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Chat"
                                });
                                splitContainer1.Panel1.Controls.Find("Chat", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new NoteForOperators());
                            }
                            else if (splitContainer1.Panel2.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Chat").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer1.Panel2.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Chat"
                                });
                                splitContainer1.Panel2.Controls.Find("Chat", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new NoteForOperators());
                            }
                            else if (splitContainer2.Panel1.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Chat").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer2.Panel1.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Chat"
                                });
                                splitContainer2.Panel1.Controls.Find("Chat", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new NoteForOperators());
                            }
                            else if (splitContainer2.Panel2.Controls.Count == 0)
                            {
                                if (!splitContainer1.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer1.Panel2.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel1.Controls.IndexOfKey("Chat").Equals(-1) || !splitContainer2.Panel2.Controls.IndexOfKey("Chat").Equals(-1))
                                {
                                    return;
                                }
                                splitContainer2.Panel2.Controls.Add(new SidePanel("Документация")
                                {
                                    Name = "Chat"
                                });
                                splitContainer2.Panel2.Controls.Find("Chat", false).FirstOrDefault().Controls.Find("Body", false).FirstOrDefault().Controls.Add(new NoteForOperators());
                            }
                            break;
                        }
                    };
                }

                Supports.WorkActivity.Start();
            }
            catch (Exception e)
            {
                MessageBoxTi.Show("Profile " + e.Message);
            }
        }
예제 #10
0
        public static string Show(string headText, string mainText, HorizontalAlignment textAlign)
        {
            string trueHeadText = headText;
            string trueMainText = mainText;

            if (trueHeadText.Length > 75)
            {
                trueHeadText = trueHeadText.Remove(75);
            }
            if (trueMainText.Length > 200)
            {
                trueMainText = trueMainText.Remove(200);
            }

            string result = null;

            using (var form = new MessageBox(trueHeadText))
            {
                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new TableLayoutPanel()
                {
                    Name   = "TableLayoutPanel",
                    Dock   = DockStyle.Bottom,
                    Height = 40,
                });

                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new TextBox()
                {
                    Font      = new Font("Times New Roman", 12),
                    Name      = "BodyTextBox",
                    Dock      = DockStyle.Top,
                    TextAlign = textAlign,
                });

                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new Label()
                {
                    Font        = new Font("Times New Roman", 10),
                    Text        = trueMainText,
                    Name        = "BodyTextBox",
                    Dock        = DockStyle.Top,
                    BorderStyle = BorderStyle.None,
                });

                TableLayoutPanel body = (form.Controls.Find("TableLayoutPanel", true).FirstOrDefault() as TableLayoutPanel);
                body.RowStyles.Clear();
                body.ColumnStyles.Clear();
                body.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));

                body.Controls.Add(new Button()
                {
                    Name = "OK",
                    Text = "OK",
                    Dock = DockStyle.Fill,
                }, 1, 0);
                body.Controls.Find("OK", false).FirstOrDefault().Click += (s, e) =>
                {
                    result = form.Controls.Find("BodyTextBox", true).FirstOrDefault().Text;
                    form.Dispose();
                };

                body.Controls.Add(new Button()
                {
                    Name = "Cancel",
                    Text = "Отменить",
                    Dock = DockStyle.Fill,
                }, 2, 0);
                body.Controls.Find("Cancel", false).FirstOrDefault().Click += (s, e) =>
                {
                    result = "";
                    form.Dispose();
                };

                Supports.GangeGroup(body);
                form.ShowDialog();

                return(result);
            }
        }
예제 #11
0
        /// <summary>
        /// Выводит диалоговое окно с кастомными кнопками, при нажатии на любую возвращается соответствующий результат Btn0, Btn1?
        /// </summary>
        /// <param name="headText"></param>
        /// <param name="mainText"></param>
        /// <param name="buttonNames"></param>
        /// <returns></returns>
        public static MessageResult Show(string headText, string mainText, string[] buttonNames)
        {
            string trueHeadText = headText;
            string trueMainText = mainText;

            if (trueHeadText.Length > 75)
            {
                trueHeadText = trueHeadText.Remove(75);
            }
            if (trueMainText.Length > 200)
            {
                trueMainText = trueMainText.Remove(200);
            }

            MessageResult result = MessageResult.None;

            using (var form = new MessageBox(trueHeadText))
            {
                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new TableLayoutPanel()
                {
                    Name   = "TableLayoutPanel",
                    Dock   = DockStyle.Bottom,
                    Height = 80,
                });

                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new Label()
                {
                    Font        = new Font("Times New Roman", 10),
                    Text        = trueMainText,
                    Name        = "BodyTransLabel",
                    Dock        = DockStyle.Top,
                    Padding     = new Padding(4, 6, 0, 0),
                    MaximumSize = new Size(500, 100),
                    Height      = 80,
                    BorderStyle = BorderStyle.None,
                    AutoSize    = true,
                    BackColor   = Supports.liteTextGray,
                    ForeColor   = Supports.textWhite,
                });

                TableLayoutPanel body = (form.Controls.Find("TableLayoutPanel", true).FirstOrDefault() as TableLayoutPanel);
                body.RowStyles.Clear();
                body.ColumnStyles.Clear();
                body.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
                body.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));

                if (buttonNames.Length > 3)
                {
                    int k = 0;
                    for (int i = 0; i < 2; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            if (k >= buttonNames.Length)
                            {
                                break;
                            }

                            body.Controls.Add(new Button()
                            {
                                Name = buttonNames[k],
                                Text = buttonNames[k],
                                Dock = DockStyle.Fill,
                            }, j, i);

                            body.Controls.Find(buttonNames[k], false).FirstOrDefault().Click += (s, e) =>
                            {
                                result = (MessageResult)buttonNames.Cast <string>().ToList().IndexOf((s as Button).Name);
                                form.Dispose();
                            };
                            k++;
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (j >= buttonNames.Length)
                        {
                            break;
                        }

                        body.Controls.Add(new Button()
                        {
                            Name = buttonNames[j],
                            Text = buttonNames[j],
                            Dock = DockStyle.Fill,
                        }, j, 1);

                        body.Controls.Find(buttonNames[j], false).FirstOrDefault().Click += (s, e) =>
                        {
                            result = (MessageResult)buttonNames.Cast <string>().ToList().IndexOf((s as Button).Name);
                            form.Dispose();
                        };
                    }
                }

                Supports.GangeGroup(body);
                form.ShowDialog();
            }
            return(result);
        }
예제 #12
0
        /// <summary>
        /// Выводит окно с тремя кнопками. "Да", "Нет", "Отмена"
        /// </summary>
        /// <param name="headText">
        /// Текст в заголовке
        /// </param>
        /// <param name="mainText">
        /// Уточняющий текст
        /// </param>
        /// <returns>
        /// MessageResult в соответствии с нажатой кнопкой
        /// </returns>
        public static MessageResult Show(string headText, string mainText)
        {
            string trueHeadText = headText;
            string trueMainText = mainText;

            if (trueHeadText.Length > 75)
            {
                trueHeadText = trueHeadText.Remove(75);
            }
            if (trueMainText.Length > 200)
            {
                trueMainText = trueMainText.Remove(200);
            }

            MessageResult result = MessageResult.None;

            using (var form = new MessageBox(trueHeadText))
            {
                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new TableLayoutPanel()
                {
                    Name   = "TableLayoutPanel",
                    Dock   = DockStyle.Bottom,
                    Height = 40,
                });

                form.Controls.Find("Body", false).FirstOrDefault().Controls.Add(new Label()
                {
                    Font        = new Font("Times New Roman", 10),
                    Text        = trueMainText,
                    Name        = "BodyTransLabel",
                    Dock        = DockStyle.Top,
                    Padding     = new Padding(4, 6, 0, 0),
                    MaximumSize = new Size(500, 100),
                    Height      = 80,
                    BorderStyle = BorderStyle.None,
                    AutoSize    = true,
                    BackColor   = Supports.liteTextGray,
                    ForeColor   = Supports.textWhite,
                });

                TableLayoutPanel body = (form.Controls.Find("TableLayoutPanel", true).FirstOrDefault() as TableLayoutPanel);
                body.RowStyles.Clear();
                body.ColumnStyles.Clear();
                body.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));
                body.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33));

                body.Controls.Add(new Button()
                {
                    Name = "Yes",
                    Text = "Да",
                    Dock = DockStyle.Fill,
                }, 0, 0);
                body.Controls.Find("Yes", false).FirstOrDefault().Click += (s, e) =>
                {
                    result = MessageResult.Yes;
                    form.Dispose();
                };

                body.Controls.Add(new Button()
                {
                    Name = "No",
                    Text = "Нет",
                    Dock = DockStyle.Fill,
                }, 1, 0);
                body.Controls.Find("No", false).FirstOrDefault().Click += (s, e) =>
                {
                    result = MessageResult.No;
                    form.Dispose();
                };

                body.Controls.Add(new Button()
                {
                    Name = "Cancel",
                    Text = "Отменить",
                    Dock = DockStyle.Fill,
                }, 2, 0);
                body.Controls.Find("Cancel", false).FirstOrDefault().Click += (s, e) =>
                {
                    result = MessageResult.Cancel;
                    form.Dispose();
                };

                Supports.GangeGroup(body);

                form.ShowDialog();
            }


            return(result);
        }
예제 #13
0
        public Panel UserCard(string Login, bool add = false)
        {
            try
            {
                Bitmap    im             = Resources.person;
                string    satellitesType = null;
                string    password       = null;
                string    name           = null;
                string    department     = null;
                int       rank           = -1;
                DataTable occupation     = null;

                if (!add)
                {
                    DataTable person = dataBase.SimpleData("[Login] WHERE [Login].[Login] = '" + Login + "'");
                    occupation     = dataBase.SimpleData("[Appointment] WHERE [Appointment].[Login] = '" + Login + "'");
                    satellitesType = person.Rows[0]["SatellitesType"].ToString();
                    password       = person.Rows[0]["Password"].ToString();
                    name           = person.Rows[0]["Пользователь"].ToString();
                    department     = person.Rows[0]["Department"].ToString();
                    im             = (Bitmap)Image.FromStream(new MemoryStream((byte[])person.Rows[0]["Face"]));
                    rank           = Convert.ToInt32(person.Rows[0]["Rank"]);
                }

                Panel myCard = new Panel()
                {
                    Name      = Login,
                    Width     = 200,
                    Height    = 500,
                    BackColor = Supports.backBlack,
                    Padding   = new Padding(3),
                };

                myCard.Controls.Add(new FlowLayoutPanel()
                {
                    Dock = DockStyle.Fill,

                    BorderStyle = BorderStyle.None,
                    Name        = "FlowLayoutPanel",
                    Width       = 200,
                    Height      = 300,
                    BackColor   = Supports.headGrey,
                });

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new PictureBox()
                {
                    Name     = "Picture",
                    Image    = im,
                    SizeMode = PictureBoxSizeMode.Zoom,
                    Width    = 200,
                    Height   = 100,
                });

                (myCard.Controls.Find("Picture", true).FirstOrDefault() as PictureBox).Click += (s, args) =>
                {
                    OpenFileDialog openFileDialog1 = new OpenFileDialog();
                    openFileDialog1.Filter = "Image files|*.jpeg;*.jpg;*.png;*.gif;*.bmp;*.tiff;*.tif;*.jfif;*.jpe;*.dib;";
                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        (myCard.Controls.Find("Picture", true).FirstOrDefault() as PictureBox).Image = Image.FromStream(openFileDialog1.OpenFile());
                    }
                };

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new GroupBox()
                {
                    Name   = "GroupBoxAppointment",
                    Text   = "Тип спутника",
                    Width  = 188,
                    Height = 40,
                });

                (myCard.Controls.Find("GroupBoxAppointment", true).FirstOrDefault() as GroupBox).Controls.Add(new ComboBox()
                {
                    Name          = "SatellitesTypeComboBox",
                    Dock          = DockStyle.Fill,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                });

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new Panel()
                {
                    Name   = "PanelRankAndDep",
                    Width  = 188,
                    Height = 40,
                });

                (myCard.Controls.Find("PanelRankAndDep", true).FirstOrDefault() as Panel).Controls.Add(new GroupBox()
                {
                    Name  = "GroupBoxDepartment",
                    Text  = "Отдел",
                    Width = 60,
                    Dock  = DockStyle.Left
                });

                (myCard.Controls.Find("PanelRankAndDep", true).FirstOrDefault() as Panel).Controls.Add(new GroupBox()
                {
                    Name  = "GroupBoxRank",
                    Text  = "Звание",
                    Width = 126,
                    Dock  = DockStyle.Right
                });

                (myCard.Controls.Find("GroupBoxDepartment", true).FirstOrDefault() as GroupBox).Controls.Add(new ComboBox()
                {
                    Name          = "DepartmentComboBox",
                    Dock          = DockStyle.Fill,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                });

                (myCard.Controls.Find("GroupBoxRank", true).FirstOrDefault() as GroupBox).Controls.Add(new ComboBox()
                {
                    Name          = "RankComboBox",
                    Dock          = DockStyle.Fill,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                });

                for (var i = 1; i < 9; i++)
                {
                    (myCard.Controls.Find("DepartmentComboBox", true).FirstOrDefault() as ComboBox).Items.Add(i.ToString());
                }

                foreach (var ranks in Enum.GetValues(typeof(Supports.Ranks)))
                {
                    (myCard.Controls.Find("RankComboBox", true).FirstOrDefault() as ComboBox).Items.Add(ranks.ToString());
                }

                if (rank != -1)
                {
                    (myCard.Controls.Find("RankComboBox", true).FirstOrDefault() as ComboBox).SelectedItem = ((Supports.Ranks)rank).ToString();
                }

                if (department != null)
                {
                    (myCard.Controls.Find("DepartmentComboBox", true).FirstOrDefault() as ComboBox).SelectedItem = department;
                }
                else
                {
                    (myCard.Controls.Find("DepartmentComboBox", true).FirstOrDefault() as ComboBox).SelectedItem = 2;
                }

                (myCard.Controls.Find("SatellitesTypeComboBox", true).FirstOrDefault() as ComboBox).Items.Add("MIL");
                (myCard.Controls.Find("SatellitesTypeComboBox", true).FirstOrDefault() as ComboBox).Items.Add("CIV");
                (myCard.Controls.Find("SatellitesTypeComboBox", true).FirstOrDefault() as ComboBox).Items.Add("TWO");

                if (satellitesType != null)
                {
                    (myCard.Controls.Find("SatellitesTypeComboBox", true).FirstOrDefault() as ComboBox).SelectedItem = satellitesType;
                }
                else
                {
                    (myCard.Controls.Find("SatellitesTypeComboBox", true).FirstOrDefault() as ComboBox).SelectedIndex = 1;
                }

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new GroupBox()
                {
                    Name   = "GroupBoxName",
                    Text   = "Пользователь",
                    Width  = 188,
                    Height = 40,
                });

                (myCard.Controls.Find("GroupBoxName", true).FirstOrDefault() as GroupBox).Controls.Add(new TextBox()
                {
                    Name      = "Name",
                    Text      = name ?? "",
                    Dock      = DockStyle.Fill,
                    MaxLength = 50,
                });

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new GroupBox()
                {
                    Name   = "GroupBoxLogin",
                    Text   = "Логин",
                    Width  = 188,
                    Height = 40,
                });

                (myCard.Controls.Find("GroupBoxLogin", true).FirstOrDefault() as GroupBox).Controls.Add(new TextBox()
                {
                    Name      = "Login",
                    Text      = Login ?? "",
                    Dock      = DockStyle.Fill,
                    Enabled   = false,
                    MaxLength = 15
                });

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new GroupBox()
                {
                    Name   = "GroupBoxPassword",
                    Text   = "Пароль",
                    Width  = 188,
                    Height = 40,
                });

                (myCard.Controls.Find("GroupBoxPassword", true).FirstOrDefault() as GroupBox).Controls.Add(new TextBox()
                {
                    Name         = "Password",
                    Text         = password ?? "",
                    Dock         = DockStyle.Fill,
                    PasswordChar = '*',
                    MaxLength    = 15,
                });

                (myCard.Controls.Find("Password", true).FirstOrDefault() as TextBox).Click += (s, a) =>
                {
                    (myCard.Controls.Find("Password", true).FirstOrDefault() as TextBox).PasswordChar = '\0';
                };

                (myCard.Controls.Find("Password", true).FirstOrDefault() as TextBox).LostFocus += (s, a) =>
                {
                    (myCard.Controls.Find("Password", true).FirstOrDefault() as TextBox).PasswordChar = '*';
                };

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new GroupBox()
                {
                    Name   = "GroupBoxOccupation",
                    Text   = "Права",
                    Width  = 188,
                    Height = 120,
                });

                (myCard.Controls.Find("GroupBoxOccupation", true).FirstOrDefault() as GroupBox).Controls.Add(new CheckedListBox()
                {
                    Name        = "Occupation",
                    Dock        = DockStyle.Fill,
                    BorderStyle = BorderStyle.None,
                    BackColor   = Supports.headGrey,
                    ForeColor   = Supports.textWhite,
                });

                CheckedListBox OccupationCheckedListBox = (myCard.Controls.Find("Occupation", true).FirstOrDefault() as CheckedListBox);

                OccupationCheckedListBox.MouseLeave += (sen, arg) =>
                {
                    (sen as CheckedListBox).ClearSelected();
                };

                (myCard.Controls.Find("FlowLayoutPanel", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new Panel()
                {
                    Name   = "Panel1",
                    Width  = 188,
                    Height = 20
                });

                (myCard.Controls.Find("Panel1", true).FirstOrDefault() as Panel).Controls.Add(new Button()
                {
                    Name      = "editButton",
                    Image     = add == false ? Resources.edit : Resources.add,
                    Dock      = DockStyle.Left,
                    Width     = 90,
                    FlatStyle = FlatStyle.Flat,
                    ForeColor = Supports.textBlack,
                });

                (myCard.Controls.Find("Panel1", true).FirstOrDefault() as Panel).Controls.Add(new Button()
                {
                    Name      = "eraseButton",
                    Image     = Resources.erase,
                    Dock      = DockStyle.Right,
                    Width     = 90,
                    FlatStyle = FlatStyle.Flat,
                    ForeColor = Supports.textBlack,
                });

                new ToolTip().SetToolTip((myCard.Controls.Find("editButton", true).FirstOrDefault() as Button), "Внести изменения");
                new ToolTip().SetToolTip((myCard.Controls.Find("eraseButton", true).FirstOrDefault() as Button), "Удалить пользователя");

                (myCard.Controls.Find("editButton", true).FirstOrDefault() as Button).Click += (sen, arg) =>
                {
                    if (MessageBoxTi.Show("Вы действительно хотите изменить данные пользователя?", "Редактирование") == MessageResult.Yes)
                    {
                        if (dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).Count() != 0)
                        {
                            List <object> delID = new List <object>();
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["Password"]       = ((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Password", true).FirstOrDefault() as TextBox).Text;
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["Face"]           = sup.ImToBy(((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Picture", true).FirstOrDefault() as PictureBox).Image);
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["Пользователь"]   = ((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Name", true).FirstOrDefault() as TextBox).Text;
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["Login"]          = ((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Login", true).FirstOrDefault() as TextBox).Text;
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["SatellitesType"] = (myCard.Controls.Find("SatellitesTypeComboBox", true).FirstOrDefault() as ComboBox).SelectedItem;
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["Department"]     = (myCard.Controls.Find("DepartmentComboBox", true).FirstOrDefault() as ComboBox).SelectedItem;
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["Allowed"]        = 1;
                            dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault()["Rank"]           = (int)Enum.Parse(typeof(Supports.Ranks), (myCard.Controls.Find("RankComboBox", true).FirstOrDefault() as ComboBox).SelectedItem.ToString());


                            for (int j = 0; j < OccupationCheckedListBox.Items.Count; j++)
                            {
                                if (OccupationCheckedListBox.GetItemChecked(j) && dataBase.dataset.Tables["Appointment"].Rows.Cast <DataRow>().Where(x => x["Login"].ToString().Equals(Login)).Where(x => x["Occupation"].ToString().Equals(OccupationCheckedListBox.Items[j].ToString())).Count() == 0)
                                {
                                    DataRow dr = dataBase.dataset.Tables["Appointment"].NewRow();
                                    dr["Login"]      = Login;
                                    dr["Occupation"] = OccupationCheckedListBox.Items[j].ToString();
                                    dataBase.dataset.Tables["Appointment"].Rows.Add(dr);
                                }

                                if (!OccupationCheckedListBox.GetItemChecked(j) && dataBase.dataset.Tables["Appointment"].Rows.Cast <DataRow>().Where(x => x["Login"].ToString().Equals(Login)).Where(x => x["Occupation"].ToString().Equals(OccupationCheckedListBox.Items[j].ToString())).Count() != 0)
                                {
                                    delID.Add(dataBase.dataset.Tables["Appointment"].Rows.Cast <DataRow>().Where(x => x["Login"].ToString().Equals(Login)).Where(x => x["Occupation"].ToString().Equals(OccupationCheckedListBox.Items[j].ToString())).FirstOrDefault()[0]);
                                }
                            }

                            if (delID.Count != 0)
                            {
                                dataBase.ToDisplay("Appointment", onlyAdapter: true);
                            }

                            foreach (var del in delID)
                            {
                                string k = dataBase.dataset.Tables["Appointment"].Select().Where(x => x["Occupation"].ToString().Equals("Admin")).FirstOrDefault()[0].ToString();

                                if (dataBase.dataset.Tables["Appointment"].Select().Where(x => x["Occupation"].ToString().Equals("Admin")).Count() == 1 && dataBase.dataset.Tables["Appointment"].Select().Where(x => x["Occupation"].ToString().Equals("Admin")).FirstOrDefault()[0].ToString().Equals(del.ToString()))
                                {
                                    OccupationCheckedListBox.SetItemChecked(3, true);
                                    continue;
                                }
                                dataBase.dataset.Tables["Appointment"].Rows.Cast <DataRow>().Where(x => x["Login"].ToString().Equals(Login)).Where(x => x["ID"].Equals(del)).FirstOrDefault().Delete();
                                dataBase.sqlAdapter.Update(dataBase.dataset.Tables["Appointment"]);
                                dataBase.dataset.Tables["Appointment"].Clear();
                                dataBase.sqlAdapter.Fill(dataBase.dataset.Tables["Appointment"]);
                            }

                            dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login", onlyAdapter: true);
                            dataBase.sqlAdapter.Update(dataBase.dataset.Tables["Login"]);
                            dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login");
                            dataBase.ToDisplay("Appointment", onlyAdapter: true);
                            dataBase.sqlAdapter.Update(dataBase.dataset.Tables["Appointment"]);
                            dataBase.ToDisplay("Appointment");

                            return;
                        }
                        else
                        {
                            DataRow dr1 = dataBase.dataset.Tables["Login"].NewRow();
                            dr1["Password"]       = ((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Password", true).FirstOrDefault() as TextBox).Text;
                            dr1["Face"]           = sup.ImToBy(((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Picture", true).FirstOrDefault() as PictureBox).Image);
                            dr1["Пользователь"]   = ((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Name", true).FirstOrDefault() as TextBox).Text;
                            dr1["Login"]          = ((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Login", true).FirstOrDefault() as TextBox).Text;
                            dr1["SatellitesType"] = (myCard.Controls.Find("SatellitesTypeComboBox", true).FirstOrDefault() as ComboBox).SelectedItem;
                            dr1["Department"]     = (myCard.Controls.Find("DepartmentComboBox", true).FirstOrDefault() as ComboBox).SelectedItem;
                            dr1["Allowed"]        = 1;
                            dr1["Rank"]           = (int)Enum.Parse(typeof(Supports.Ranks), (myCard.Controls.Find("RankComboBox", true).FirstOrDefault() as ComboBox).SelectedItem.ToString());

                            dataBase.dataset.Tables["Login"].Rows.Add(dr1);

                            for (int j = 0; j < OccupationCheckedListBox.Items.Count; j++)
                            {
                                if (OccupationCheckedListBox.GetItemChecked(j) && dataBase.dataset.Tables["Appointment"].Rows.Cast <DataRow>().Where(x => x["Login"].ToString().Equals(Login) && x["Occupation"].ToString().Equals(OccupationCheckedListBox.Items[j].ToString())).Count() == 0)
                                {
                                    DataRow dr = dataBase.dataset.Tables["Appointment"].NewRow();
                                    dr["Login"]      = ((Controls.Find(Login, true).FirstOrDefault() as Panel).Controls.Find("Login", true).FirstOrDefault() as TextBox).Text;
                                    dr["Occupation"] = OccupationCheckedListBox.Items[j].ToString();
                                    dataBase.dataset.Tables["Appointment"].Rows.Add(dr);
                                }
                            }

                            dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login", onlyAdapter: true);
                            dataBase.sqlAdapter.Update(dataBase.dataset.Tables["Login"]);
                            dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login");
                            dataBase.ToDisplay("Appointment", onlyAdapter: true);
                            dataBase.sqlAdapter.Update(dataBase.dataset.Tables["Appointment"]);
                            dataBase.ToDisplay("Appointment");


                            (myCard.Controls.Find("editButton", true).FirstOrDefault() as Button).Image = Resources.edit;
                            return;
                        }
                    }
                };

                (myCard.Controls.Find("eraseButton", true).FirstOrDefault() as Button).Click += (sen, arg) =>
                {
                    if (dataBase.dataset.Tables["Appointment"].Select().Where(x => x["Occupation"].ToString().Equals("Admin")).Count() == 1 && OccupationCheckedListBox.GetItemChecked(3))
                    {
                        MessageBoxTi.Show("Невозможно удалить последнего администратора");
                        return;
                    }
                    if (dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).Count() != 0)
                    {
                        dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(Login)).FirstOrDefault().Delete();
                        foreach (DataRow dr in dataBase.dataset.Tables["Appointment"].Select().Where(x => x["Login"].ToString().Equals(Login)))
                        {
                            dr.Delete();
                        }
                        dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login", onlyAdapter: true);
                        dataBase.sqlAdapter.Update(dataBase.dataset.Tables["Login"]);
                        dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login");
                        dataBase.ToDisplay("Appointment", onlyAdapter: true);
                        dataBase.sqlAdapter.Update(dataBase.dataset.Tables["Appointment"]);
                        dataBase.ToDisplay("Appointment");
                        Controls.Remove(Controls.Find(Login, true).FirstOrDefault());
                    }
                    else
                    {
                        Controls.Remove(Controls.Find(Login, true).FirstOrDefault());
                    }
                };

                OccupationCheckedListBox.Items.Add("Администратор");
                OccupationCheckedListBox.Items.Add("ССА");
                OccupationCheckedListBox.Items.Add("Графики");
                OccupationCheckedListBox.Items.Add("НС");
                OccupationCheckedListBox.Items.Add("Документация");

                if (occupation != null)
                {
                    for (int j = 0; j < OccupationCheckedListBox.Items.Count; j++)
                    {
                        if ((occupation.Rows.Cast <DataRow>().Where(x => x["Login"].ToString().Equals(Login)).Where(x => x["Occupation"].ToString().Equals(OccupationCheckedListBox.Items[j].ToString()))).ToList().Count != 0)
                        {
                            OccupationCheckedListBox.SetItemChecked(j, true);
                        }
                    }
                }

                Supports.GangeGroup(myCard);
                return(myCard);
            }
            catch (Exception e)
            {
                MessageBoxTi.Show("Admin.UserCard " + e.Message);
                return(null);
            }
        }
예제 #14
0
        public Admin()
        {
            try
            {
                BorderStyle = BorderStyle.None;
                Name        = "tabPageAdmin";
                Text        = "Админ";
                BackColor   = Supports.headGrey;
                ForeColor   = Supports.headGrey;

                Controls.Add(new FlowLayoutPanel()
                {
                    BorderStyle = BorderStyle.None,
                    Name        = "FlowLayoutPanelAdmin",
                    Dock        = DockStyle.Fill,
                    AutoScroll  = true,
                });

                Controls.Add(new Panel()
                {
                    Name  = "foreignPanelAdmin",
                    Dock  = DockStyle.Right,
                    Width = 440,
                });

                (Controls.Find("foreignPanelAdmin", true).FirstOrDefault() as Panel).Controls.Add(foreignPeople);

                (Controls.Find("foreignPanelAdmin", true).FirstOrDefault() as Panel).Controls.Add(new Label()
                {
                    Font      = new Font("Times New Roman", 12, FontStyle.Bold),
                    TextAlign = ContentAlignment.MiddleCenter,
                    Dock      = DockStyle.Top,
                    Text      = "Грингос",
                });

                Controls.Add(new FlowLayoutPanel()
                {
                    BorderStyle = BorderStyle.None,
                    Name        = "FlowLayoutPanelData",
                    Dock        = DockStyle.Top,
                    Height      = 30,
                    Padding     = new Padding(3),
                    BackColor   = Supports.backBlack,
                });

                bool adminFirst = false;

                Enter += (se, e) =>
                {
                    try
                    {
                        dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login", onlyAdapter: true);

                        if (adminFirst == true)
                        {
                            return;
                        }

                        foreach (DataRow dr in dataBase.dataset.Tables["Login"].Rows.Cast <DataRow>().Where(x => Convert.ToInt32(x["Department"]) == 2))
                        {
                            (Controls.Find("FlowLayoutPanelAdmin", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(UserCard(dr["Login"].ToString()));
                        }


                        (Controls.Find("FlowLayoutPanelAdmin", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new Panel()
                        {
                            Name      = "AddPanel",
                            Width     = 200,
                            Height    = 410,
                            BackColor = Supports.backBlack,
                            Padding   = new Padding(3),
                        });


                        (Controls.Find("FlowLayoutPanelData", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new Label()
                        {
                            Name     = "DataLabel",
                            AutoSize = true,
                            Text     = "Текущая версия программы:",
                            Padding  = new Padding(0, 9, 0, 0),
                        });

                        (Controls.Find("FlowLayoutPanelData", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new Label()
                        {
                            Name     = "DataLabel1",
                            Text     = (string)dataBase.ToCount("SELECT TOP 1 [Version] FROM [dbo].[ProgVer] ORDER BY [dbo].[ProgVer].[Version] DESC"),
                            AutoSize = true,
                            Padding  = new Padding(0, 9, 0, 0),
                        });



                        (Controls.Find("FlowLayoutPanelData", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(new Button()
                        {
                            Name      = "DataButton",
                            Text      = "Добавить новую версию",
                            Width     = 160,
                            FlatStyle = FlatStyle.Flat,
                        });

                        (Controls.Find("DataButton", true).FirstOrDefault() as Button).Click += (s, arg) =>
                        {
                            OpenFileDialog openFileDialog1 = new OpenFileDialog();
                            openFileDialog1.Filter = "EXECUTE files|*.exe;";
                            if (openFileDialog1.ShowDialog() == DialogResult.OK)
                            {
                                dataBase.ToUpdate(openFileDialog1.OpenFile(), Application.ProductVersion);
                            }

                            (Controls.Find("DataLabel1", true).FirstOrDefault() as Label).Text = (string)dataBase.ToCount("SELECT TOP 1 [Version] FROM [dbo].[ProgVer] ORDER BY [dbo].[ProgVer].[Version] DESC");
                        };

                        (Controls.Find("AddPanel", true).FirstOrDefault() as Panel).Controls.Add(new Button()
                        {
                            Name      = "AddPanelButton",
                            Image     = Resources.plus,
                            Dock      = DockStyle.Fill,
                            FlatStyle = FlatStyle.Flat,
                            ForeColor = Supports.textBlack,
                            BackColor = Supports.headGrey
                        });

                        (Controls.Find("AddPanelButton", true).FirstOrDefault() as Button).Click += (s, arg) =>
                        {
                            string log = MessageBoxTi.Show("Логин", "Придумайте логин", HorizontalAlignment.Left);
                            while (log.Length > 15)
                            {
                                log = MessageBoxTi.Show("Логин", "Пользователь с таким ологином уже существует. Придумайте другой логин!", HorizontalAlignment.Left);
                                if (log == null || log == "")
                                {
                                    return;
                                }
                            }

                            if (dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(log)).Count() == 0 && log != "")
                            {
                                (Controls.Find("FlowLayoutPanelAdmin", true).FirstOrDefault() as FlowLayoutPanel).Controls.Add(UserCard(log, true));
                                (Controls.Find("FlowLayoutPanelAdmin", true).FirstOrDefault() as FlowLayoutPanel).Controls.SetChildIndex((Controls.Find("FlowLayoutPanelAdmin", true).FirstOrDefault() as FlowLayoutPanel).Controls.Find("AddPanel", false).FirstOrDefault(), (Controls.Find("FlowLayoutPanelAdmin", true).FirstOrDefault() as FlowLayoutPanel).Controls.Count);
                                return;
                            }
                            else if (log == null || log == "")
                            {
                                return;
                            }
                            else
                            {
                                MessageBoxTi.Show("Такой логин уже существует");
                                return;
                            }
                        };
                        Controls.Find("AddPanelButton", true).FirstOrDefault().Focus();
                        adminFirst = true;



                        foreach (DataRow dr in dataBase.dataset.Tables["Login"].Rows.Cast <DataRow>().Where(x => Convert.ToInt32(x["Department"]) != 2))
                        {
                            foreignPeople.Controls.Add(UserCard(dr["Login"].ToString()));
                        }

                        foreignPeople.Controls.Add(new Panel()
                        {
                            Name      = "AddPanel",
                            Width     = 200,
                            Height    = 410,
                            BackColor = Supports.backBlack,
                            Padding   = new Padding(3),
                        });

                        (foreignPeople.Controls.Find("AddPanel", true).FirstOrDefault() as Panel).Controls.Add(new Button()
                        {
                            Name      = "AddPanelButton",
                            Image     = Resources.plus,
                            Dock      = DockStyle.Fill,
                            FlatStyle = FlatStyle.Flat,
                            ForeColor = Supports.textBlack,
                            BackColor = Supports.headGrey
                        });

                        (foreignPeople.Controls.Find("AddPanelButton", true).FirstOrDefault() as Button).Click += (s, arg) =>
                        {
                            string log = MessageBoxTi.Show("Логин", "Придумайте логин", HorizontalAlignment.Left);
                            while (log.Length > 15)
                            {
                                log = MessageBoxTi.Show("Логин", "Пользователь с таким ологином уже существует. Придумайте другой логин!", HorizontalAlignment.Left);
                                if (log == null || log == "")
                                {
                                    return;
                                }
                            }

                            if (dataBase.dataset.Tables["Login"].Select().Where(x => x["Login"].ToString().Equals(log)).Count() == 0 && log != "")
                            {
                                foreignPeople.Controls.Add(UserCard(log, true));
                                foreignPeople.Controls.SetChildIndex(foreignPeople.Controls.Find("AddPanel", false).FirstOrDefault(), foreignPeople.Controls.Count);
                                return;
                            }
                            else if (log == null || log == "")
                            {
                                return;
                            }
                            else
                            {
                                MessageBoxTi.Show("Такой логин уже существует");
                                return;
                            }
                        };


                        Supports.GangeGroup(this);
                    }
                    catch (Exception ex)
                    {
                        MessageBoxTi.Show("Admin.Enter " + ex.Message);
                    }
                };

                dataBase.ToDisplay("SELECT [ID], [Department], [Login], [Password], [Face], [Пользователь], [Rank], [Allowed], [SatellitesType] FROM Login", requestJustByMyself: true, dataTableName: "Login");
                dataBase.ToDisplay("Appointment");
            }
            catch (Exception e)
            {
                MessageBoxTi.Show("Admin " + e.Message);
            }
        }