Exemple #1
0
        public AddSubjectForm(User user, IEnumerable <HandbookGrade> grades, SubjectsForm SubjectForm)
        {
            if (!String.IsNullOrEmpty(Properties.Settings.Default.Language))
            {
                // ВАЖНО: Устанавливать язык нужно до создания элементов формы!
                // Это можно сделать глобально, в рамках приложения в классе Program (см. файл Program.cs).
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language);
                System.Threading.Thread.CurrentThread.CurrentCulture   = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language);
            }
            InitializeComponent();
            cmbGrade.DropDownStyle = ComboBoxStyle.DropDownList;
            this.user        = user;
            this.grades      = grades;
            this.SubjectForm = SubjectForm;

            foreach (var grade in grades)
            {
                cmbGrade.Items.Add(grade.Number + grade.Name);
            }

            cmbGrade.SelectedIndexChanged += delegate
            {
                var index = cmbGrade.SelectedIndex;
                var list  = grades.ToList();
                this.grade = list[index];
            };
        }
Exemple #2
0
        public AddSubjectForm(User user, IEnumerable <HandbookGrade> grades, SubjectsForm SubjectForm, string id, string name, string gradeId)
        {
            InitializeComponent();
            cmbGrade.DropDownStyle = ComboBoxStyle.DropDownList;
            this.user        = user;
            this.grades      = grades;
            this.SubjectForm = SubjectForm;



            txtId.Text   = id;
            txtName.Text = name;
            var grade = grades.ToList().Where(g => g.Id == Int32.Parse(gradeId)).FirstOrDefault();

            this.grade = grade;
            var indexOfIntegerValue = grades.ToList().IndexOf(grade);


            foreach (var grade2 in grades)
            {
                cmbGrade.Items.Add(grade2.Number + grade2.Name);
            }

            cmbGrade.SelectedIndexChanged += delegate
            {
                var index = cmbGrade.SelectedIndex;
                var list  = grades.ToList();
                this.grade = list[index];
            };

            cmbGrade.SelectedItem = cmbGrade.Items[indexOfIntegerValue];
        }
        private async void subjectsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ApplicationViewModel applicationViewModel = new ApplicationViewModel();
            await applicationViewModel.GetSubjects(user.Login, user.Password);

            SubjectsForm subjectsForm = new SubjectsForm(user, applicationViewModel.handbookSubjects);

            subjectsForm.Show();
        }