/* * Addin Array lists objects of AcademicDTO for DEGREE and compute aggregate */ public void addDegrees(AcademicDTO Obj) { int size = DegreeInfo.Count; if (Obj.degreeName == "Inter") { totalFScMarks += Obj.totalMarks; ObtainedFScMarks += Obj.obtainMarks; if (ObtainedECATMarks > 0 && ObtainedFScMarks > 0) { // look into only first 3 object peform caculations Obj.Aggregate = (ObtainedFScMarks / totalFScMarks) * 70 + (ObtainedECATMarks / totalECATMarks) * 30; ObtainedECATMarks = ObtainedFScMarks = totalFScMarks = totalECATMarks = 0; } else { // } } else if (Obj.degreeName == "ECAT") { totalECATMarks += Obj.totalMarks; ObtainedECATMarks += Obj.obtainMarks; if (ObtainedECATMarks > 0 && ObtainedFScMarks > 0) { // look into only first 3 object peform caculations Obj.Aggregate = (ObtainedFScMarks / totalFScMarks) * 70 + (ObtainedECATMarks / totalECATMarks) * 30; ObtainedECATMarks = ObtainedFScMarks = totalFScMarks = totalECATMarks = 0; } else { // } } else if (Obj.degreeName == "Matric") { if (ObtainedECATMarks > 0 && ObtainedFScMarks > 0) { // look into only first 3 object peform caculations Obj.Aggregate = (ObtainedFScMarks / totalFScMarks) * 70 + (ObtainedECATMarks / totalECATMarks) * 30; ObtainedECATMarks = ObtainedFScMarks = totalFScMarks = totalECATMarks = 0; } else { // } }// else if end // finally add object in arraylist DegreeInfo.Add(Obj); }// add fun
}// add academic Degree event end /////////////////////////ADD TEST BUTTTON ///////////////////////// // get test information of the student and stor in array of academicDL private void btnAddTest_Click(object sender, EventArgs e) { AcademicDTO eduObject = new AcademicDTO(); float totalM = 0; float obtainM = 0; if (list2.Contains("" + comboBoxtests.SelectedItem)) { if (txtTotalmarksOther.Text != "" && txtObtainmarksOther.Text != "" && txtPassingyearOther.Text != "" && txtPercentageOther.Text != "") { eduObject.degreeName = "" + comboBoxdegree.SelectedItem; try { // validate total marks if (Regex.IsMatch(txtTotalmarksOther.Text, @"^[0-9]+$")) { // eduObject.totalMarks totalM = float.Parse(txtTotalmarksOther.Text); } else { MessageBox.Show(" Invalid input"); txtTotalmarksOther.Text = ""; return; } }catch (Exception ex) { MessageBox.Show(ex.Message); } try { //validate obtain marks if (Regex.IsMatch(txtObtainmarksOther.Text, @"^[0-9]+$")) { // eduObject.obtainMarks obtainM = float.Parse(txtObtainmarksOther.Text); } else { MessageBox.Show(" Invalid input"); txtObtainmarksOther.Text = ""; return; } }catch (Exception ex) { MessageBox.Show(ex.Message); } //////////check either nobtain marks are greater than total marks if (obtainM < totalM) { eduObject.totalMarks = totalM; eduObject.obtainMarks = obtainM; } else { MessageBox.Show("Invalid Obatin marks"); txtObtainmarksOther.Text = ""; txtTotalmarksOther.Text = ""; return; } try { // validate the percentage if (Regex.IsMatch(txtPercentageOther.Text, @"^[0-9]+$")) { eduObject.percentage = float.Parse(txtPercentageOther.Text); } else { MessageBox.Show("Invalid input"); txtPercentageOther.Text = ""; return; } }catch (Exception ex) { MessageBox.Show(ex.Message); } try { // validate the year if (Regex.IsMatch(txtPassingyearOther.Text, @"^[0-9]+$")) { eduObject.passingYear = Convert.ToInt16(txtPassingyearOther.Text); } else { MessageBox.Show("Invalid input"); txtPassingyearOther.Text = ""; return; } }catch (Exception ex) { MessageBox.Show(ex.Message); } // add degree in list Education.addTest(eduObject); // remove element from comparision list that added in data list2.Remove("" + comboBoxtests.SelectedItem); } else { MessageBox.Show("Invalid input"); return; } } else { MessageBox.Show("This is already exist OR Complete Data Required "); } }// add test event end
//////////////////////ADD ACADEMIC Degree BUTTON///////////////////// //get the education and add into array of Academic class private void btnAddEducation_Click(object sender, EventArgs e) { AcademicDTO eduObject = new AcademicDTO(); float totalM = 0; float obtainM = 0; /* * check either degree entered by user ,allow only once entry */ if (list.Contains("" + comboBoxdegree.SelectedItem)) { //check either any feild is empty of not and set valus if (txtTotalmarks.Text != "" && txtObtainmarks.Text != "" && txtPassingyear.Text != "" && txtpercentage.Text != "") { eduObject.degreeName = "" + comboBoxdegree.SelectedItem; // validate obtain marks try { if (Regex.IsMatch(txtTotalmarks.Text, @"^[0-9]+$")) { // eduObject.totalMarks totalM = float.Parse(txtTotalmarks.Text); } else { txtTotalmarks.Text = ""; MessageBox.Show("Invalid input"); return; } }catch (Exception ex) { MessageBox.Show(ex.Message); } try { // validate obtain marks if (Regex.IsMatch(txtObtainmarks.Text, @"^[0-9]+$")) { // eduObject.obtainMarks obtainM = float.Parse(txtObtainmarks.Text); } else { txtObtainmarks.Text = ""; MessageBox.Show("Invalid input"); return; } }catch (Exception ex) { MessageBox.Show(ex.Message); } /////////////// check on obtain marks should not greater than total marks if (obtainM < totalM) { eduObject.totalMarks = totalM; eduObject.obtainMarks = obtainM; } else { MessageBox.Show("Invalid Total & Obtain Marks"); txtObtainmarks.Text = ""; txtTotalmarks.Text = ""; return; } try { // validate percentage if (Regex.IsMatch(txtpercentage.Text, @"^[0-9]+$")) { eduObject.percentage = float.Parse(txtpercentage.Text); } else { txtpercentage.Text = ""; MessageBox.Show("Invalid input"); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } try { //validate year if (Regex.IsMatch(txtPassingyear.Text, @"^[0-9]+$")) { eduObject.passingYear = Convert.ToInt16(txtPassingyear.Text); } else { txtPassingyear.Text = ""; MessageBox.Show("Invalid input"); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } // add degree Education.addDegrees(eduObject); //remove degree added in data from the comparison list list.Remove("" + comboBoxdegree.SelectedItem); } else { MessageBox.Show("Invalid input"); } } else { MessageBox.Show("Degree Already Entered OR Complete Data Required"); } }// add academic Degree event end
}// add fun /* * Add tests in arraylist */ public void addTest(AcademicDTO Obj) { testInfo.Add(Obj); }