コード例 #1
0
        private void AddScheduleForm_Load(object sender, EventArgs e)
        {
            this.datePicker.MaxDate = DateTime.Today.AddDays(7);
            this.datePicker.Value   = DateTime.Today;
            crs crs = new crs();
            Dictionary <int, string> dict = crs.CourseList();

            if (dict.Count > 0)
            {
                courseSelect.DataSource    = new BindingSource(dict, null);
                courseSelect.DisplayMember = "Value";
                courseSelect.ValueMember   = "Key";
                courseSelect.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("No Course Available", "Course Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            dict = (new Teacher()).ListAll();
            if (dict.Count > 0)
            {
                teacherSelect.DataSource    = new BindingSource(dict, null);
                teacherSelect.DisplayMember = "Value";
                teacherSelect.ValueMember   = "Key";
                teacherSelect.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("No Teacher Available", "Teacher Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
 private void FillData(crs crs)
 {
     crs.CourseName = this.courseName.Text.Trim();
     crs.Duration   = this.courseDuration.SelectedItem.ToString().Trim();
     crs.CType      = this.courseType.SelectedItem.ToString().Trim();
     crs.Benefits   = this.courseBenefits.Text.Trim();
     crs.Fee        = int.Parse(this.courseFee.Text.Trim());
 }
 private void delbtn_Click(object sender, EventArgs e)
 {
     crs = new crs();
     if (crs.Delete(cID))
     {
         MessageBox.Show("Data Deleted Successfully", "Course Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
 }
コード例 #4
0
        private void submitbtn_Click(object sender, EventArgs e)
        {
            crs = new crs();
            FillData(crs);
            bool insert = crs.AddCourse();

            if (insert)
            {
                MessageBox.Show("Course Added Successfully", "Course Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void CourseAddForm_Load(object sender, EventArgs e)
        {
            crs = new crs();
            this.courseDuration.SelectedIndex = 0;
            this.courseType.SelectedIndex     = 0;
            Dictionary <int, string> dict = crs.CourseList();

            this.coursetxt.DataSource = new BindingSource(dict, null);
            coursetxt.DisplayMember   = "Value";
            coursetxt.ValueMember     = "Key";
            crs.GetDetail(cID);
        }
 private void updatebtn_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(crs.CourseID))
     {
         crs = new crs();
         FillData(crs);
         if (crs.UpdateCourse(cID))
         {
             MessageBox.Show("Data Updated Successfully", "Course Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Select data to update", "Course Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }