示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text != "")
         {
             DB = new SQLiteConnection("Data Source=testBD.db; Version=3");
             DB.Open();
             SQLiteCommand AddtoTable = DB.CreateCommand();
             AddtoTable.CommandText = "insert into LESSON (Name) values( @Name)";
             AddtoTable.Parameters.Add("@Name", DbType.String).Value = textBox1.Text.ToUpper();
             AddtoTable.ExecuteNonQuery();
             Form1 form1 = this.Owner as Form1;
             form1.Update_Tab_2();
             successfully succ = new successfully();
             this.Hide();
             succ.ShowDialog();
             this.Close();
         }
     }
     catch
     {
         error er = new error();
         er.ShowDialog();
     }
 }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ed == null || ed == "")
            {
                SQLiteConnection DB = new SQLiteConnection("Data Source=testBD.db; Version=3");
                DB.Open();
                SQLiteCommand AddtoTable = DB.CreateCommand();
                AddtoTable.CommandText = "insert into PLAN (Name, Houraweek, Year, Grouptype) values( @Name, @Houraweek, @Year, @Grouptype)";
                AddtoTable.Parameters.Add("@Name", DbType.String).Value      = comboBox2.Text.ToUpper();
                AddtoTable.Parameters.Add("@Houraweek", DbType.String).Value = numericUpDown1.Text;
                AddtoTable.Parameters.Add("@Year", DbType.String).Value      = label1.Text.Split()[0];
                AddtoTable.Parameters.Add("@Grouptype", DbType.String).Value = comboBox1.Text;
                AddtoTable.ExecuteNonQuery();
            }
            else
            {
                SQLiteConnection DB = new SQLiteConnection("Data Source=testBD.db; Version=3");
                DB.Open();
                SQLiteCommand AddtoTable = DB.CreateCommand();
                AddtoTable.CommandText = "UPDATE PLAN set Name = @Name, Houraweek = @Houraweek, Grouptype = @Grouptype WHERE Id = @Id";
                AddtoTable.Parameters.Add("@Name", DbType.String).Value      = comboBox2.Text.ToUpper();
                AddtoTable.Parameters.Add("@Houraweek", DbType.String).Value = numericUpDown1.Text;
                AddtoTable.Parameters.Add("@Id", DbType.String).Value        = id;
                AddtoTable.Parameters.Add("@Grouptype", DbType.String).Value = comboBox1.Text;
                AddtoTable.ExecuteNonQuery();
            }
            Form1 f1 = this.Owner as Form1;

            f1.Update_BD_1();
            successfully succ = new successfully();

            this.Hide();
            succ.ShowDialog();
            this.Close();
        }
示例#3
0
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         int           delet = dataGridView2.SelectedCells[0].RowIndex;
         SQLiteCommand CMD   = DB.CreateCommand();
         CMD.CommandText = "delete from GRADE where Name = @Name; delete from TEACHERSPLAN where Grade = @Name; delete from RASPISANIE where Grade = @Name";
         CMD.Parameters.Add("@Name", DbType.String).Value = dataGridView2[0, delet].Value.ToString();
         CMD.ExecuteNonQuery();
         Update_BD();
         successfully succ = new successfully();
         succ.ShowDialog();
     }
     catch
     {
         error er = new error();
         er.ShowDialog();
     }
 }
示例#4
0
 private void button16_Click(object sender, EventArgs e)
 {
     try
     {
         int           delet = dataGridView4.SelectedCells[0].RowIndex;
         SQLiteCommand CMD   = DB.CreateCommand();
         CMD.CommandText = "delete from TEACHERS where Fio = @Name; delete from TS where Idteacher = @Id; UPDATE TEACHERSPLAN set Idteacher = NULL WHERE Idteacher = @Id";
         CMD.Parameters.Add("@Name", DbType.String).Value = dataGridView4[0, delet].Value.ToString();
         CMD.Parameters.Add("@Id", DbType.String).Value   = dataGridView4[7, delet].Value.ToString();
         CMD.ExecuteNonQuery();
         Update_Tab_2();
         successfully succ = new successfully();
         succ.ShowDialog();
     }
     catch
     {
         error er = new error();
         er.ShowDialog();
     }
 }
