예제 #1
0
        private void assignButton_Click(object sender, EventArgs e)
        {
            CourseAssignToTeacher courseAssignToTeacher = new CourseAssignToTeacher();


            float remainingCredit;

            float.TryParse(remainingCreditTextBox.Text, out remainingCredit);

            float courseCredit;

            float.TryParse(creditTextBox.Text, out courseCredit);

            remainingCredit -= courseCredit;


            DialogResult result = DialogResult.None;

            if (remainingCredit <= 0)
            {
                string massageBoxString = "Teacher is Assigned more Credit\n"
                                          + "Do you want to continue";
                string            titleBarString    = "Warning";
                MessageBoxButtons messageBoxButtons = MessageBoxButtons.YesNo;
                MessageBoxIcon    messageBoxIcon    = MessageBoxIcon.Information;

                result = MessageBox.Show(massageBoxString, titleBarString, messageBoxButtons,
                                         messageBoxIcon);
            }
            if (result == DialogResult.No)
            {
                return;
            }
            // erokom return condition ta 1ta choto limited condtion. mane ei jaiga projonto ashle ei condition ta mante hobe
            // na hoi program break korbe

            courseAssignToTeacher.RemainingCredit = remainingCredit;

            int deptId;

            int.TryParse(hiddenDeptId.Text, out deptId);
            courseAssignToTeacher.DeptId = deptId;

            int teacherId;

            int.TryParse(hiddenTeacherId.Text, out teacherId);
            courseAssignToTeacher.TeacherId = teacherId;

            int courseId;

            int.TryParse(hiddenCourseId.Text, out courseId);
            courseAssignToTeacher.CourseId = courseId;



            if (courseAssignToTeacherManager.IsExistCourse(courseAssignToTeacher))
            {
                MessageBox.Show(@"This Course already assign to a teacher");
                return;
            }

            string massage = courseAssignToTeacherManager.SaveCourseAssignToTeacher(courseAssignToTeacher);

            MessageBox.Show(massage);
        }