Пример #1
0
        public void Remove()
        {
            DialogResult delete = MessageBox.Show("Are you sure delete student with id: " + ID_Course_tb.Text, "",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            int id = Convert.ToInt32(ID_Course_tb.Text);

            if (delete == DialogResult.Yes)
            {
                Courses course = new Courses();
                if (course.RemoveCourse(id) && ID_Course_tb.Text.Trim() != "")
                {
                    MessageBox.Show("Complete", "Delete Course", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Reset_Change();
                }
                else
                {
                    MessageBox.Show("Delete course failed", "Delete Course", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #2
0
        private void WindowsUIButtonPanel_ButtonChecked(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e)
        {
            Courses course = new Courses();
            string  tag    = ((WindowsUIButton)e.Button).Tag.ToString();

            switch (tag)
            {
            case "A1":

                course.Id          = Convert.ToInt32(ID_Course.Text);
                course.Label       = NameCourse.Text;
                course.Period      = Convert.ToInt32(Period_updown.Value);
                course.Description = Rich_decs.Text;
                if (course.CheckCourseName(course.Label))
                {
                    if (this.Check())
                    {
                        MessageBox.Show("The textbox control is blank! Please enter again", "Add Course", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (course.AddThisCourse())
                        {
                            MessageBox.Show("Add a new course successful!", "Add Course", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Add failed", "Add Course", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("This course already!. Please add a new course", "Add Course", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

            case "A2":
                try
                {
                    int    id          = Convert.ToInt32(ID_Course.Text);
                    string label       = NameCourse.Text;
                    int    period      = Convert.ToInt32(Period_updown.Value);
                    string description = Rich_decs.Text;
                    int    se          = Convert.ToInt32(ComboxBox_Semester.Text);
                    if (course.UpdateCourse(id, label, period, description, se))
                    {
                        MessageBox.Show("Edit course successful!", "Edit Course", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Edit course failed", "Edit Course", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch
                {
                }
                break;

            case "A3":
                DialogResult delete = MessageBox.Show("Are you sure delete student with id: " + ID_Course.Text, "",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                int ids = Convert.ToInt32(ID_Course.Text);
                if (delete == DialogResult.Yes)
                {
                    if (course.RemoveCourse(ids) && ID_Course.Text.Trim() != "")
                    {
                        MessageBox.Show("Complete", "Delete Course", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Delete course failed", "Delete Course", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                break;

            case "A4":
                this.RefreshList();
                break;
            }
        }