private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (listViewCourse.SelectedItems.Count > 0)
            {
                try
                {
                    if (IsValid())
                    {
                        int courseID = int.Parse(listViewCourse.SelectedItems[0].SubItems[0].Text);
                        BusinessLogic.CourseManager courseManager = new BusinessLogic.CourseManager();
                        BusinessEntity.CourseEntity oldCourse     = courseManager.GetSingle(courseID);

                        BusinessEntity.CourseEntity newCourse = new BusinessEntity.CourseEntity();

                        newCourse.ID          = courseID;
                        newCourse.Title       = txtTitle.Text;
                        newCourse.Description = txtDescription.Text;

                        courseManager.Update(newCourse);

                        MessageBox.Show("Course Information Updated Successfully.");
                        LoadCourses();
                    }
                }
                catch (Exception ex)
                {
                    //save to log table
                    MessageBox.Show("Update Failed, Please try again.");
                }
            }
            else
            {
                MessageBox.Show("Please select course from the list first.");
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (listViewCourse.SelectedItems.Count > 0)
            {
                try
                {
                    DialogResult result = MessageBox.Show("Are you sure you want to delete the selected record?", "Training Information Management System", MessageBoxButtons.YesNo);
                    if (result == DialogResult.OK)
                    {
                        int courseID = int.Parse(listViewCourse.SelectedItems[0].SubItems[0].Text);
                        BusinessLogic.CourseManager courseManager = new BusinessLogic.CourseManager();
                        BusinessEntity.CourseEntity oldCourse     = courseManager.GetSingle(courseID);

                        courseManager.Delete(oldCourse);
                        MessageBox.Show("Course Information Deleted Successfully.");
                        LoadCourses();
                    }
                }
                catch (Exception ex)
                {
                    //save to log table
                    MessageBox.Show("Delete Failed, Please try again.");
                }
            }
            else
            {
                MessageBox.Show("Please select trainee from the list first.");
            }
        }
        private void listViewCourse_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewCourse.SelectedItems.Count > 0)
            {
                int courseID = int.Parse(listViewCourse.SelectedItems[0].SubItems[0].Text);
                BusinessLogic.CourseManager courseManager = new BusinessLogic.CourseManager();
                BusinessEntity.CourseEntity course        = courseManager.GetSingle(courseID);

                txtTitle.Text       = course.Title;
                txtDescription.Text = course.Description;
            }
        }
Exemple #4
0
        private void frmTraineeCourse_Load(object sender, EventArgs e)
        {
            this.Tag = "Bereket";

            LoadTraineeCourses();

            BusinessLogic.TraineeManager        traineeManager = new BusinessLogic.TraineeManager();
            List <BusinessEntity.TraineeEntity> trainees       = traineeManager.GetAll();

            cboTrainee.DataSource    = trainees;
            cboTrainee.ValueMember   = "ID";
            cboTrainee.DisplayMember = "Fullname";

            BusinessLogic.CourseManager        courseManager = new BusinessLogic.CourseManager();
            List <BusinessEntity.CourseEntity> courses       = courseManager.GetAll();

            cboCourse.DataSource    = courses;
            cboCourse.ValueMember   = "ID";
            cboCourse.DisplayMember = "Title";
        }
        private void LoadCourses()
        {
            BusinessLogic.CourseManager        courseManager  = new BusinessLogic.CourseManager();
            List <BusinessEntity.CourseEntity> courseEntities = courseManager.GetAll();

            listViewCourse.Items.Clear();
            if (courseEntities == null)
            {
                MessageBox.Show("Sorry database error occured, please try again.");
            }
            else
            {
                foreach (BusinessEntity.CourseEntity courseEntity in courseEntities)
                {
                    ListViewItem item = new ListViewItem(courseEntity.ID.ToString());
                    item.SubItems.Add(courseEntity.Title);

                    listViewCourse.Items.Add(item);
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValid())
                {
                    BusinessLogic.CourseManager courseManager = new BusinessLogic.CourseManager();
                    BusinessEntity.CourseEntity course        = new BusinessEntity.CourseEntity();
                    course.Title       = txtTitle.Text;
                    course.Description = txtDescription.Text;

                    courseManager.Save(course);
                    MessageBox.Show("Course Information Saved Successfully.");
                    LoadCourses();
                }
            }
            catch (Exception ex)
            {
                //save to log table
                MessageBox.Show("Save Failed, Please try again.");
            }
        }
Exemple #7
0
        private void PopulateCombobox()
        {
            //populate gender
            BusinessLogic.GenderManager        genderManager = new BusinessLogic.GenderManager();
            List <BusinessEntity.GenderEntity> genders       = genderManager.GetAll();

            genders.Add(new BusinessEntity.GenderEntity()
            {
                ID = 0, Title = "All"
            });

            cboGender.DataSource    = genders.OrderBy(x => x.ID).ToList();
            cboGender.ValueMember   = "ID";
            cboGender.DisplayMember = "Title";

            //populate academic level
            BusinessLogic.AcademicLevelManager        academicLevelManager = new BusinessLogic.AcademicLevelManager();
            List <BusinessEntity.AcademicLevelEntity> academicLevels       = academicLevelManager.GetAll();

            academicLevels.Add(new BusinessEntity.AcademicLevelEntity()
            {
                ID = 0, Title = "All"
            });

            cboAcademicLevel.DataSource    = academicLevels.OrderBy(x => x.ID).ToList();
            cboAcademicLevel.ValueMember   = "ID";
            cboAcademicLevel.DisplayMember = "Title";

            //populate trainee
            BusinessLogic.TraineeManager        traineeManager = new BusinessLogic.TraineeManager();
            List <BusinessEntity.TraineeEntity> trainees       = traineeManager.GetAll();

            trainees.Add(new BusinessEntity.TraineeEntity()
            {
                ID = 0, Fullname = "All"
            });

            cboTrainee.DataSource    = trainees.OrderBy(x => x.ID).ToList();
            cboTrainee.ValueMember   = "ID";
            cboTrainee.DisplayMember = "Fullname";

            cboTraineePayment.DataSource    = trainees.OrderBy(x => x.ID).ToList();
            cboTraineePayment.ValueMember   = "ID";
            cboTraineePayment.DisplayMember = "Fullname";

            //populate course
            BusinessLogic.CourseManager        courseManager = new BusinessLogic.CourseManager();
            List <BusinessEntity.CourseEntity> courses       = courseManager.GetAll();

            courses.Add(new BusinessEntity.CourseEntity()
            {
                ID = 0, Title = "All"
            });

            cboCourse.DataSource    = courses.OrderBy(x => x.ID).ToList();
            cboCourse.ValueMember   = "ID";
            cboCourse.DisplayMember = "Title";

            cboCoursePayment.DataSource    = courses.OrderBy(x => x.ID).ToList();
            cboCoursePayment.ValueMember   = "ID";
            cboCoursePayment.DisplayMember = "Title";
        }