Beispiel #1
0
        void AddNew()
        {
            if (!HasWritePrivilage())
            {
                return;
            }
            using (var dlg = new dlgStudent(true))
            {
                dlg.cbMiejsceUr.DataSource  = City.ComboItems.GetCities();
                dlg.cbMiejsceZam.DataSource = City.ComboItems.GetCities();

                dlg.cbKlasa.SelectedIndexChanged += dlg.cbKlasa_SelectedIndexChanged;
                dlg.NewRecordAdded += NewRecord;
                dlg.ShowDialog();
                dlg.NewRecordAdded -= NewRecord;
                dlg.cbKlasa.SelectedIndexChanged -= dlg.cbKlasa_SelectedIndexChanged;
            }
        }
Beispiel #2
0
        void EditStudent()
        {
            var S = olvStudent.SelectedObject as StudentAllocation;

            if (S == null)
            {
                return;
            }
            if (!HasWritePrivilage(S.StudentClass.ID))
            {
                return;
            }
            using (var dlg = new dlgStudent(false))
            {
                FillStudentData(dlg, S);

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        var Student    = UpdateStudentAsync(dlg, S.Student.ID);
                        var Allocation = UpdateStudentAllocationAsync(dlg, S.ID);
                        if (Student.Result > 0 && Allocation.Result > 0)
                        {
                            NewRecord(S.Student.ID);
                            return;
                        }
                        throw new Exception("Aktualizacja danych nie powiodła się!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }