Beispiel #1
0
        public static List <Dogadaj> DohavtiSvePrioritet()
        {
            BP.otvoriKonekciju();

            List <Dogadaj> listaDogadaja = new List <Dogadaj>();

            SqliteCommand command = BP.konekcija.CreateCommand();

            command.CommandText = "Select * from dogadaj order by prioritet desc";

            SqliteDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Dogadaj temp = new Dogadaj();

                temp.Id        = (int)(Int64)reader["id"];
                temp.Datum     = DateTime.FromFileTime(reader.GetInt64(1));
                temp.Opis      = (string)reader["opis"];
                temp.Vrijeme   = (string)reader["vrijeme"];
                temp.Mjesto    = (string)reader["mjesto"];
                temp.Prioritet = (string)reader["prioritet"];

                listaDogadaja.Add(temp);
            }

            reader.Dispose();
            command.Dispose();

            BP.zatvoriKonekciju();

            return(listaDogadaja);
        }
Beispiel #2
0
        protected string provjeraDatum(Dogadaj d)
        {
            int satiD   = int.Parse(d.Vrijeme.Substring(0, 2));
            int minuteD = int.Parse(d.Vrijeme.Substring(3, 2));

            foreach (var i in listaDogadaja)
            {
                if (d.Id == i.Id)
                {
                    continue;
                }

                int sati   = int.Parse(i.Vrijeme.Substring(0, 2));
                int minute = int.Parse(i.Vrijeme.Substring(3, 2));

                DateTime jedan = new DateTime(i.Datum.Year, i.Datum.Month, i.Datum.Day, sati, minute, 0);
                DateTime dva   = new DateTime(d.Datum.Year, d.Datum.Month, d.Datum.Day, satiD, minuteD, 0);

                if (Math.Abs((jedan - dva).TotalHours) <= 1)
                {
                    return("red");
                }
            }
            return(null);
        }
Beispiel #3
0
        public UnosDogadaja(Dogadaj dogadaj) :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();

            temp = dogadaj;

            buttonSpremi.Clicked   += spremi;
            buttonOdustani.Clicked += odustani;


            if (temp.Id != -1)
            {
                this.Title        = "Izmjena dogadaja";
                calendar4.Date    = temp.Datum;
                entryOpis.Text    = temp.Opis;
                entryMjesto.Text  = temp.Mjesto;
                entryVrijeme.Text = temp.Vrijeme;

                switch (temp.Prioritet)
                {
                case "Nizak":
                    combobox1.Active = 2;
                    break;

                case "Obican":
                    combobox1.Active = 1;
                    break;

                case "Visok":
                    combobox1.Active = 0;
                    break;
                }
            }
        }
Beispiel #4
0
        public DogadajNode(Dogadaj d, string color)
        {
            this.id = d.Id;

            this.datum     = d.Datum.ToString().Substring(0, d.Datum.ToString().Length - 8);
            this.opis      = d.Opis;
            this.vrijeme   = d.Vrijeme;
            this.mjesto    = d.Mjesto;
            this.prioritet = d.Prioritet;
            this.color     = color;
        }
Beispiel #5
0
        public static void SpremiDogadaj(Dogadaj d)
        {
            BP.otvoriKonekciju();

            SqliteCommand command = BP.konekcija.CreateCommand();

            command.CommandText = String.Format(@"Insert into dogadaj (datum, opis, vrijeme, mjesto, prioritet)
			Values ('{0}', '{1}', '{2}', '{3}', '{4}')"            , d.Datum.ToFileTime(), d.Opis, d.Vrijeme, d.Mjesto, d.Prioritet);

            command.ExecuteNonQuery();

            command.Dispose();

            BP.zatvoriKonekciju();
        }
Beispiel #6
0
        public static void IzmjeniDogadaj(Dogadaj d)
        {
            BP.otvoriKonekciju();

            SqliteCommand command = BP.konekcija.CreateCommand();

            command.CommandText = String.Format(@"Update dogadaj
			set datum = '{0}', opis = '{1}', vrijeme = '{2}', mjesto = '{3}', prioritet = '{4}'
			where id = '{5}'"            , d.Datum.ToFileTime(), d.Opis, d.Vrijeme, d.Mjesto, d.Prioritet, d.Id);

            command.ExecuteNonQuery();

            command.Dispose();

            BP.zatvoriKonekciju();
        }
Beispiel #7
0
        public void dodajDogadaj(Dogadaj d, string color)
        {
            DogadajNode temp = new DogadajNode(d, color);

            this.AddNode(temp);
        }