Пример #1
0
        private void frm_Barcordes_Load(object sender, EventArgs e)
        {
            // load all student course registration IDs
            try
            {
                gridBarcode.DataSource = null;
                var source = RegistrationCodesDataAccess.getBarcodes();
                //gridBarcode.DataSource = source
                //    .Select(x => new
                //    {
                //        StudentID = x.StudentId,
                //        StudentName = x.StudentName,
                //        CourseId = x.CourseId,
                //        CourseName = x.CourseName,
                //        RegistrationId = x.RegistrationId,
                //        IssuedDate = x.IssuedDate,
                //        IssuedBy = x.IssuedBy
                //    });

                gridBarcode.DataSource = source;

                gridBarcode.Columns["StudentId"].HeaderText      = "Student ID";
                gridBarcode.Columns["StudentName"].HeaderText    = "Student Name";
                gridBarcode.Columns["CourseId"].HeaderText       = "Course ID";
                gridBarcode.Columns["CourseName"].HeaderText     = "Course Name";
                gridBarcode.Columns["RegistrationId"].HeaderText = "Course Registration ID";
                gridBarcode.Columns["IssuedDate"].HeaderText     = "Issued Date";
                gridBarcode.Columns["IssuedBy"].HeaderText       = "Issued By";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void txtCourseId_KeyDown(object sender, KeyEventArgs e)
        {
            // Display course info
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    var course = new Course();
                    course.RefNo = txtCourseId.Text;

                    var record = CoursesDataAccess.findCourseById(course);
                    if (record == null)
                    {
                        MessageBox.Show("Course ID not found. Please check the Course-ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        // display course fee and course name
                        txtCourseName.Text = record.Title;
                        txtFee.Text        = record.Fee.ToString();

                        // display lecturer Id and name
                        var lecturer = CourseEnrollmentDataAccess.findCourseByCourseId(txtCourseId.Text);
                        if (lecturer == null)
                        {
                            MessageBox.Show("Course lecturer details not found. Please check the course-ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            // display lecturer info
                            txtLectuerId.Text    = lecturer.LecturerId;
                            txtLecturerName.Text = lecturer.LecturerName;

                            // find student id
                            var registration = new RegistrationIds();
                            registration.RegistrationId = txtRegistrationId.Text;

                            var studentRecords = RegistrationCodesDataAccess.findStudentByRegistrationId(registration);

                            if (studentRecords == null)
                            {
                                MessageBox.Show("Unable to locate student ID. Please check the registration ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                            else
                            {
                                studentId = studentRecords.StudentId;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
        private void txt_RegistrationId_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    var registration = new RegistrationIds();
                    registration.RegistrationId = txt_RegistrationId.Text;

                    var record = RegistrationCodesDataAccess.findStudentByRegistrationId(registration);
                    if (record == null)
                    {
                        MessageBox.Show("Registration ID not found. Please check the registration ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        //// get parent contact no.
                        var parentInfo = StudentDataAccess.findParentInfo(record.StudentId);
                        if (parentInfo == null)
                        {
                            return;
                        }
                        else if (parentInfo.Mobile == null)
                        {
                            return;
                        }
                        else
                        {
                            parentContact = parentInfo.Pmobile; // assign phone number
                        }
                        var lecturerInfo = CourseEnrollmentDataAccess.findRegistrationDateByStudentId(record.RegistrationId, record.CourseId);
                        if (lecturerInfo == null)
                        {
                            MessageBox.Show("Unable to locate lecturer details", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            txtStudentId.Text    = record.StudentId;
                            txtStudentName.Text  = record.StudentName;
                            txt_CourseId.Text    = record.CourseId;
                            txt_CourseName.Text  = record.CourseName;
                            txtLecturerID.Text   = lecturerInfo.LecturerId;
                            txtLecturerName.Text = lecturerInfo.LecturerName;

                            Submit(); // call mark attendance
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #4
0
        private void gridCourses_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            // fill course, lecturer fields and find student Id
            try
            {
                // find course info and lecturer info
                txtCourseId.Text     = gridCourses.SelectedRows[0].Cells[0].Value.ToString();
                txtCourseName.Text   = gridCourses.SelectedRows[0].Cells[1].Value.ToString();
                txtLectuerId.Text    = gridCourses.SelectedRows[0].Cells[2].Value.ToString();
                txtLecturerName.Text = gridCourses.SelectedRows[0].Cells[3].Value.ToString();

                // find course fee
                var course = new Course();
                course.RefNo = txtCourseId.Text;

                var record = CoursesDataAccess.findCourseById(course);
                if (record == null)
                {
                    MessageBox.Show("Course ID not found. Please check the Course-ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    // display course fee
                    txtFee.Text = record.Fee.ToString();

                    // find student id
                    var registration = new RegistrationIds();
                    registration.RegistrationId = txtRegistrationId.Text;

                    var studentRecords = RegistrationCodesDataAccess.findStudentByRegistrationId(registration);

                    if (studentRecords == null)
                    {
                        MessageBox.Show("Unable to locate student ID. Please check the registration ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        studentId = studentRecords.StudentId;
                    }

                    // display last paid month
                    var lastRecord = PaymentDataAccess.getLastRecord(txtRegistrationId.Text, txtCourseId.Text);
                    MessageBox.Show(lastRecord.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        private void txtRegistrationId_KeyDown(object sender, KeyEventArgs e)
        {
            // fill student name and enrolled courses in dropdown
            try
            {
                if (e.KeyCode == Keys.Enter)
                {
                    var registrationCode = new RegistrationIds();
                    registrationCode.RegistrationId = txtRegistrationId.Text;

                    var record = RegistrationCodesDataAccess.findStudentByRegistrationId(registrationCode);

                    if (record == null)
                    {
                        MessageBox.Show("Registration ID not found. Please check the ID", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        txtStudentName.Text    = record.StudentName; // student name
                        gridCourses.DataSource = null;

                        //var source = CourseEnrollmentDataAccess.findCourseByStudentId(record.StudentId).Where(x => x.IsRemoved == false);
                        var source = CourseEnrollmentDataAccess.findCourseByStudentId(record.RegistrationId).Where(x => x.IsRemoved == false);
                        gridCourses.DataSource = source
                                                 .Select(x => new
                        {
                            CourseId     = x.CourseId,
                            CourseName   = x.CourseName,
                            LecturerId   = x.LecturerId,
                            LecturerName = x.LecturerName
                        }).ToList();

                        gridCourses.Columns["CourseId"].HeaderText     = "Course ID";
                        gridCourses.Columns["CourseName"].HeaderText   = "Course Name";
                        gridCourses.Columns["LecturerId"].HeaderText   = "Lecturer ID";
                        gridCourses.Columns["LecturerName"].HeaderText = "Lecturer Name";



                        // setting column width
                        gridCourses.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #6
0
        private void txt_Find_TextChanged(object sender, EventArgs e)
        {
            // filter registration code
            try
            {
                gridBarcode.DataSource = null;
                var source = RegistrationCodesDataAccess.filterRegistrationId(txt_Find.Text);

                gridBarcode.DataSource = source;

                gridBarcode.Columns["StudentId"].HeaderText      = "Student ID";
                gridBarcode.Columns["StudentName"].HeaderText    = "Student Name";
                gridBarcode.Columns["CourseId"].HeaderText       = "Course ID";
                gridBarcode.Columns["CourseName"].HeaderText     = "Course Name";
                gridBarcode.Columns["RegistrationId"].HeaderText = "Course Registration ID";
                gridBarcode.Columns["IssuedDate"].HeaderText     = "Issued Date";
                gridBarcode.Columns["IssuedBy"].HeaderText       = "Issued By";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // add new course registration
            try
            {
                // Course registration barcode
                var year = DateTime.Now.Year.ToString();
                year = year.Substring(2);
                var month       = DateTime.Now.Month.ToString();
                var date        = DateTime.Now.Day.ToString();
                var hour        = DateTime.Now.Hour.ToString();
                var minute      = DateTime.Now.Minute.ToString();
                var miliseconds = DateTime.Now.Millisecond.ToString();

                var RegistrationId = year + month + date + hour + minute + miliseconds; // registration id

                var enrollment = new CourseEnrollment();
                enrollment.RegisteredDate = Convert.ToDateTime(dateRegister.Value.ToShortDateString());
                enrollment.StudentId      = txtStudentId.Text;
                enrollment.RegistrationId = RegistrationId;
                enrollment.StudentName    = txtStudentName.Text;
                enrollment.CourseId       = txtCourseId.Text;
                enrollment.CourseName     = txtCourseName.Text;
                enrollment.LecturerId     = txtLecturerId.Text;
                enrollment.LecturerName   = txtLecturerName.Text;

                var result = CourseEnrollmentDataAccess.addEnrollment(enrollment);

                if (result == true)
                {
                    MessageBox.Show("Course registration has been completed successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    gridRefresh(); // call grid refresh method

                    var barcodeInfo = new RegistrationIds();
                    barcodeInfo.StudentId      = txtStudentId.Text;
                    barcodeInfo.StudentName    = txtStudentName.Text;
                    barcodeInfo.CourseId       = txtCourseId.Text;
                    barcodeInfo.CourseName     = txtCourseName.Text;
                    barcodeInfo.RegistrationId = RegistrationId;
                    barcodeInfo.IssuedDate     = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    barcodeInfo.IssuedBy       = Username;

                    var output = RegistrationCodesDataAccess.add(barcodeInfo);

                    if (output == true)
                    {
                        // show barcode form

                        var Barcode = new frm_CourseRegistrationCode(RegistrationId);
                        Barcode.Show();

                        clearField(); // call clear field method
                    }
                    else
                    {
                        MessageBox.Show("Unable to record registraion data", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                else
                {
                    MessageBox.Show("Course registration has been failed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }



                //    var record = CourseEnrollmentDataAccess.findLastEntry(txtCourseId.Text);
                //    if (record == null)
                //    {
                //        var lastEntry = 1;
                //        lastEntry += 1; // adding 1 to last entry
                //        var courseId = txtCourseId.Text;

                //        RegistrationBarcodeId = courseId + lastEntry; // registration Id
                //    }
                //    else
                //    {
                //        var lastEntry = record.Id;
                //        lastEntry += 1; // adding 1 to last entry
                //        var courseId = txtCourseId.Text;

                //        RegistrationBarcodeId = courseId + lastEntry; // registration Id
                //    }


                //    var enrollment = new CourseEnrollment();
                //    enrollment.RegisteredDate = Convert.ToDateTime(dateRegister.Value.ToShortDateString());
                //    enrollment.StudentId = txtStudentId.Text;
                //    enrollment.RegistrationId = RegistrationBarcodeId;
                //    enrollment.StudentName = txtStudentName.Text;
                //    enrollment.CourseId = txtCourseId.Text;
                //    enrollment.CourseName = txtCourseName.Text;
                //    enrollment.LecturerId = txtLecturerId.Text;
                //    enrollment.LecturerName = txtLecturerName.Text;

                //    var result = CourseEnrollmentDataAccess.addEnrollment(enrollment);

                //    if (result == true)
                //    {
                //        MessageBox.Show("Course registration has been completed successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //        gridRefresh(); // call grid refresh method

                //        var barcodeInfo = new RegistrationIds();
                //        barcodeInfo.StudentId = txtStudentId.Text;
                //        barcodeInfo.StudentName = txtStudentName.Text;
                //        barcodeInfo.CourseId = txtCourseId.Text;
                //        barcodeInfo.CourseName = txtCourseName.Text;
                //        barcodeInfo.RegistrationId = RegistrationBarcodeId;
                //        barcodeInfo.IssuedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                //        barcodeInfo.IssuedBy = Username;

                //        var output = RegistrationCodesDataAccess.add(barcodeInfo);

                //        if (output == true)
                //        {
                //            // show barcode form

                //            var Barcode = new frm_CourseRegistrationCode(RegistrationBarcodeId);
                //            Barcode.Show();

                //            clearField(); // call clear field method
                //        }
                //        else
                //        {
                //            MessageBox.Show("Unable to record registraion data", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //        }
                //    }
                //    else
                //    {
                //        MessageBox.Show("Course registration has been failed", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed : " + ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }