Exemple #1
0
        private void ScheduleLoad(int uID)
        {
            try
            {
                schedule.clearTable();

                DBA db = DBA.Instance;
                db.connect();
                var con = db.getConnection();
                con.Open();

                string query = "SELECT  * FROM schedule WHERE user_id = " + uID;
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    using (SqlDataReader r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            int    cID   = r.GetInt32(2);
                            string day   = r.GetString(4);
                            string title = r.GetString(3) + " " + r.GetString(8);
                            string start = r.GetInt32(5).ToString() + ":00";
                            string end   = r.GetInt32(6).ToString() + ":00";

                            ScheduleEvent block = new ScheduleEvent(r.GetInt32(1), r.GetInt32(2), r.GetString(3), r.GetString(4), r.GetInt32(5), r.GetInt32(6), r.GetInt32(7), r.GetString(8));
                            dictSchedule[uID][cID] = block;

                            schedule.buildEvent(day, title, start, end, schedule_color);
                        }
                    }
                }

                scheduleView.DocumentText = schedule.fill();
            }

            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        public async void ScheduleLoad(int uID)
        {
            try
            {
                timeTable scheduleObj = new timeTable();
                webBrowser1.DocumentText = scheduleObj.clearTable();

                DBA db = DBA.Instance;
                db.connect();
                var con = db.getConnection();
                con.Open();

                string query = "SELECT  * FROM schedule WHERE id IN(SELECT l_id FROM studentSchedule WHERE user_id = " + uID + " )";
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    using (SqlDataReader r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            int    cID   = r.GetInt32(2);
                            string day   = r.GetString(4);
                            string title = r.GetString(3) + " " + r.GetString(8);
                            string start = r.GetInt32(5).ToString() + ":00";
                            string end   = r.GetInt32(6).ToString() + ":00";

                            scheduleObj.buildEvent(day, title, start, end, "lightgreen");
                        }
                    }
                }

                await Task.Delay(1000);

                webBrowser1.DocumentText = scheduleObj.fill();
            }

            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        public void load_prefers(int uID)
        {
            try
            {
                listPrefers = new List <Prefers>();
                prefers.clearTable();
                //int tmpHour = 0;
                string[] tmp_;
                DBA      db = DBA.Instance;
                db.connect();

                db.getConnection().Open();

                using (var command = new SqlCommand("SELECT * FROM prefers WHERE id_user = "******"Sun", "Morning", tmp_[0] + ":00", tmp_[1] + ":00", prefers_color);
                            prefers.buildEvent("Sun", "Evening", tmp_[2] + ":00", tmp_[3] + ":00", prefers_color);

                            listPrefers.Add(new Prefers("Sun", strToInt(tmp_[0]), strToInt(tmp_[1])));
                            listPrefers.Add(new Prefers("Sun", strToInt(tmp_[2]), strToInt(tmp_[3])));

                            // monday
                            tmp_ = r.GetString(3).Split(',');
                            prefers.buildEvent("Mon", "Morning", tmp_[0] + ":00", tmp_[1] + ":00", prefers_color);
                            prefers.buildEvent("Mon", "Evening", tmp_[2] + ":00", tmp_[3] + ":00", prefers_color);

                            listPrefers.Add(new Prefers("Mon", strToInt(tmp_[0]), strToInt(tmp_[1])));
                            listPrefers.Add(new Prefers("Mon", strToInt(tmp_[2]), strToInt(tmp_[3])));

                            // tuesday
                            tmp_ = r.GetString(4).Split(',');
                            prefers.buildEvent("Tue", "Morning", tmp_[0] + ":00", tmp_[1] + ":00", prefers_color);
                            prefers.buildEvent("Tue", "Evening", tmp_[2] + ":00", tmp_[3] + ":00", prefers_color);

                            listPrefers.Add(new Prefers("Tue", strToInt(tmp_[0]), strToInt(tmp_[1])));
                            listPrefers.Add(new Prefers("Tue", strToInt(tmp_[2]), strToInt(tmp_[3])));

                            // wednesday
                            tmp_ = r.GetString(5).Split(',');
                            prefers.buildEvent("Wed", "Morning", tmp_[0] + ":00", tmp_[1] + ":00", prefers_color);
                            prefers.buildEvent("Wed", "Evening", tmp_[2] + ":00", tmp_[3] + ":00", prefers_color);

                            listPrefers.Add(new Prefers("Wed", strToInt(tmp_[0]), strToInt(tmp_[1])));
                            listPrefers.Add(new Prefers("Wed", strToInt(tmp_[2]), strToInt(tmp_[3])));


                            // thusday
                            tmp_ = r.GetString(6).Split(',');
                            prefers.buildEvent("Thu", "Morning", tmp_[0] + ":00", tmp_[1] + ":00", prefers_color);
                            prefers.buildEvent("Thu", "Evening", tmp_[2] + ":00", tmp_[3] + ":00", prefers_color);

                            listPrefers.Add(new Prefers("Thu", strToInt(tmp_[0]), strToInt(tmp_[1])));
                            listPrefers.Add(new Prefers("Thu", strToInt(tmp_[2]), strToInt(tmp_[3])));


                            // friday
                            tmp_ = r.GetString(7).Split(',');
                            prefers.buildEvent("Fri", "Morning", tmp_[0] + ":00", tmp_[1] + ":00", prefers_color);

                            listPrefers.Add(new Prefers("Fri", strToInt(tmp_[0]), strToInt(tmp_[1])));
                        }
                    }
                }
                userPrefers.DocumentText = prefers.fill();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "SQL Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }