private void btnDelete_Click(object sender, EventArgs e) { try { manageMarks myM = new manageMarks(); DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this mark record", "Confirm Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { if (myM.deleteMark(this.markId) == true) { MessageBox.Show("mark deleted success", "Confirm Option", MessageBoxButtons.OK, MessageBoxIcon.Question); this.btnDelete.Enabled = false; this.btnUpdate.Enabled = false; this.btnRecord.Enabled = true; refresh(); } else { MessageBox.Show("Failed to delete mark", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("failed in btnDelete_Click() " + ex.Message); } }
private void dgvStudents_DoubleClick(object sender, EventArgs e) { try { this.studentId = Convert.ToInt32(dgvStudents.SelectedRows[0].Cells[0].Value); this.txtComment.Text = ""; this.txtMark.Text = ""; manageStudent myS = new manageStudent(); myS.getStudentId(this.studentId); this.txtFname.Text = myS.firstName; this.txtLastname.Text = myS.lastName; manageMarks myM = new manageMarks(); myM.getMarkByPaper(studentId, paperId); if (myM.dacFound == true) { MessageBox.Show("Marks for this paper already " + myS.firstName + " " + myS.lastName, "system info", MessageBoxButtons.OK, MessageBoxIcon.Question); this.txtComment.Text = myM.remarks; this.markId = myM.markId; this.txtMark.Text = myM.attainedMark.ToString(); this.btnRecord.Enabled = false; this.btnDelete.Enabled = true; this.btnUpdate.Enabled = true; } else { this.btnDelete.Enabled = false; this.btnUpdate.Enabled = false; this.btnRecord.Enabled = true; } } catch (Exception ex) { MessageBox.Show("failed in dgvStudents_DoubleClick() " + ex.Message); } }
private void btnRecord_Click(object sender, EventArgs e) { try { //InsertMark(string stdId,int exanId, int atnMark, int posMark, string grde, string remark, string typ ,string tchr, int paper) this.btnRecord.Enabled = false; int mark = Convert.ToInt32(this.txtMark.Text); var comment = this.txtComment.Text; int possibleMark = Convert.ToInt32(this.txtPossible.Text); string type = this.txtExamCater.Text; if (this.txtMark.Text == "") { MessageBox.Show("enter the mark to record ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMark.Focus(); this.btnRecord.Enabled = true; } else if (mark > possibleMark) { MessageBox.Show("attained mark can not be greater than possible ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMark.Focus(); this.btnRecord.Enabled = true; } else if (comment == "") { MessageBox.Show("teacher perfomance analysis required ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtComment.Focus(); this.btnRecord.Enabled = true; } else { manageMarks myM = new manageMarks(); //InsertMark(string stdId, int exanId, int atnMark, int posMark, string grde, string remark, string typ, string tchr, int paper) myM.getMarkByPaper(this.studentId, this.paperId); if (myM.dacFound == false) { if (myM.InsertMark(this.studentId.ToString(), this.examId, mark, possibleMark, getGrade(mark).ToString(), comment, type, sessions.userId.ToString(), this.paperId) == true) { MessageBox.Show("Marks enter success ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.btnRecord.Enabled = true; this.btnDelete.Enabled = false; this.btnUpdate.Enabled = false; refresh(); } else { this.btnRecord.Enabled = true; MessageBox.Show("faled to insert mark", "system info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("mark already entered", "system info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } catch (Exception ex) { MessageBox.Show("failed in btnRecord_Click() " + ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { //InsertMark(string stdId,int exanId, int atnMark, int posMark, string grde, string remark, string typ ,string tchr, int paper) int mark = Convert.ToInt32(this.txtMark.Text); var comment = this.txtComment.Text; int possibleMark = Convert.ToInt32(this.txtPossible.Text); string type = this.txtExamCater.Text; if (this.txtMark.Text == "") { MessageBox.Show("enter the mark to record ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMark.Focus(); } else if (mark > possibleMark) { MessageBox.Show("attained mark can not be greater than possible ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMark.Focus(); } else if (comment == "") { MessageBox.Show("teacher perfomance analysis required ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtComment.Focus(); } else { manageMarks myM = new manageMarks(); myM.getMark(this.markId); myM.attainedMark = mark; myM.remarks = comment; myM.grade = getGrade(mark); if (myM.UpdateMark(this.markId) == true) { MessageBox.Show("Marks update success success ", "system info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.btnDelete.Enabled = false; this.btnUpdate.Enabled = false; this.btnRecord.Enabled = true; refresh(); } } } catch (Exception ex) { MessageBox.Show("failed in btnUpdate_Click() " + ex.Message); } }