private void cmdManageStudents_Click(object sender, EventArgs e) { ManageStudentsScreen manageStudent = new ManageStudentsScreen(); this.Hide(); manageStudent.Show(); }
private void cmdCancel_Click(object sender, EventArgs e) { try { foreach (Student Remove in Section.getInstance().ListofStudents()) { Section.getInstance().ListofStudents().Remove(Remove); } } catch (Exception p) { MessageBox.Show("error is " + p.ToString()); } ManageStudentsScreen manageStudent = new ManageStudentsScreen(); this.Hide(); manageStudent.Show(); }
private void cmdSave_Click(object sender, EventArgs e) { 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 && Section.getInstance().ListofStudents().Count() > 0 && Section.getInstance().ListofStudents().Last().Courses2.Count() > 0) { Student addStudent = new Student(); addStudent.Name1 = Section.getInstance().ListofStudents().Last().Name1; addStudent.RegisterationNumber1 = Section.getInstance().ListofStudents().Last().RegisterationNumber1; addStudent.Degree1 = Section.getInstance().ListofStudents().Last().Degree1; addStudent.Courses2 = Section.getInstance().ListofStudents().Last().Courses2; string studentInfo = string.Format("delete StudentData where RegNo='{0}'", addStudent.RegisterationNumber1); DataBaseConnection.getInstance().executeQuery(studentInfo); string deleteResult = string.Format("delete CourseDMC where StudentId='{0}'", addStudent.RegisterationNumber1); DataBaseConnection.getInstance().executeQuery(deleteResult); lblstudentExist.Text = ""; string storeStudent = string.Format("insert into StudentData(RegNo,Name,Degree,Courses) values('{0}','{1}','{2}','{3}')", txtRegNo.Text, txtName.Text, cmbBoxDegree.Text, addStudent.Courses2.Count()); DataBaseConnection.getInstance().executeQuery(storeStudent); foreach (CourseResult result in addStudent.Courses2) { string courseResult = string.Format("insert into CourseDMC(CourseId,CourseTitle,CreditHour,Marks,Semester,Grade,StudentId) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", result.CourseId1, result.CourseTitle1, result.CreditHours1, result.Marks1, result.Semester1, result.getGrade(), addStudent.RegisterationNumber1); DataBaseConnection.getInstance().executeQuery(courseResult); } Section.getInstance().ListofStudents().RemoveRange(0, Section.getInstance().ListofStudents().Count()); ManageStudentsScreen studentScreen = new ManageStudentsScreen(); this.Hide(); studentScreen.Show(); } else { MessageBox.Show("Invalid Student info or course Result"); } } // } }