Exemple #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            Show_Student_Group ssg = new Show_Student_Group();

            this.Hide();
            ssg.Show();
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string date  = DateTime.Now.ToShortDateString();
            string query = "insert into Group1(Created_On) values('" + date + "')";

            DatabaseConnection.getInstance().executeQuery(query);
            string countMaxId = string.Format("select max(Id) from Group1");
            var    re         = DatabaseConnection.getInstance().readData(countMaxId);
            int    count      = 0;

            while (re.Read())
            {
                count = re.GetInt32(0);
            }
            int id;

            if (list.Count() > 4 || list.Count() < 2)
            {
                label8.Visible = true;
                label8.Text    = "Student Length should be between 2 and 4";
            }

            else
            {
                for (int i = 0; i < list.Count; i++)
                {
                    id = list[i].Id;
                    string query1 = string.Format("insert into GroupStudent(GroupId,StudentId,Status,AssignmentDate) values('{0}','{1}','{2}','{3}')", count, id, 4, date);
                    DatabaseConnection.getInstance().executeQuery(query1);
                }
                dataGridView1.DataSource = null;
                Show_Student_Group ssg = new Show_Student_Group();
                this.Hide();
                ssg.Show();
            }
        }