Exemple #1
0
        /// <summary>
        /// Method that handles click on grade label. Left click shows edit grade form to edit given grade.
        /// Right click deletes given grade.
        /// </summary>
        /// <param name="sender">Clicked object</param>
        /// <param name="e">Event parameters</param>
        private async void ShowGradePanel(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var lblSender = sender as LinkLabel;
            var data = (Point)lblSender.Tag;

            var gradesPanel = this.Controls.Find("panel" + data.Y, true).First() as FlowLayoutPanel;

            var repo = new HttpSubjectDetailsRepository();
            var g = await repo.GetOne(data.X);
            //var g = repo.GetGrade(data.X);
            if (e.Button == MouseButtons.Left)
            {
                if (g == null)
                    MessageBox.Show("Test");
                //var editForm = Program.GetKernel().Get<EditGradeForm>(new ConstructorArgument("grade", g));
                var editForm = new EditGradeForm(g);
                editForm.ShowDialog();
                UpdateMainForm();
            }
            else if (e.Button == MouseButtons.Right)
            {
                await repo.DeleteOne(g);
                //repo.DeleteGrade(g);
                //gradesPanel.Controls.Remove(lblSender);
                //Refresh();
                UpdateMainForm();
            }
        }
Exemple #2
0
        /// <summary>
        /// Calls edit form for grade
        /// </summary>
        /// <param name="sub">Subject to which grade will be added</param>
        private void AddGradeToSubject(SubjectsViewModel sub)
        {
            SubjectDetailsViewModel grade = new SubjectDetailsViewModel()
            {
                sub_id = sub.id,
                grade_weight = 1
            };

            var editForm = new EditGradeForm(grade, true);
            editForm.ShowDialog();
            UpdateMainForm();
        }