示例#5
0
 private void button30_Click(object sender, EventArgs e)
 {
     try
     {
         int           delet = dataGridView9.SelectedCells[0].RowIndex;
         SQLiteCommand CMD   = DB.CreateCommand();
         CMD.CommandText = "delete from ROOMS where Id = @Id; delete from RS where Idroom = @Name; UPDATE TEACHERSPLAN set Room = NULL WHERE Room = @Name";
         CMD.Parameters.Add("@Name", DbType.String).Value = dataGridView9[0, delet].Value.ToString();
         CMD.Parameters.Add("@Id", DbType.String).Value   = dataGridView9[3, delet].Value.ToString();
         CMD.ExecuteNonQuery();
         Update_Room();
         Update_Room2();
         successfully succ = new successfully();
         succ.ShowDialog();
     }
     catch
     {
         error er = new error();
         er.ShowDialog();
     }
 }
示例#6
0
        private void button2_Click(object sender, EventArgs e)
        {
            SQLiteConnection DB = new SQLiteConnection("Data Source=testBD.db; Version=3");

            DB.Open();
            SQLiteCommand AddtoTable = DB.CreateCommand();

            AddtoTable.CommandText = "insert into TEACHERSPLAN (Lesson, Hoursaweek, Grade) values( @Name, @Houraweek, @Year)";
            AddtoTable.Parameters.Add("@Name", DbType.String).Value      = comboBox2.Text.ToUpper();
            AddtoTable.Parameters.Add("@Houraweek", DbType.String).Value = numericUpDown1.Text;
            AddtoTable.Parameters.Add("@Year", DbType.String).Value      = rd;
            AddtoTable.ExecuteNonQuery();
            Form1 f1 = this.Owner as Form1;

            f1.Update_BD_1();
            successfully succ = new successfully();

            f1.Update_Grid6();
            this.Hide();
            succ.ShowDialog();
            this.Close();
        }
示例#7
0
文件: Form2.cs 项目: stezenkok/vkr
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text != "")
         {
             SQLiteCommand AddtoTable = DB.CreateCommand();
             AddtoTable.CommandText = "insert into GRADE (Name, Shift, Academic_Plan, Supervisor, Room,Number_Of_Students) values( @Name, @Shift, @Academic_Plan, @Supervisor, @Room, @Number_Of_Students )";
             AddtoTable.Parameters.Add("@Name", DbType.String).Value               = textBox1.Text.ToUpper();
             AddtoTable.Parameters.Add("@Shift", DbType.String).Value              = comboBox1.Text.ToUpper();
             AddtoTable.Parameters.Add("@Academic_Plan", DbType.String).Value      = textBox2.Text.ToUpper();
             AddtoTable.Parameters.Add("@Supervisor", DbType.String).Value         = comboBox2.Text.ToUpper();
             AddtoTable.Parameters.Add("@Room", DbType.String).Value               = comboBox4.Text.ToUpper();
             AddtoTable.Parameters.Add("@Number_Of_Students", DbType.String).Value = numericUpDown1.Text.ToUpper();
             AddtoTable.ExecuteNonQuery();
             SQLiteCommand AddtoTable1 = DB.CreateCommand();
             AddtoTable1.CommandText = "INSERT INTO TEACHERSPLAN(Lesson, Hoursaweek, Grade)SELECT Name, Houraweek, Year FROM PLAN WHERE Year like @name";
             AddtoTable1.Parameters.Add("@Name", DbType.String).Value = year;
             AddtoTable1.ExecuteNonQuery();
             SQLiteCommand AddtoTable2 = DB.CreateCommand();
             AddtoTable2.CommandText = "UPDATE TEACHERSPLAN set Grade = @Name WHERE GRADE = @Year";
             AddtoTable2.Parameters.Add("@Year", DbType.String).Value = year;
             AddtoTable2.Parameters.Add("@Name", DbType.String).Value = textBox1.Text.ToUpper();
             AddtoTable2.ExecuteNonQuery();
             Form1 f1 = this.Owner as Form1;
             f1.Update_BD();
             successfully succ = new successfully();
             this.Hide();
             succ.ShowDialog();
             this.Close();
         }
     }
     catch
     {
         error er = new error();
         er.ShowDialog();
     }
 }
