Exemplo n.º 1
0
        private void CoursesdataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            selected = CoursesdataGridView.CurrentCell.RowIndex;
            DataGridViewRow row = CoursesdataGridView.Rows[selected];
            CourseResult    r   = new CourseResult();

            r.CourseId1    = row.Cells[0].Value.ToString();
            r.CourseTitle1 = row.Cells[1].Value.ToString();
            r.CreditHours1 = (int)row.Cells[2].Value;
            r.Marks1       = (int)row.Cells[3].Value;
            r.Semester1    = (int)row.Cells[4].Value;

            if (e.ColumnIndex == 6)
            {
                Section.getInstance().ListofStudents().Last().Courses2.Remove(r);
                CoursesdataGridView.Rows.Remove(row);
            }
            else if (e.ColumnIndex == 5)
            {
                Student editStudent = new Student();
                editStudent.Courses2.Add(r);
                Section.getInstance().ListofStudents().Insert(0, editStudent);
                AddCourse course = new AddCourse();
                this.Hide();
                course.Show();
            }
        }
Exemplo n.º 2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            bool haveCourses = false;

            try
            {
                MessageBox.Show(Section.getInstance().ListofStudents().Last().Courses2.Count.ToString());
                if (Section.getInstance().ListofStudents().Last().Courses2.Count > 0)
                {
                    haveCourses = true;
                }
            }
            catch
            {
                //  MessageBox.Show("error is " + exp.ToString());
            }
            if (!haveCourses)
            {
                bool invalidName = false, invalidReg = false, invalidDegree = false;
                lblNameError.Text = ""; lblRegNoError.Text = ""; lblDegreeError.Text = "";
                Student obj = new Student();
                if (obj.invalidName(txtName.Text))
                {
                    lblNameError.Text = "Invalid Name";
                    invalidName       = true;
                }
                if (obj.invalidRegisteration(txtRegNo.Text))
                {
                    lblRegNoError.Text = "Invalid Registeration Number";
                    invalidReg         = true;
                }
                if (obj.invalidDegree(cmbBoxDegree.Text))
                {
                    lblDegreeError.Text = "Invalid Degree";
                    invalidDegree       = true;
                }
                else
                {
                    if (!invalidName && !invalidReg && !invalidDegree)
                    {
                        obj.Name1 = txtName.Text;
                        obj.RegisterationNumber1 = txtRegNo.Text;
                        obj.Degree1 = cmbBoxDegree.Text;
                        Section sec = Section.getInstance();
                        sec.addStudent(obj);
                        if (Section.getInstance().ListofStudents().Count() > 1)
                        {
                            Section.getInstance().ListofStudents().RemoveAt(0);
                        }

                        AddCourse addCourse = new AddCourse();
                        this.Hide();
                        addCourse.Show();
                    }
                }
            }

            else
            {
                if (Section.getInstance().ListofStudents().Count() > 1)
                {
                    Section.getInstance().ListofStudents().RemoveAt(0);
                }

                AddCourse addCourse = new AddCourse();
                this.Hide();
                addCourse.Show();
            }
        }