private void add_btn_Click(object sender, EventArgs e)
        {
            if (add_Subject_limiter.MaxValue > Subject.Count)
            {
                if (SubjectCode_txt.Text == "")
                {
                    MessageBox.Show("Subject Code must have value!!");
                }
                else
                {
                    subject_list_view.FocusedItem = null;
                    presenter.AddSubject();
                    DataTable dt = presenter.loadSubjects();

                    foreach (DataRow dr in dt.Rows)
                    {
                        //bug
                        string subjectCode = dr["study_name"].ToString();
                        string description = dr["study_decription"].ToString();
                        subject_list_view.Items.Add(subjectCode, 1);
                        Subject.Add(new Subjects
                        {
                            Subject_Code        = subjectCode,
                            Subject_Description = description
                        });
                        SubjectCode_txt.Text        = "";
                        SubjectDescription_txt.Text = "";
                        adding_panel.Visible        = false;
                    }
                }
                add_Subject_limiter.Value = Subject.Count();
            }
            else
            {
                MessageBox.Show("Subject is at limit");
            }
        }
Example #2
0
        private void add_btn_Click(object sender, EventArgs e)
        {
            bool same = false;

            if (add_Subject_limiter.MaxValue > Subject.Count)
            {
                if (SubjectCode_txt.Text == "")
                {
                    MessageBox.Show("Subject Code must have value!!");
                }
                else
                {
                    for (int x = 0; x < subject_list_view.Items.Count; x++)
                    {
                        if (subject_list_view.Items[x].Text == SubjectCode_txt.Text)
                        {
                            same = true;
                        }
                    }
                    if (same == false)
                    {
                        presenter.AddSubject();
                        loadSubjects();
                    }
                    else if (same == true)
                    {
                        MessageBox.Show("Subject Code has same value!!  ");
                    }
                }
            }
            else
            {
                MessageBox.Show("Subject is at limit");
            }
            add_subject_panel.Visible  = false;
            view_subject_panel.Visible = true;
        }