private void btnPresent_Click(object sender, EventArgs e) { try { var student = this.txtEnId.Text; var attendDate = this.txtDate.Value.ToShortDateString(); manageAttendence myA = new manageAttendence(); manageattendsheet myAs = new manageattendsheet(); myAs.checkEntered(student, attendDate); if (myAs.dacFound == false) { myA.getAttendence(sessions.currTerm, student); if (myA.addPresent(sessions.currTerm, student) == true) { if (myAs.setAttend(student, attendDate, this.classId, "P", sessions.currTerm) == true) { MessageBox.Show(this.txtFname.Text + " " + this.txtLname.Text + " marked present", "system info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtAbsent.Text = myA.absentdays.ToString(); this.txtPresent.Text = myA.presentdays.ToString(); this.txtTotal.Text = myA.totaldays.ToString(); } else { MessageBox.Show("add atend failed"); } } else { DialogResult dialogResult = MessageBox.Show("this tudent has already been marked do you want to modifly", "Confirm Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { //get the attence enter //update totals //updade attendancee sheet } } } else { MessageBox.Show("already marked"); } } catch (Exception ex) { MessageBox.Show("failed in btnNext_Click()" + ex); } }
private void btnPresent_Click(object sender, EventArgs e) { try { var student = this.txtEnId.Text; var attendDate = this.txtDate.Value.ToShortDateString(); manageAttendence myA = new manageAttendence(); manageattendsheet myAs = new manageattendsheet(); myAs.checkEntered(student, attendDate); if (myAs.dacFound == false) { myA.getAttendence(sessions.currTerm, student); if (myA.addPresent(sessions.currTerm, student) == true) { if (myAs.setAttend(student, attendDate, this.classId, "P", sessions.currTerm) == true) { MessageBox.Show(this.txtFname.Text + " " + this.txtLname.Text + " marked present", "system info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtAbsent.Text = myA.absentdays.ToString(); this.txtPresent.Text = myA.presentdays.ToString(); this.txtTotal.Text = myA.totaldays.ToString(); this.lblShowList.Text = "List of students not marked in register"; string sql = "SELECT * FROM wizstudents WHERE classId = '" + this.classId + "' AND enrolmentId NOT IN (SELECT enrolmentId FROM wizattendsheet WHERE entryData = '" + attendDate + "' ) "; this.fillStudents(sql); } else { MessageBox.Show("add atend failed"); } } else { MessageBox.Show("failed tp add present in sumation file"); } } else { DialogResult dialogResult = MessageBox.Show("this student has already been marked do you want to modifly", "Confirm Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { //get the attence enter myAs.getAttend(student, attendDate); //update totals if (myAs.status == "P") { MessageBox.Show(this.txtFname.Text + " " + this.txtLname.Text + " already marked present", "system info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { myA.getAttendence(sessions.currTerm, student); myA.updateEntry(sessions.currTerm, student, "undo_Absent"); if (myAs.updateStatus(student, attendDate, "P") == true) { this.txtAbsent.Text = myA.absentdays.ToString(); this.txtPresent.Text = myA.presentdays.ToString(); this.txtTotal.Text = myA.totaldays.ToString(); MessageBox.Show(this.txtFname.Text + " " + this.txtLname.Text + " updated marked present", "system info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.lblShowList.Text = "List of students not marked in register"; string sql = "SELECT * FROM wizstudents WHERE classId = '" + this.classId + "' AND enrolmentId NOT IN (SELECT enrolmentId FROM wizattendsheet WHERE entryData = '" + attendDate + "' ) "; this.fillStudents(sql); } else { MessageBox.Show("failed to update", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //updade attendancee sheet } } } catch (Exception ex) { MessageBox.Show("failed in btnNext_Click()" + ex); } }