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 = SchoolClassSQL.DeleteSchoolClass(); var count = 0; var sqlParamWithValue = new HashSet <Tuple <string, object> >(); foreach (SchoolClass SC in olvKlasa.CheckedObjects) { sqlParamWithValue.Add(new Tuple <string, object>("@ID", SC.ID)); } using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); count = dbs.RemoveManyRecordsAsync(sqlString, sqlParamWithValue).Result; } RefreshData(); MessageBox.Show($"{count} rekordów zostało usuniętych.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private async Task <int> UpdateData(dlgSchoolClass dlg, SchoolClass SC) { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.UpdateRecordAsync(SchoolClassSQL.UpdateSchoolClass(), CreateUpdateParams(dlg, SC.ID))); } }
static SchoolClass() { IEnumerable <int> classLine; using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); classLine = dbs.FetchRecordSetAsync(SchoolClassSQL.SelectSchoolClassLine(UserSession.User.Settings.SchoolID.ToString(), UserSession.User.Settings.SchoolYear), (R) => Convert.ToInt32(R[0])).Result; } foreach (var Line in classLine) { ClassLine.Add(Line, classLineDescription[Line]); } }
public static IEnumerable <SchoolClass> GetClassList() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(dbs.FetchRecordSetAsync(SchoolClassSQL.SelectSchoolClassCombo(UserSession.User.Settings.SchoolID.ToString(), UserSession.User.Settings.SchoolYear), SchoolClassModel).Result); } } catch (Exception) { throw; } }
public static async Task <IEnumerable <string> > GetClassList() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(SchoolClassSQL.SelectClassCombo(UserSession.User.Settings.SchoolID.ToString(), UserSession.User.Settings.SchoolYear), (R) => R["Kod"].ToString())); } } catch (Exception) { throw; } }
async Task <long> AddSchoolClass() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.AddRecordAsync(SchoolClassSQL.InsertSchoolClass(), CreateInsertParams())); } } catch (Exception) { throw; } }
async Task <IEnumerable <SchoolClass> > GetSubjectList() { try { var PreviousSchoolYear = $"{nudStartYear.Value}/{nudEndYear.Value}"; using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(SchoolClassSQL.SelectSchoolClassList(UserSession.User.Settings.SchoolID.ToString(), PreviousSchoolYear), (R) => new SchoolClass { ClassName = R["NazwaKlasy"].ToString(), ClassCode = R["KodKlasy"].ToString(), IsVirtual = (YesNo)Convert.ToInt64(R["IsVirtual"]) })); } } catch (Exception) { throw; } }
public static async Task <IEnumerable <SchoolClass> > GetClassList() { try { using (var scope = AppSession.TypeContainer.BeginLifetimeScope()) { var dbs = scope.Resolve <IDataBaseService>(); return(await dbs.FetchRecordSetAsync(SchoolClassSQL.SelectSchoolClassCombo(UserSession.User.Settings.SchoolID.ToString(), UserSession.User.Settings.SchoolYear), (R) => new SchoolClass() { ID = Convert.ToInt32(R["ID"]), ClassCode = R["KodKlasy"].ToString(), ClassName = R["NazwaKlasy"].ToString() })); } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(new HashSet <SchoolClass>()); } }