コード例 #1
0
        public void Addschedule(bool bf, string pp, bool ga, DateTime arrivaldate, TimeSpan schedule_datecoming, TimeSpan schedule_dateleaving, Child c)
        {
            schedule s = new schedule();

            s.breakfast            = bf;
            s.pick_up              = pp;
            s.goalone              = ga;
            s.arrivaldate          = arrivaldate;
            s.schedule_datecoming  = schedule_datecoming;
            s.schedule_dateleaving = schedule_dateleaving;



            string stmt = "INSERT INTO schedule(breakfast, pick_up, goalone, child_id, arrivaldate, schedule_datecoming, schedule_dateleaving) VALUES (@bf, @pp, @ga, @child_id, @arrivaldate, @schedule_datecoming, @schedule_dateleaving)";

            using (var conn = new
                              NpgsqlConnection(ConfigurationManager.ConnectionStrings["Dbconn"].ConnectionString))
            {
                conn.Open();
                using (var cmd = new NpgsqlCommand(stmt, conn))
                {
                    cmd.Parameters.AddWithValue("bf", bf);
                    cmd.Parameters.AddWithValue("pp", pp);
                    cmd.Parameters.AddWithValue("ga", ga);
                    cmd.Parameters.AddWithValue("child_id", c.child_id);
                    cmd.Parameters.AddWithValue("arrivaldate", arrivaldate);
                    cmd.Parameters.AddWithValue("schedule_datecoming", schedule_datecoming);
                    cmd.Parameters.AddWithValue("schedule_dateleaving", schedule_dateleaving);
                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #2
0
        public bool breakfast()
        {
            schedule schedule = new schedule();

            if (checkfrukost.IsChecked == true)
            {
                schedule.breakfast = true;
            }
            else
            {
                schedule.breakfast = false;
            }
            return(schedule.breakfast);
        }
コード例 #3
0
        public List <schedule> GetSchedules(Child child)
        {
            schedule        s;
            List <schedule> schedules = new List <schedule>();

            using (var conn = new
                              NpgsqlConnection(ConfigurationManager.ConnectionStrings["Dbconn"].ConnectionString))
            {
                conn.Open();
                using (var cmd = new NpgsqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandText = "SELECT schedule.schedule_id, schedule.breakfast, schedule.sickleave, schedule.pick_up, schedule.goalone, schedule.child_id, schedule.leave, schedule.weekday, schedule.schedule_datecoming, schedule.schedule_dateleaving, arrivaldate FROM schedule JOIN child ON child.child_id = schedule.child_id  WHERE child.child_id = @child.child_id ORDER BY arrivaldate ASC";
                    cmd.Parameters.AddWithValue("child.child_id", child.child_id);
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            s             = new schedule();
                            s.schedule_id = reader.GetInt32(0);
                            s.breakfast   = reader.GetBoolean(1);
                            if ((!reader.IsDBNull(2)))
                            {
                                s.sickleave = reader.GetDateTime(2);
                            }
                            s.pick_up  = reader.GetString(3);
                            s.goalone  = reader.GetBoolean(4);
                            s.child_id = reader.GetInt32(5);
                            if ((!reader.IsDBNull(6)))
                            {
                                s.leave = reader.GetDateTime(6);
                            }
                            if ((!reader.IsDBNull(7)))
                            {
                                s.weekday = reader.GetString(7);
                            }
                            s.schedule_datecoming  = reader.GetTimeSpan(8);
                            s.schedule_dateleaving = reader.GetTimeSpan(9);
                            if ((!reader.IsDBNull(10)))
                            {
                                s.arrivaldate = reader.GetDateTime(10);
                            }

                            schedules.Add(s);
                        }
                    }
                }
                return(schedules);
            }
        }
コード例 #4
0
        public bool checkhemsjalv()
        {
            schedule schedule = new schedule();

            if (checkhemsjälv.IsChecked == true)
            {
                schedule.goalone = true;
                txt_pickup.Text  = "Själv";
            }
            else
            {
                schedule.goalone = false;
            }
            return(schedule.goalone);
        }
コード例 #5
0
        public void addLeave(Child c, DateTime leave)
        {
            schedule s = new schedule();

            s.leave = leave;

            string stmt = "INSERT INTO schedule(child_id, leave) VALUES (@child_id, @leave)";


            using (var conn = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["Dbconn"].ConnectionString))
            {
                conn.Open();
                using (var cmd = new NpgsqlCommand(stmt, conn))
                {
                    cmd.Parameters.AddWithValue("child_id", c.child_id);
                    cmd.Parameters.AddWithValue("leave", leave);
                    cmd.ExecuteNonQuery();
                }
            }
        }