Esempio n. 1
0
        private void UpTeachers_Load(object sender, EventArgs e)
        {
            adminpanel main = this.Owner as adminpanel;

            if (main != null)
            {
                ConnectDB.ConnectOnDb();
                id = main.label2.Text;
                SqlCeCommand thisCommand1 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand1.CommandText = "SELECT Sname FROM teacher WHERE (id_teacher = '" + id + "')";
                thisCommand1.Connection  = ConnectDB.ConnectOnDb();
                Sname = (string)thisCommand1.ExecuteScalar();
                SqlCeCommand thisCommand2 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand2.CommandText = "SELECT Fname FROM teacher WHERE(id_teacher = '" + id + "')";
                thisCommand2.Connection  = ConnectDB.ConnectOnDb();
                Fname = (string)thisCommand2.ExecuteScalar();
                SqlCeCommand thisCommand3 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand3.CommandText = "SELECT Lname FROM teacher WHERE(id_teacher = '" + id + "')";
                thisCommand3.Connection  = ConnectDB.ConnectOnDb();
                Lname = (string)thisCommand3.ExecuteScalar();
                SqlCeCommand thisCommand4 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand4.CommandText = "SELECT Login FROM teacher WHERE(id_teacher = '" + id + "')";
                thisCommand4.Connection  = ConnectDB.ConnectOnDb();
                login = (string)thisCommand4.ExecuteScalar();
                SqlCeCommand thisCommand5 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand5.CommandText = "SELECT Password FROM teacher WHERE(id_teacher = '" + id + "')";
                thisCommand5.Connection  = ConnectDB.ConnectOnDb();
                password            = (string)thisCommand5.ExecuteScalar();
                metroTextBox6.Text  = Sname;
                metroTextBox7.Text  = Fname;
                metroTextBox8.Text  = Lname;
                metroTextBox9.Text  = login;
                metroTextBox10.Text = password;
            }
        }
Esempio n. 2
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            try
            {
                SqlCeCommand thisCommand = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand.CommandText = "SELECT Prava FROM teacher WHERE Login='******' AND Password = '******'";
                thisCommand.Connection  = ConnectDB.ConnectOnDb();
                int prava = (int)thisCommand.ExecuteScalar();

                if (prava == 0)
                {
                    Form jou = new Journal();
                    jou.Owner = this;
                    jou.Show();
                    this.Hide();
                }
                if (prava == 1)
                {
                    Form ad = new adminpanel();
                    ad.Owner = this;
                    ad.Show();
                    this.Hide();
                }
            }
            catch
            {
                //MessageBox.Show("Неправильные данные!");
                MetroFramework.MetroMessageBox.Show(this, "Неправильные данные!", " ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Esempio n. 3
0
        private void metroButton4_Click(object sender, EventArgs e)
        {
            SqlCeCommand cmd = new SqlCeCommand("UPDATE student SET id_zachetki =  '" + metroTextBox2.Text + "', Sname =  '" + metroTextBox3.Text + "', Fname = '" + metroTextBox4.Text + "', Lname = '" + metroTextBox5.Text + "', id_gruppa = '" + idGr + "' WHERE (id_zachetki  =  '" + id + "')", ConnectDB.ConnectOnDb());

            cmd.ExecuteNonQuery();
            ConnectDB.ConnectClose();
            adminpanel main = this.Owner as adminpanel;

            if (main != null)
            {
                DataSet          ds4        = new DataSet();
                SqlCeDataAdapter dtAdapter6 = new SqlCeDataAdapter("SELECT student.id_zachetki AS [Номер зачетки], student.Sname AS Фамилия, student.Fname AS Имя, student.Lname AS Отчество, gruppa.gruppa AS Группа FROM student INNER JOIN gruppa ON student.id_gruppa = gruppa.id_gruppa WHERE(gruppa.gruppa = '" + comboBox3.Text + "')", ConnectDB.ConnectOnDb());
                dtAdapter6.Fill(ds4, "student");
                main.metroGrid2.DataSource = ds4.Tables["student"];
            }
        }
Esempio n. 4
0
        private void metroButton4_Click(object sender, EventArgs e)
        {
            SqlCeCommand cmd = new SqlCeCommand("UPDATE teacher SET Sname =  '" + metroTextBox6.Text + "', Fname = '" + metroTextBox7.Text + "', Lname = '" + metroTextBox8.Text + "', Login = '******', Password = '******', Prava = '" + 0 + "' WHERE (id_teacher  =  '" + id + "')", ConnectDB.ConnectOnDb());

            cmd.ExecuteNonQuery();
            ConnectDB.ConnectClose();

            adminpanel main = this.Owner as adminpanel;

            if (main != null)
            {
                DataSet          ds2        = new DataSet();
                SqlCeDataAdapter dtAdapter3 = new SqlCeDataAdapter("SELECT Sname AS Фамилия, Fname AS Имя, Lname AS Отчество, Login AS Логин, Password AS Пароль FROM teacher", ConnectDB.ConnectOnDb());
                dtAdapter3.Fill(ds2, "teacher");
                main.metroGrid3.DataSource = ds2.Tables["teacher"];
            }
        }
Esempio n. 5
0
        private void UpStudents_Load(object sender, EventArgs e)
        {
            adminpanel main = this.Owner as adminpanel;

            if (main != null)
            {
                ConnectDB.ConnectOnDb();
                id = main.label1.Text;
                SqlCeCommand thisCommand1 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand1.CommandText = "SELECT Sname FROM student WHERE (id_zachetki = '" + id + "')";
                thisCommand1.Connection  = ConnectDB.ConnectOnDb();
                Sname = (string)thisCommand1.ExecuteScalar();
                SqlCeCommand thisCommand2 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand2.CommandText = "SELECT Fname FROM student WHERE(id_zachetki = '" + id + "')";
                thisCommand2.Connection  = ConnectDB.ConnectOnDb();
                Fname = (string)thisCommand2.ExecuteScalar();
                SqlCeCommand thisCommand3 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand3.CommandText = "SELECT Lname FROM student WHERE(id_zachetki = '" + id + "')";
                thisCommand3.Connection  = ConnectDB.ConnectOnDb();
                Lname = (string)thisCommand3.ExecuteScalar();
                SqlCeCommand thisCommand4 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand4.CommandText = "SELECT gruppa.gruppa FROM student INNER JOIN gruppa ON student.id_gruppa = gruppa.id_gruppa WHERE(student.id_zachetki = '" + id + "')";
                thisCommand4.Connection  = ConnectDB.ConnectOnDb();
                gruppa = (string)thisCommand4.ExecuteScalar();

                metroTextBox2.Text = id;
                metroTextBox3.Text = Sname;
                metroTextBox4.Text = Fname;
                metroTextBox5.Text = Lname;

                DataTable        dt           = new DataTable();
                string           q            = "SELECT DISTINCT gruppa FROM gruppa";
                SqlCeDataAdapter dataAdapter2 = new SqlCeDataAdapter(q, ConnectDB.ConnectOnDb());
                dataAdapter2.Fill(dt);
                comboBox3.DataSource    = dt;
                comboBox3.DisplayMember = "gruppa";
                comboBox3.ValueMember   = "gruppa";

                comboBox3.Text = gruppa;

                SqlCeCommand thisCommand5 = ConnectDB.ConnectOnDb().CreateCommand();
                thisCommand5.CommandText = "SELECT id_gruppa FROM gruppa WHERE gruppa = '" + comboBox3.Text + "'";
                thisCommand5.Connection  = ConnectDB.ConnectOnDb();
                idGr = (int)thisCommand5.ExecuteScalar();
            }
        }