private void btnAdd_Click(object sender, EventArgs e) { try { if (txtName.CheckNull()) { return; } List <Subject> subjects = CallAPI.GetListContent <Subject, Subject>("GetSubjects"); if (subjects.Any(x => x.SubjectName == txtName.Text && x.Chapter == (Chapter)comboChapter.SelectedValue && x.Dept == (Dept)comboDept.SelectedValue)) { MessageBox.Show("The information was already entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Subject subject = new Subject { SubjectName = txtName.Text, Chapter = (Chapter)comboChapter.SelectedValue, Dept = (Dept)comboDept.SelectedValue }; subject = CallAPI.PostObjectAndGetObject <Subject, Subject>(subject, "AddNewSubject"); MessageBox.Show("The information has been entered successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); ManageSubjects_Load(sender, e); } catch (Exception ex) { MessageBox.Show("An error occurred, please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ManageNoteBooks_Load(object sender, EventArgs e) { try { noteBooks = CallAPI.GetListContent <Models.NoteBook, Models.NoteBook>("GetNoteBooks"); if (!noteBooks.Any()) { foreach (Control item in this.Controls) { item.Enabled = false; } return; } noteBooksTitles = new List <NoteBooksTitle>(); foreach (var item in noteBooks) { noteBooksTitles.Add(new NoteBooksTitle { Id = item.Id, Title = item.Subject.SubjectName + " " + item.Subject.Dept.ToString() + " " + item.Subject.Chapter + " " + item.ReleaseDate.Year }); } comboDeptSubjectYear.DataSource = noteBooksTitles; comboDeptSubjectYear.DisplayMember = "Title"; comboDeptSubjectYear.ValueMember = "Id"; } catch { CheckData.ErrorMessage(); } }
private void AddNoteBook_Load(object sender, EventArgs e) { try { subjects = CallAPI.GetListContent <Subject, Subject>("GetSubjects"); features = CallAPI.GetListContent <Feature, Feature>("GetFeatures").Where(x => x.Id != 1).ToList(); noteBooks = CallAPI.GetListContent <Models.NoteBook, Models.NoteBook>("GetNoteBooks"); subjectsInDepts = new List <SubjectsInDept>(); foreach (var item in subjects) { subjectsInDepts.Add(new SubjectsInDept { Id = item.Id, Title = item.SubjectName + " " + item.Dept.ToString() + " " + item.Chapter }); } comboSubjects.DataSource = subjectsInDepts; comboSubjects.DisplayMember = "Title"; comboSubjects.ValueMember = "Id"; foreach (var feature in features) { chkFeatures.Items.Add(feature); } chkFeatures.DisplayMember = "Title"; chkFeatures.ValueMember = "Id"; } catch (Exception ex) { MessageBox.Show("There Are An Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ManageSubjects_Load(object sender, EventArgs e) { grdSubjects.DataSource = CallAPI.GetListContent <Subject, Subject>("GetSubjects"); grdSubjects.Columns["Id"].Visible = false; grdSubjects.Columns["NoteBooks"].Visible = false; comboChapter.DataSource = Enum.GetValues(typeof(Chapter)); comboDept.DataSource = Enum.GetValues(typeof(Dept)); }
private void ManageStudents_Load(object sender, EventArgs e) { students = CallAPI.GetListContent <Student, Student>("GetStudents"); FillGridView(students); var years = students.Select(x => x.LoginData.Year).Distinct().ToList(); comboYear.DataSource = years; }
private void ManageFeatures_Load(object sender, EventArgs e) { try { features = CallAPI.GetListContent <Feature, Feature>("GetFeatures"); FillGrid(); } catch (Exception ex) { MessageBox.Show("There Are An Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FillGrid() { lblTitle.Text = reseller.Title; resellerAndNoteBooks = CallAPI.GetListContent <Reseller, ResellerAndNoteBook>("GetResellerAndNoteBookByResellerId", reseller.Id.ToString()); List <ResellerAndNoteBooksVM> resellerAndNoteBooksVM = new List <ResellerAndNoteBooksVM>(); foreach (var item in resellerAndNoteBooks) { resellerAndNoteBooksVM.Add(new ResellerAndNoteBooksVM { NoteBookTitle = item.NoteBook.Subject.SubjectName + " " + item.NoteBook.Subject.Dept.ToString() + " " + item.NoteBook.Subject.Chapter + " " + item.NoteBook.ReleaseDate.Year, ResellerTitle = item.Reseller.Title, Count = item.Count, LastGrantDate = item.LastGrantDate }); } grdResellerAndNoteBook.DataSource = resellerAndNoteBooksVM; }
private void ManageStore_Load(object sender, EventArgs e) { comboLocation.DataSource = Enum.GetValues(typeof(Provinces)); resellers = CallAPI.GetListContent <Reseller, Reseller>("GetResellers"); grdStores.DataSource = resellers; grdStores.Columns["Id"].Visible = false; noteBooks = CallAPI.GetListContent <Models.NoteBook, Models.NoteBook>("GetNoteBooks"); noteBooksTitles = new List <NoteBooksTitle>(); foreach (var item in noteBooks) { noteBooksTitles.Add(new NoteBooksTitle { Id = item.Id, Title = item.Subject.SubjectName + " " + item.Subject.Dept.ToString() + " " + item.Subject.Chapter + " " + item.ReleaseDate.Year }); } comboNoteBook.DataSource = noteBooksTitles; comboNoteBook.DisplayMember = "Title"; comboNoteBook.ValueMember = "Id"; }
private void Reissuing_Load(object sender, EventArgs e) { noteBooks = CallAPI.GetListContent <Models.NoteBook, Models.NoteBook>("GetNoteBooks"); if (!noteBooks.Any()) { MessageBox.Show("There is no notebook yet", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnReissuing.Enabled = btnQrDownload.Enabled = false; return; } noteBooksTitles = new List <NoteBooksTitle>(); foreach (var item in noteBooks) { noteBooksTitles.Add(new NoteBooksTitle { Id = item.Id, Title = item.Subject.SubjectName + " " + item.Subject.Dept.ToString() + " " + item.Subject.Chapter + " " + item.ReleaseDate.Year }); } comboNoteBook.DataSource = noteBooksTitles; comboNoteBook.DisplayMember = "Title"; comboNoteBook.ValueMember = "Id"; }