void DeleteStudent() { if (!HasWritePrivilage()) { return; } if (MessageBox.Show("Czy na pewno chcesz usunąć wskazanego ucznia?\nPotwierdzenie tej operacji spowoduje usunięcie ucznia z bazy danych oraz wszystkich danych z nim powiązanych (przydziały ucznia do oddziałów klasowych we wszystkich okresach, jego nieobecności na zajęciach oraz wszystkie oceny przedmiotowe z całego okresu kształcenia)!", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { var recordCount = 0; var sqlParamWithValue = new HashSet <Tuple <string, object> >(); foreach (StudentAllocation S in olvStudent.SelectedObjects) { if (!HasWritePrivilage(S.StudentClass.ID)) { continue; } sqlParamWithValue.Add(new Tuple <string, object>("@ID", S.Student.ID)); } using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); recordCount = dbs.RemoveManyRecordsAsync(StudentSQL.DeleteStudent(), sqlParamWithValue).Result; } MessageBox.Show($"{recordCount} rekordów zostało usuniętych.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshData(); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
async Task <int> UpdateStudentAllocationAsync(dlgStudent dlg, int idAllocation) { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.UpdateRecordAsync(StudentSQL.UpdateStudentAllocation(), CreateAllocationParamWithValue(dlg, idAllocation))); } }
async Task <long> AddStudent() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.AddRecordAsync(StudentSQL.InsertStudent(), CreateInsertParams())); } } catch (Exception) { throw; } }
private async Task <IEnumerable <int> > GetRepeaterListAsync() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(StudentSQL.SelectRepeater(UserSession.User.Settings.SchoolID.ToString(), UserSession.User.Settings.SchoolYear), (R) => R.GetInt32(0))); } } catch (Exception) { throw; } }
private async Task <IEnumerable <StudentAllocation> > GetStudentListAsync() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(StudentSQL.SelectStudent(UserSession.User.Settings.SchoolID.ToString(), UserSession.User.Settings.SchoolYear), StudentAllocationModel)); } } catch (Exception) { throw; } }