Example #1
0
        private void bttnRefresh_Click(object sender, EventArgs e)
        {
            if (tabMenu.SelectedTab == pageRequests)
            {
                MySqlDataAdapter daRequests = new MySqlDataAdapter("SELECT `№ заявки`, `Название анализа`, ФИО, клиент.`Номер и серия паспорта`, `Дата создания`,Результат,`Дата выполнения` FROM заявка, клиент " +
                                                                   "WHERE заявка.`Номер и серия паспорта` = клиент.`Номер и серия паспорта`", frmAuthorization.connection);
                DataTable dtRequests = new DataTable();
                daRequests.Fill(dtRequests);
                dataTableRequests.DataSource         = dtRequests;
                dataTableRequests.RowHeadersVisible  = false; // Hide the display of the left column
                dataTableRequests.AllowUserToAddRows = false; // Hide the display of the bottom column
                dataTableRequests.Columns[0].Visible = false;
                //Unlock buttons
                bttnAdd.Enabled    = true;
                bttnChange.Enabled = true;

                bttnChange.Text = "Результат анализа готов";
            }
            else if (tabMenu.SelectedTab == pageClients)
            {
                MySqlDataAdapter daClients = new MySqlDataAdapter("SELECT * FROM клиент", frmAuthorization.connection);
                DataTable        dtClients = new DataTable();
                daClients.Fill(dtClients);
                dataTableClients.DataSource         = dtClients;
                dataTableClients.RowHeadersVisible  = false; // Hide the display of the left column
                dataTableClients.AllowUserToAddRows = false; // Hide the display of the bottom column
                //Unlock buttons
                bttnAdd.Enabled    = true;
                bttnChange.Enabled = true;

                bttnChange.Text = "Изменить";
            }
            else if (tabMenu.SelectedTab == pageServices)
            {
                MySqlDataAdapter daServices = new MySqlDataAdapter("SELECT * FROM услуги", frmAuthorization.connection);
                DataTable        dtServices = new DataTable();
                daServices.Fill(dtServices);
                dataTableServices.DataSource         = dtServices;
                dataTableServices.RowHeadersVisible  = false; // Hide the display of the left column
                dataTableServices.AllowUserToAddRows = false; // Hide the display of the bottom column
                dataTableServices.Columns[0].Width   = 300;
                dataTableServices.Columns[1].Width   = 75;
                dataTableServices.Columns[2].Width   = 170;
                //Block buttons
                bttnAdd.Enabled    = false;
                bttnChange.Enabled = false;

                bttnChange.Text = "Изменить";
            }
            else
            {
                ErrorAuthorization EA = new ErrorAuthorization();
                EA.Show();
            }
        }
Example #2
0
        //---------------------------------------------------------------------------------------

        private void bttnEnter_Click(object sender, EventArgs e)
        {
            connection = new MySqlConnection("server = 127.0.0.1; port = 3306; user = root; password = Vfhnvfhn23@; database = lis; sslmode = none;");
            connection.Open();

            string Password = Hashing.HashPassword(tbPassword.Text);

            if (chckBoxAdm.Checked == true)
            {
                MySqlCommand     cSelect  = new MySqlCommand("SELECT Логин, Пароль, Роль FROM пользователь WHERE Логин= '" + tbLogin.Text + "' AND Пароль= '" + Password + "' AND Роль= 'Администратор'", connection);
                MySqlDataAdapter daSelect = new MySqlDataAdapter(cSelect);
                DataTable        dtSelect = new DataTable();
                daSelect.Fill(dtSelect);
                if (dtSelect.Rows.Count > 0)
                {
                    //Active user
                    MySqlCommand cUserID   = new MySqlCommand("SELECT `ID пользователя` FROM пользователь WHERE Логин = '" + tbLogin.Text + "'", connection);
                    object       userIDObj = cUserID.ExecuteScalar();
                    string       userID    = userIDObj.ToString();

                    frmMenuAdm FMA = new frmMenuAdm(userID);
                    FMA.ShowDialog();
                }
                else
                {
                    ErrorAuthorization EA = new ErrorAuthorization();
                    EA.Show();
                }
            }
            else
            {
                MySqlCommand     cSelect  = new MySqlCommand("SELECT Логин, Пароль, Роль FROM пользователь WHERE Логин= '" + tbLogin.Text + "' AND Пароль= '" + Password + "' AND Роль= 'Пользователь'", connection);
                MySqlDataAdapter daSelect = new MySqlDataAdapter(cSelect);
                DataTable        dtSelect = new DataTable();
                daSelect.Fill(dtSelect);
                if (dtSelect.Rows.Count > 0)
                {
                    //Active user
                    MySqlCommand cUserID   = new MySqlCommand("SELECT `ID пользователя` FROM пользователь WHERE Логин = '" + tbLogin.Text + "'", connection);
                    object       userIDObj = cUserID.ExecuteScalar();
                    string       userID    = userIDObj.ToString();

                    frmMenuUser FMU = new frmMenuUser(userID);
                    FMU.ShowDialog();
                }
                else
                {
                    ErrorAuthorization EA = new ErrorAuthorization();
                    EA.Show();
                }
            }
        }
