private async void UIset(Student fst) { lblName.Text = fst.FullName; lblSchoolAndNo.Text = $"{fst.School} - {fst.SchoolCode}"; //EschoolKe Secondary - 20154245 lblMOL.Text = $"Mode of Learning - {fst.LearningMode}"; //Mode of Learning - Bording lblRegno.Text = $"Reg NO - {fst.Regno}"; //Reg NO - 17052 //look for data on discpline Disciplinary mDis = null; List <Disciplinary> studdis = await Task.Factory.StartNew(() => { using (var context = new SmartdbEntities()) { return(context.Disciplinaries .Where(x => x.Regno == fst.Regno) .ToList()); } }); //latest case mDis = studdis.OrderBy(x => x.Id).LastOrDefault(); if (mDis != null) { tbLegalInfo.Text = mDis.Details; SetUpDrops(mDis); } UpdateCharts(studdis); //charts consume this data }
private void SetUpDrops(Disciplinary dsss) { //check drop values if (dsss.level > 79) { dropLevels.selectedIndex = 0; } if (dsss.level > 50 & dsss.level < 80) { dropLevels.selectedIndex = 2; } if (dsss.level >= 0 & dsss.level < 50) { dropLevels.selectedIndex = 1; } }
private void button1_Click(object sender, EventArgs e) { //verification if (currentStudent == null) { alert.Show("Required info \n Search for Student", alert.AlertType.warnig); return; } if (disAction == 0 & disLevel == 0) { alert.Show("Required info \n Select provided options", alert.AlertType.warnig); return; } //save the current student info using (var context = new SmartdbEntities()) { Disciplinary dd = new Disciplinary(); dd.Regno = currentStudent.Regno; dd.Action = dropAction.selectedValue.ToString(); dd.Details = tbLegalInfo.Text; dd.level = (disAction + disLevel); try { context.Disciplinaries.Add(dd); context.SaveChanges(); alert.Show("Saved Successfully", alert.AlertType.success); //set ui again UIset(currentStudent); } catch (Exception) { throw; } } }