示例#8
0
        private void button20_Click(object sender, EventArgs e)
        {
            try
            {
                int           delet     = dataGridView5.SelectedCells[0].RowIndex;
                SQLiteCommand deleted_5 = DB.CreateCommand();
                deleted_5.CommandText = "DELETE FROM PLAN WHERE Year like @Year AND Name like '%' || @Name || '%'";
                deleted_5.Parameters.Add("@Year", DbType.String).Value = treeView_AfterSelec.ToString().Split()[0];
                deleted_5.Parameters.Add("@Name", DbType.String).Value = dataGridView5[0, delet].Value.ToString();

                deleted_5.ExecuteNonQuery();

                Update_BD_1();

                successfully succ = new successfully();
                succ.ShowDialog();
            }
            catch
            {
                error er = new error();
                er.ShowDialog();
            }
        }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != null)
            {
                if (ed2 == "")
                {
                    SQLiteCommand CMD = DB.CreateCommand();
                    CMD.CommandText = "insert into TEACHERS (Fio, Lesson, Grade, Room) values( @fio ,@Lesson , @Grade, @Room )";
                    CMD.Parameters.Add("@fio", DbType.String).Value    = textBox1.Text;
                    CMD.Parameters.Add("@Lesson", DbType.String).Value = textBox2.Text.ToUpper();


                    CMD.Parameters.Add("@Grade", DbType.String).Value = comboBox1.Text.ToUpper();
                    CMD.Parameters.Add("@Room", DbType.String).Value  = comboBox2.Text.ToUpper();

                    CMD.ExecuteNonQuery();
                    this.Hide();
                    successfully succ = new successfully();
                    succ.ShowDialog();

                    SQLiteCommand CMD4      = DB.CreateCommand();
                    SQLiteCommand Teacherid = DB.CreateCommand();
                    Teacherid.CommandText = "select Id from TEACHERS where Fio LIKE @fio";
                    Teacherid.Parameters.Add("@fio", DbType.String).Value = textBox1.Text;
                    SQLiteDataReader SQL2 = Teacherid.ExecuteReader();
                    string           q    = "";
                    if (SQL2.HasRows)
                    {
                        while (SQL2.Read())
                        {
                            q = SQL2.GetValue(0).ToString();
                        }
                    }

                    //label6.Text = q;
                    foreach (string s in checkedListBox1.CheckedItems)
                    {
                        CMD4.CommandText = "insert into TS (Idteacher, Subjects) VALUES (@Sub, @Name)";
                        CMD4.Parameters.Add("@Sub", DbType.String).Value  = q;
                        CMD4.Parameters.Add("@Name", DbType.String).Value = s;
                        CMD4.ExecuteNonQuery();
                    }
                    Form1 f1 = this.Owner as Form1;
                    f1.Update_Tab_2();
                    this.Close();
                }
                else
                {
                    SQLiteCommand del = DB.CreateCommand();
                    del.CommandText = "UPDATE TEACHERS set Fio = '', Lesson = NULL, Grade = NULL, Room = NULL WHERE Id = @Id; delete from TS where Idteacher = @id";

                    del.Parameters.Add("@Id", DbType.String).Value = ed2;
                    del.ExecuteNonQuery();

                    SQLiteCommand CMD = DB.CreateCommand();
                    CMD.CommandText = "UPDATE TEACHERS set Fio = @fio, Lesson = @Lesson, Grade = @Grade, Room = @Room where Id = '" + ed2 + "'";
                    CMD.Parameters.Add("@fio", DbType.String).Value    = textBox1.Text;
                    CMD.Parameters.Add("@Lesson", DbType.String).Value = textBox2.Text.ToUpper();
                    CMD.Parameters.Add("@Grade", DbType.String).Value  = comboBox1.Text.ToUpper();
                    CMD.Parameters.Add("@Room", DbType.String).Value   = comboBox2.Text.ToUpper();
                    CMD.ExecuteNonQuery();

                    this.Hide();

                    successfully succ = new successfully();
                    succ.ShowDialog();

                    SQLiteCommand CMD4      = DB.CreateCommand();
                    SQLiteCommand Teacherid = DB.CreateCommand();
                    Teacherid.CommandText = "select Id from TEACHERS where Fio LIKE @fio";
                    Teacherid.Parameters.Add("@fio", DbType.String).Value = textBox1.Text;
                    SQLiteDataReader SQL2 = Teacherid.ExecuteReader();
                    string           q    = "";
                    if (SQL2.HasRows)
                    {
                        while (SQL2.Read())
                        {
                            q = SQL2.GetValue(0).ToString();
                        }
                    }

                    //label6.Text = q;
                    foreach (string s in checkedListBox1.CheckedItems)
                    {
                        CMD4.CommandText = "insert into TS (Idteacher, Subjects) VALUES (@Sub, @Name)";
                        CMD4.Parameters.Add("@Sub", DbType.String).Value  = q;
                        CMD4.Parameters.Add("@Name", DbType.String).Value = s;
                        CMD4.ExecuteNonQuery();
                    }
                    Form1 f1 = this.Owner as Form1;
                    f1.Update_Tab_2();
                    this.Close();
                }
            }
        }