Example #3
0
        private void bttnRefresh_Click(object sender, EventArgs e)
        {
            if (tabMenu.SelectedTab == pageClients)
            {
                MySqlDataAdapter daClients = new MySqlDataAdapter("SELECT * FROM клиент", frmAuthorization.connection);
                DataTable        dtClients = new DataTable();
                daClients.Fill(dtClients);
                dataTableClients.DataSource         = dtClients;
                dataTableClients.RowHeadersVisible  = false; // Hide the display of the left column
                dataTableClients.AllowUserToAddRows = false; // Hide the display of the bottom column
                bttnAdd.Enabled        = true;
                bttnChange.Enabled     = true;
                bttnDelete.Enabled     = true;
                bttnAddUser.Enabled    = false;
                bttnChngUser.Enabled   = false;
                bttnDeleteUser.Enabled = false;
                //Clear dataTableUsers&Adm
                DataTable dt  = (DataTable)dataTableUsers.DataSource;
                DataTable dt2 = (DataTable)dataTableAdm.DataSource;
                if (dt != null && dt2 != null)
                {
                    dt.Clear();
                    dt2.Clear();
                }
            }
            else if (tabMenu.SelectedTab == pageRequests)
            {
                MySqlDataAdapter daSearch = new MySqlDataAdapter("SELECT `№ заявки`,`Название анализа`, ФИО, заявка.`Номер и серия паспорта`, `Дата создания`, Результат, `Дата выполнения` FROM заявка, клиент " +
                                                                 "WHERE (заявка.`Номер и серия паспорта` = клиент.`Номер и серия паспорта`)" +
                                                                 "AND (`Название анализа` LIKE '%" + tbSearch.Text + "%' " +
                                                                 "OR ФИО LIKE '%" + tbSearch.Text + "%' " +
                                                                 "OR `Дата создания` LIKE '%" + tbSearch.Text + "%' " +
                                                                 "OR Результат like '%" + tbSearch.Text + "%' " +
                                                                 "OR `Дата выполнения` LIKE '%" + tbSearch.Text + "%')", frmAuthorization.connection);
                DataTable dtSearch = new DataTable();
                daSearch.Fill(dtSearch);
                dataTableRequests.DataSource         = dtSearch;
                dataTableRequests.RowHeadersVisible  = false; // Hide the display of the left column
                dataTableRequests.AllowUserToAddRows = false; // Hide the display of the bottom column
                dataTableRequests.Columns[0].Width   = 60;
                bttnAdd.Enabled        = true;
                bttnChange.Enabled     = true;
                bttnDelete.Enabled     = true;
                bttnAddUser.Enabled    = false;
                bttnChngUser.Enabled   = false;
                bttnDeleteUser.Enabled = false;
                //Clear dataTableUsers&Adm
                DataTable dt  = (DataTable)dataTableUsers.DataSource;
                DataTable dt2 = (DataTable)dataTableAdm.DataSource;
                if (dt != null && dt2 != null)
                {
                    dt.Clear();
                    dt2.Clear();
                }
            }
            else if (tabMenu.SelectedTab == pageServices)
            {
                MySqlDataAdapter daServices = new MySqlDataAdapter("SELECT * FROM услуги", frmAuthorization.connection);
                DataTable        dtServices = new DataTable();
                daServices.Fill(dtServices);
                dataTableServices.DataSource         = dtServices;
                dataTableServices.RowHeadersVisible  = false; // Hide the display of the left column
                dataTableServices.AllowUserToAddRows = false; // Hide the display of the bottom column
                dataTableServices.Columns[0].Width   = 300;
                dataTableServices.Columns[1].Width   = 90;
                dataTableServices.Columns[2].Width   = 170;
                bttnAdd.Enabled        = true;
                bttnChange.Enabled     = true;
                bttnDelete.Enabled     = true;
                bttnAddUser.Enabled    = false;
                bttnChngUser.Enabled   = false;
                bttnDeleteUser.Enabled = false;
                //Clear dataTableUsers&Adm
                DataTable dt  = (DataTable)dataTableUsers.DataSource;
                DataTable dt2 = (DataTable)dataTableAdm.DataSource;
                if (dt != null && dt2 != null)
                {
                    dt.Clear();
                    dt2.Clear();
                }
            }
            else if (tabMenu.SelectedTab == pageUsers)
            {
                frmCheckPassword FCP = new frmCheckPassword();
                FCP.ShowDialog();
                if (FCP.DialogResult == DialogResult.OK)
                {
                    //Users
                    MySqlDataAdapter daUsers = new MySqlDataAdapter("SELECT `ID пользователя`, Логин, ФИО FROM пользователь WHERE Роль= 'Пользователь'", frmAuthorization.connection);
                    DataTable        dtUsers = new DataTable();
                    daUsers.Fill(dtUsers);
                    dataTableUsers.DataSource         = dtUsers;
                    dataTableUsers.RowHeadersVisible  = false; // Hide the display of the left column
                    dataTableUsers.AllowUserToAddRows = false; // Hide the display of the bottom column
                    dataTableUsers.Columns[0].Width   = 35;

                    //Administrations
                    MySqlDataAdapter daAdm = new MySqlDataAdapter("SELECT `ID пользователя`, Логин, ФИО FROM пользователь WHERE Роль= 'Администратор'", frmAuthorization.connection);
                    DataTable        dtAdm = new DataTable();
                    daAdm.Fill(dtAdm);
                    dataTableAdm.DataSource         = dtAdm;
                    dataTableAdm.RowHeadersVisible  = false; // Hide the display of the left column
                    dataTableAdm.AllowUserToAddRows = false; // Hide the display of the bottom column
                    dataTableAdm.Columns[0].Width   = 185;
                    dataTableAdm.Columns[2].Width   = 480;

                    bttnAdd.Enabled        = false;
                    bttnChange.Enabled     = false;
                    bttnDelete.Enabled     = false;
                    bttnAddUser.Enabled    = true;
                    bttnChngUser.Enabled   = true;
                    bttnDeleteUser.Enabled = true;
                }
                else
                {
                    ErrorAuthorization EA = new ErrorAuthorization();
                    EA.Show();
                }
            }
        }