Example #1
0
        private void lblAssignStudents_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Hide();
            Show_Groups MG = new Show_Groups();

            MG.Show();
        }
Example #2
0
        private void btnCreateGroup_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(conStr);

            con.Open();
            if (Mode == 0)
            {
                if (con.State == ConnectionState.Open)
                {
                    try
                    {
                        string     Insert = "INSERT INTO [dbo].[Group](Created_On) VALUES ('" + Convert.ToDateTime(mcCreationDate.Value) + "')";
                        SqlCommand cmd    = new SqlCommand(Insert, con);
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = "SELECT @@IDENTITY";
                        GroupId         = Convert.ToInt32(cmd.ExecuteScalar());

                        for (int i = 0; i < check; i++)
                        {
                            Insert          = "INSERT INTO GroupStudent(GroupId, StudentId, Status, AssignmentDate) VALUES ('" + GroupId + "', (SELECT Id FROM Student WHERE RegistrationNo = '" + Selectedstudents[i].Registration_Number1 + "'), (SELECT Id FROM Lookup WHERE Lookup.Value = '" + Status[i] + "'), '" + Convert.ToDateTime(mcCreationDate.Value) + "' )";
                            cmd.CommandText = Insert;
                            cmd.ExecuteNonQuery();
                        }


                        MessageBox.Show("Succesfully Created");
                    }
                    catch
                    {
                        MessageBox.Show("Some Error Occured");
                    }

                    check = 0;

                    Status.Clear();
                    Selectedstudents.Clear();
                    setGrid();
                }
            }
            else
            {
                try
                {
                    for (int i = 0; i < check; i++)
                    {
                        string     Insert = "INSERT INTO GroupStudent(GroupId, StudentId, Status, AssignmentDate) VALUES ('" + GroupId + "', (SELECT Id FROM Student WHERE RegistrationNo = '" + Selectedstudents[i].Registration_Number1 + "'), (SELECT Id FROM Lookup WHERE Lookup.Value = '" + Status[i] + "'), '" + Convert.ToDateTime(mcCreationDate.Value) + "' )";
                        SqlCommand cmd    = new SqlCommand(Insert, con);
                        cmd.ExecuteNonQuery();

                        MessageBox.Show("Succesfully Updated");
                    }
                }
                catch
                {
                    MessageBox.Show("Some Error Occured");
                }


                check = 0;

                Status.Clear();
                Selectedstudents.Clear();
                setGrid();


                Mode = 0;

                Show_Groups SG = new Show_Groups();
                SG.Show();
                this.Hide();
            }
        }