Beispiel #1
0
        // Add Course Module
        private void Addcoursebtn_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                AspireDB db = new AspireDB();

                Course cs   = new Course();
                byte[] hash = HelpMe.Md5toBinary(course_name.Text.ToString());
                Course got  = db.Courses.SingleOrDefault(Course => Course.CourseID == hash);
                if (got != null)
                {
                    new MsgBox("Duplicate entry");
                    return;
                }
                cs.Name     = course_name.Text.ToString();
                cs.CourseID = hash;
                cs.Level    = course_level.Text;
                cs.Nos      = Convert.ToInt32(course_strength.Text);
                db.Courses.Add(cs);
                db.SaveChanges();

                message.Text         = "Done";
                course_strength.Text = "";
                course_name.Text     = "";
                course_level.Text    = "";
                CourseControl.Instance.CreateList();
                CourseControl.Instance.FooterMessage("Course Added");
            }
        }
Beispiel #2
0
        private void filter_combo_SelectedIndexChanged(object sender, EventArgs e)
        {
            string item = filter_combo.Text;

            if (!item.Trim().Equals(""))
            {
                if (item.Trim().ToLower().Equals("all"))
                {
                    CreateList();
                }
                else
                {
                    string[] parsed = item.Split('-');
                    string   name   = parsed[0];
                    string   level  = HelpMe.GetFullForm(parsed[1]);
                    AspireDB db     = new AspireDB();
                    Course   c      = db.Courses.SingleOrDefault(Course => Course.Name == name && Course.Level == level);
                    CreateList(c);
                }
            }
            else
            {
                CreateList();
            }
        }
Beispiel #3
0
 // Add Students
 private void addstudentbtn_Click(object sender, EventArgs e)
 {
     if (ValidateChildren())
     {
         byte[]         hash  = HelpMe.Md5toBinary(course_name.Text.ToString());
         Course         cou   = db.Courses.SingleOrDefault(Course => Course.CourseID == hash);
         List <Student> sd    = db.Students.ToList();
         int            count = 0;
         foreach (Student ed in studs)
         {
             ed.Course = cou;
             bool skip = false;
             foreach (Student d in sd)
             {
                 if (ed.StudentID == d.StudentID)
                 {
                     skip = true;
                     break;
                 }
             }
             if (!skip)
             {
                 db.Students.Add(ed);
                 count++;
             }
         }
         db.SaveChanges();
         message.Text = "Done";
         StudentControl.Instance.CreateList();
         StudentControl.Instance.FooterMessage(count + " Records Added");
     }
 }
Beispiel #4
0
 private void saveimgbtn_Click(object sender, EventArgs e)
 {
     AspireDB db = new AspireDB();
     db.Configuration.ProxyCreationEnabled = false;
     List<Course> cour = db.Courses.ToList<Course>();
     String str = HelpMe.GetJson(cour);
     Console.Write(str);
     HelpMe.SaveFileNow(str, "courses");
 }
Beispiel #5
0
        public AddStudent()
        {
            InitializeComponent();
            db = new AspireDB();
            List <Course> cs = db.Courses.ToList <Course>();

            foreach (Course c in cs)
            {
                course_combo.Items.Add(c.Name + "-" + HelpMe.GetInitials(c.Level, ""));
            }
        }
Beispiel #6
0
        public void FilterBoxUpdate()
        {
            AspireDB      db = new AspireDB();
            List <Course> cs = db.Courses.ToList <Course>();

            filter_combo.Items.Add("All");
            foreach (Course c in cs)
            {
                filter_combo.Items.Add(c.Name + "-" + HelpMe.GetInitials(c.Level, ""));
            }
        }
Beispiel #7
0
        private void saveimgbtn_Click(object sender, EventArgs e)
        {
            AspireDB db = new AspireDB();

            db.Configuration.ProxyCreationEnabled = false;
            List <Subject> sub = db.Subjects.ToList <Subject>();

            // Create JSON String
            String str = HelpMe.GetJson(sub);

            // Save in file with extension
            HelpMe.SaveFileNow(str, "subject");
        }
Beispiel #8
0
        private void loadimgbtn_Click(object sender, EventArgs e)
        {
            // Opens File and match extension -> If Extension do not match it shows msg
            string json = HelpMe.OpenFileNow("courses");

            // Load Data from Json File Opened
            List <Course> css = HelpMe.GetDataFromJson <Course>(json);

            AspireDB db = new AspireDB();

            db.Courses.SqlQuery(" DBCC CHECKIDENT('Course', RESEED, 0)");
            int count = 0;

            foreach (Course s in css)
            {
                // Check for Exsisting Subjects
                if (db.Courses.Count(Course => Course.Name == s.Name && Course.Level == s.Level) <= 0)
                {
                    db.Courses.Add(s);
                    count++;
                }
            }

            string msg;

            try
            {
                db.SaveChanges();
                msg = "File Loaded ( " + count + " Rows Added )";
            }
            catch (Exception ee)
            {
                count = 0;
                msg   = "File Not Loaded";
                new MsgBox("Invalid File");
                MessageBox.Show(ee.Message);
            }
            //Update list and Show Footer Message
            CourseControl.Instance.CreateList();
            CourseControl.Instance.FooterMessage(msg);
        }
Beispiel #9
0
        private void loadimgbtn_Click(object sender, EventArgs e)
        {
            // Opens File and match extension -> If Extension do not match it shows msg
            string json = HelpMe.OpenFileNow("subject");

            // Load Data from Json File Opened
            List <Subject> sub = HelpMe.GetDataFromJson <Subject>(json);

            AspireDB db = new AspireDB();

            int count = 0;

            foreach (Subject s in sub)
            {
                // Check for Exsisting Subjects
                if (db.Subjects.Count(Subject => Subject.Name == s.Name && Subject.CourseID == s.CourseID) <= 0)
                {
                    db.Subjects.Add(s);
                    count++;
                }
            }

            string msg;

            try {
                db.SaveChanges();
                msg = "File Loaded ( " + count + " Rows Added )";
            }
            catch
            {
                count = 0;
                msg   = "File Not Loaded, Please Make Sure Courses Exsists";
                new MsgBox("Invalid File or Courses Missing!");
            }
            //Update list and Show Footer Message
            SubjectControl.Instance.CreateList();
            SubjectControl.Instance.FooterMessage(msg);
        }
Beispiel #10
0
        // Add student method
        private void addbtn_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                Student stud = new Student();
                stud.Name      = student_name.Text;
                stud.StudentID = student_studentID.Text;
                stud.Email     = student_email.Text;
                string   toparse = course_combo.Text;
                string[] strs = toparse.Split('-');
                string   cname = strs[0], clevel = HelpMe.GetFullForm(strs[1]);
                Course   fc = db.Courses.SingleOrDefault(Course => Course.Name == cname && Course.Level == clevel);
                stud.Course = fc;
                db.Students.Add(stud);
                db.SaveChanges();

                student_email.Text     = "";
                student_name.Text      = "";
                student_studentID.Text = "";
                StudentControl.Instance.CreateList();
                StudentControl.Instance.FooterMessage("Student Added");
            }
        }