示例#10
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != null)
            {
                if (ed2 == "" || ed2 == null)
                {
                    SQLiteCommand CMD = DB.CreateCommand();
                    CMD.CommandText = "insert into ROOMS (Room, Type) values(@Room, @Type )";

                    CMD.Parameters.Add("@Type", DbType.String).Value = textBox2.Text.ToUpper();
                    CMD.Parameters.Add("@Room", DbType.String).Value = textBox1.Text.ToUpper();
                    CMD.ExecuteNonQuery();

                    this.Hide();
                    successfully succ = new successfully();
                    succ.ShowDialog();

                    SQLiteCommand CMD4 = DB.CreateCommand();
                    foreach (string s in checkedListBox1.CheckedItems)
                    {
                        CMD4.CommandText = "insert into RS (Idroom, Subjects) VALUES (@Sub, @Name)";
                        CMD4.Parameters.Add("@Sub", DbType.String).Value  = textBox1.Text.ToUpper();
                        CMD4.Parameters.Add("@Name", DbType.String).Value = s;
                        CMD4.ExecuteNonQuery();
                    }
                    Form1 f1 = this.Owner as Form1;
                    f1.Update_Room();
                    this.Close();
                }
                else
                {
                    SQLiteCommand CMD = DB.CreateCommand();
                    CMD.CommandText = "UPDATE ROOMS set Room = @R, Type = @T where Room = '" + ed2 + "';delete from RS where Idroom = @Room";
                    CMD.Parameters.Add("@R", DbType.String).Value    = textBox1.Text.ToUpper();
                    CMD.Parameters.Add("@Room", DbType.String).Value = ed2;
                    CMD.Parameters.Add("@T", DbType.String).Value    = textBox2.Text.ToUpper();

                    CMD.ExecuteNonQuery();

                    this.Hide();

                    successfully succ = new successfully();
                    succ.ShowDialog();

                    SQLiteCommand CMD4 = DB.CreateCommand();

                    //label6.Text = q;
                    foreach (string s in checkedListBox1.CheckedItems)
                    {
                        CMD4.CommandText = "insert into RS (Idroom, Subjects) VALUES (@Sub, @Name)";
                        CMD4.Parameters.Add("@Sub", DbType.String).Value  = textBox1.Text.ToUpper();
                        CMD4.Parameters.Add("@Name", DbType.String).Value = s;
                        CMD4.ExecuteNonQuery();
                    }
                    Form1 f1 = this.Owner as Form1;
                    f1.Update_Room2();
                    f1.Update_Room();

                    this.Close();
                }
            }
        }