private void btn_preview_Click(object sender, EventArgs e)
        {
            try
            {
                if (cbo_class.SelectedIndex == -1)
                {
                    MessageBox.Show("Class not selected");
                }

                else
                {
                    AttendanceSP reportSP = new AttendanceSP();
                    DataSet      Attendance_rpt_Dataset = reportSP.AttendanceReport(Convert.ToInt32(cbo_class.SelectedValue.ToString()), Convert.ToDateTime(dateTimePicker1.Text), Convert.ToDateTime(dateTimePicker2.Text));
                    if (Attendance_rpt_Dataset.Tables[0].Rows.Count > 0)
                    {
                        frmReport frm = new frmReport();
                        frm.print_attendance_rpt(Attendance_rpt_Dataset);
                        frm.Show();
                    }

                    else
                    {
                        MessageBox.Show("No records found");
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        public void SaveFunction()
        {
            try
            {
                AttendanceInfo attendanceInfo = new AttendanceInfo();
                AttendanceSP   attendanceSp   = new AttendanceSP();


                for (int i = 0; i < dgvAttendance.RowCount - 1; i++)
                {
                    if (dgvAttendance.Rows[i].Cells["dgvcmbstudent"].Value.ToString() != string.Empty && dgvAttendance.Rows[i].Cells["dgvcmbstudent"].Value != null)
                    {
                        attendanceInfo.StudentId = Convert.ToInt32(dgvAttendance.Rows[i].Cells["dgvcmbstudent"].Value);
                    }

                    if (dgvAttendance.Rows[i].Cells["dgvstatus"].Value.ToString() != string.Empty && dgvAttendance.Rows[i].Cells["dgvstatus"].Value != null)
                    {
                        attendanceInfo.Status = Convert.ToString(dgvAttendance.Rows[i].Cells["dgvstatus"].Value);
                    }

                    attendanceInfo.Date = Convert.ToDateTime(datePicker.Text);

                    attendanceInfo.ClassId = Convert.ToInt32(cmbClass.SelectedValue);

                    attendanceInfo.TermId = Convert.ToInt32(cmbTerm.SelectedValue);


                    attendanceSp.AttendanceAdd(attendanceInfo);
                }

                clearfielsd();
                Messages.SavedMessage();
            }
            catch (Exception ex)
            {
                MessageBox.Show(" SaveFunction " + ex.Message);
            }
        }