private void cmdDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Czy na pewno chcesz usunąć wskazane pozycje?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { var sqlString = SubjectSQL.DeleteSubject(); var recordCount = 0; var sqlParamWithValue = new HashSet <Tuple <string, object> >(); foreach (SubjectModel s in olvSchoolType.CheckedObjects) { sqlParamWithValue.Add(new Tuple <string, object>("@ID", s.ID)); } using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); recordCount = dbs.RemoveManyRecordsAsync(sqlString, sqlParamWithValue).Result; } GetData(olvSchoolType); MessageBox.Show($"Liczba usuniętych rekordów: {recordCount}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private async Task <IEnumerable <SubjectModel> > GetSubjectList() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(SubjectSQL.SelectSubject(), SubjectModel.Create)); } } catch (Exception) { throw; } }
private async Task <IEnumerable <SchoolSubjectModel> > GetSchoolSubjectList() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(SubjectSQL.SelectSchoolSubject(UserSession.User.Settings.SchoolID.ToString()), SchoolSubjectModel.CreateSchoolSubject)); } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(new HashSet <SchoolSubjectModel>()); } }
async Task <IEnumerable <SubjectModel> > GetSubjectList(string ClassId) { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(SubjectSQL.SelectSchoolSubject(UserSession.User.Settings.SchoolID.ToString(), ClassId), (R) => new SubjectModel() { ID = Convert.ToInt32(R["ID"]), Alias = R["Alias"].ToString() })); } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(new HashSet <SubjectModel>()); } }