Exemple #1
0
        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 btnSave_Click(object sender, EventArgs e)
        {
            if (this.gData.Rows.Count == -1)
            {
                alert.Show("No data to save ....", alert.AlertType.info);
            }
            alert.Show("Saving ....", alert.AlertType.info);
            using (var context = new SmartdbEntities())
            {
                for (int i = 0; i < this.gData.Rows.Count - 1; i++)
                {
                    DataGridViewRow dr = gData.Rows[i];
                    if (dr != null && (dr.Cells["RegNo"].Value != null) && (dr.Cells["FullName"].Value != null))
                    {
                        try
                        {
                            context.Students.Add(new Student
                            {
                                //check for duplicate Admin number
                                Regno        = dr.Cells["RegNo"].Value.ToString(),
                                FullName     = dr.Cells["FullName"].Value.ToString(),
                                School       = dr.Cells["School"].Value.ToString(),
                                SchoolCode   = dr.Cells["SchoolCode"].Value.ToString(),
                                LearningMode = dr.Cells["LearningMode"].Value.ToString(),
                            });
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Check all entries are correct and retry", "Error");
                            // throw;
                        }
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "Critical error contact developer immediately \n :( :( :( :( :( :(:( :( ", "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                try
                {
                    context.SaveChanges();
                    alert.Show("Saved Successfully", alert.AlertType.success);
                }
                catch (Exception) { }
            }


            this.Close();
        }
Exemple #3
0
        private async void Home_Load(object sender, EventArgs e)
        {
            SetToolTip(tbLegalInfo, $"Info: \n Keywords like Good, bad, improving, indisciplined, positive, questionable \n are being tracked to determine overall discipline");

            List <Student> studs = await Task.Factory.StartNew(() =>
            {
                using (var context = new SmartdbEntities())
                {
                    return(context.Students.OrderBy(c => c.Regno)
                           .ToList());
                }
            });

            //first student in db default
            currentStudent = studs.FirstOrDefault();
            //chart updates auto

            UIset(currentStudent);
        }
Exemple #4
0
        private async Task <Student> StudFoundAsync(string regno)
        {
            var studentList = await Task.Factory.StartNew(() =>
            {
                using (var context = new SmartdbEntities())
                {
                    return(context.Students.ToList());
                }
            });

            foreach (var stud in studentList.Where(a => a.Regno.Equals(regno)))
            {
                if (regno == stud.Regno)
                {
                    return(stud);
                }
            }
            return(null);
        }
Exemple #5
0
        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;
                }
            }
        }
Exemple #6
0
        private async void tab2_Click(object sender, EventArgs e)
        {
            //prompt add student
            FrmAddStud ff = new FrmAddStud();

            if (ff.ShowDialog() == DialogResult.OK)
            {
                List <Student> studs = await Task.Factory.StartNew(() =>
                {
                    using (var context = new SmartdbEntities())
                    {
                        return(context.Students.OrderBy(c => c.Regno)
                               .ToList());
                    }
                });

                //first student in db default
                currentStudent = studs.LastOrDefault();
                //chart updates auto

                UIset(currentStudent);
            }
        }