Exemplo n.º 1
0
        public void createData()
        {
            using (var con = new SQLiteConnection(System.IO.Path.Combine(folder, "App.db")))
            {
                DBTerm      TermInsert       = new DBTerm();
                DBCourse    CourseInsert     = new DBCourse();
                DBAssesment AssesmentInsert1 = new DBAssesment();
                DBAssesment AssesmentInsert2 = new DBAssesment();

                var termCheck = con.Table <DBTerm>().Where(x => x.title == "Test Term").ToList();

                if (termCheck.Count == 0)
                {
                    TermInsert.title = "Test Term";
                    TermInsert.start = DateTime.Today.AddDays(7);
                    TermInsert.end   = DateTime.Today.AddDays(14);
                    InsertIntoTerm(TermInsert);

                    var relatedTermCheck = con.Table <DBTerm>().Where(x => x.title == "Test Term").ToList();

                    if (relatedTermCheck.Count == 1)
                    {
                        CourseInsert.coursetitle           = "Test Course";
                        CourseInsert.coursestartdate       = DateTime.Today.AddDays(7);
                        CourseInsert.courseenddate         = DateTime.Today.AddDays(14);
                        CourseInsert.instructorname        = "Austin Rukes";
                        CourseInsert.instructoremail       = "*****@*****.**";
                        CourseInsert.instructorphonenumber = "765-592-2466";
                        CourseInsert.termid = relatedTermCheck[0].termid;
                        CourseInsert.status = "Active";
                        InsertIntoCourse(CourseInsert);

                        var relatedCourseCheck = con.Table <DBCourse>().Where(x => x.coursetitle == "Test Course").ToList();

                        if (relatedCourseCheck.Count > 0)
                        {
                            AssesmentInsert1.assesmentname = "Test Course 1";
                            AssesmentInsert1.type          = "OA";
                            AssesmentInsert1.assesmentdate = DateTime.Today.AddDays(14);
                            AssesmentInsert1.courseid      = relatedCourseCheck[0].courseid;
                            AssesmentInsert2.assesmentname = "Test Course 2";
                            AssesmentInsert2.type          = "PA";
                            AssesmentInsert2.assesmentdate = DateTime.Today.AddDays(14);
                            AssesmentInsert2.courseid      = relatedCourseCheck[0].courseid;
                            InsertIntoAssesment(AssesmentInsert1);
                            InsertIntoAssesment(AssesmentInsert2);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public bool InsertIntoTerm(DBTerm term)
 {
     try
     {
         using (var con = new SQLiteConnection(System.IO.Path.Combine(folder, "App.db")))
         {
             con.Insert(term);
             return(true);
         }
     }
     catch (SQLiteException sqlex)
     {
         return(false);
     }
 }
Exemplo n.º 3
0
        public void AddTermNew(object sender, EventArgs arg)
        {
            if (termstart.Date <= termend.Date)
            {
                DBTerm term = new DBTerm();
                term.title = termtitle.Text;
                term.start = termstart.Date;
                term.end   = termend.Date;

                DataHelper dh = new DataHelper();
                dh.InsertIntoTerm(term);

                Navigation.PopModalAsync();
            }
            else
            {
                DisplayAlert("Alert!", "Make sure the start date is before the end date.", "Ok");
            }
        }
Exemplo n.º 4
0
 public EditTerm(DBTerm selectedTerm)
 {
     InitializeComponent();
     this.selectedTerm = selectedTerm;
 }