private void GetAndDisplaySubjects()
        {
            ListSubjects.Clear();

            SqlConnection  con  = GeneralMethods.ConnectToDatabase();
            SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * From [SUBJECT] WHERE SemID='" + ViewModelLocator.SemesterSelectViewModel.SelectedSemester.SemID + "'", con);
            DataTable      dt   = new DataTable();

            sda2.Fill(dt);
            con.Close();

            for (int x = 0; x < dt.Rows.Count; x++)
            {
                SUBJECT newSubject = new SUBJECT();

                newSubject.Description    = dt.Rows[x]["Description"].ToString();
                newSubject.PrelimPercent  = Convert.ToDouble(dt.Rows[x]["PrelimPercent"]);
                newSubject.MidtermPercent = Convert.ToDouble(dt.Rows[x]["MidtermPercent"]);
                newSubject.PrefiPercent   = Convert.ToDouble(dt.Rows[x]["PrefiPercent"]);
                newSubject.Schedule       = dt.Rows[x]["Schedule"].ToString();
                newSubject.Units          = Convert.ToInt16(dt.Rows[x]["Units"]);
                newSubject.SubjectCode    = dt.Rows[x]["Subject_Code"].ToString();
                newSubject.SubjectID      = Convert.ToInt16(dt.Rows[x]["Subject_ID"]);
                newSubject.SemID          = Convert.ToInt16(dt.Rows[x]["SemID"]);
                newSubject.Base           = Convert.ToDouble(dt.Rows[x]["Base"]);

                ListSubjects.Add(newSubject);
            }

            UsedUnits = ComputeMaxUnits();
            MaxUnits  = ViewModelLocator.SemesterSelectViewModel.SelectedSemester.MaxUnits;
        }
Exemplo n.º 2
0
        private void fillLists()
        {
            var asigs  = SubjectsService.GetAll(true).Result;
            var teachs = TeachersService.GetAll(true).Result;
            var trimes = TrimestresService.GetAll(true).Result;

            asigs.Insert(0, new Subjects {
                SubjectId = -1, SubjectName = "Seleccione ---"
            });
            teachs.Insert(0, new Teachers {
                TeacherId = -1, DisplayName = "Seleccione ---"
            });
            trimes.Insert(0, new Trimestres {
                TrimestreId = -1, Name = "Seleccione ---"
            });

            ListTrimestres.BeginInvoke(new Action(() => {
                ListTrimestres.DisplayMember = "Name";
            }));
            ListTrimestres.BeginInvoke(new Action(() => {
                ListTrimestres.ValueMember = "TrimestreID";
            }));
            ListTrimestres.BeginInvoke(new Action(() => {
                ListTrimestres.DataSource = trimes;
            }));

            ListTeachers.BeginInvoke(new Action(() => {
                ListTeachers.DisplayMember = "DisplayName";
            }));
            ListTeachers.BeginInvoke(new Action(() => {
                ListTeachers.ValueMember = "TeacherID";
            }));
            ListTeachers.BeginInvoke(new Action(() => {
                ListTeachers.DataSource = teachs;
            }));

            ListSubjects.BeginInvoke(new Action(() => {
                ListSubjects.DisplayMember = "SubjectName";
            }));
            ListSubjects.BeginInvoke(new Action(() => {
                ListSubjects.ValueMember = "SubjectID";
            }));
            ListSubjects.BeginInvoke(new Action(() => {
                ListSubjects.DataSource = asigs;
            }));

            this.Invoke(new MethodInvoker(() => {
                HaveFilledLists = true;
            }));
            // HaveFilledLists = true;
        }
 private void BtnReset_Click(object sender, EventArgs e)
 {
     numericStudents.Value = 0;
     comboClassnum.Text    = "";
     checkTeacher.Checked  = false;
     ListSubjects.SetItemChecked(0, false);
     ListSubjects.SetItemChecked(1, false);
     ListSubjects.SetItemChecked(2, false);
     ListSubjects.SetItemChecked(3, false);
     ListSubjects.SetItemChecked(4, false);
     ListSubjects.SetItemChecked(5, false);
     ListSubjects.SetItemChecked(6, false);
     ListSubjects.SetItemChecked(7, false);
     comboEducation.Text  = "";
     comboGender.Text     = "";
     textDescription.Text = "";
     textAddress.Text     = "";
     textSurname.Text     = "";
     textName.Text        = "";
     textNumber.Text      = "";
     textMail.Text        = "";
 }