示例#1
0
        private void IkonicaButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog rezultat = new Microsoft.Win32.OpenFileDialog();

            rezultat.Filter = "Image Files(*.BMP;*.JPG;*PNG)|*.BMP;*.JPG;*PNG";


            if (rezultat.ShowDialog() == true)
            {
                foreach (Window w in Application.Current.Windows)
                {
                    if (w is Tutorial.Tutor)
                    {
                        Tutorial.Tutor tutor = w as Tutorial.Tutor;

                        if (tutor.slikaKorak == 1)
                        {
                            w.Activate();
                            tutor.IzborTipa1();
                        }
                    }
                }
                this.ikonica.Source = new BitmapImage(new Uri(rezultat.FileName));
                icon = new BitmapImage(new Uri(rezultat.FileName));
            }
        }
示例#2
0
        private void TipCombo_LostFocus(object sender, RoutedEventArgs e)
        {
            foreach (Window w in Application.Current.Windows)
            {
                if (w is Tutorial.Tutor)
                {
                    Tutorial.Tutor tutor = w as Tutorial.Tutor;

                    if (tutor.korak == 4)
                    {
                        w.Activate();
                        tutor.IzborDatuma();
                    }
                }
            }
        }
示例#3
0
        private void OznakaText_LostFocus(object sender, RoutedEventArgs e)
        {
            foreach (Window w in Application.Current.Windows)
            {
                if (w is Tutorial.Tutor)
                {
                    Tutorial.Tutor tutor = w as Tutorial.Tutor;

                    if (tutor.korak == 2)
                    {
                        w.Activate();
                        tutor.UnosNaziva();
                    }
                }
            }
        }
示例#4
0
        public void NazivTuto()
        {
            foreach (Window w in Application.Current.Windows)
            {
                if (w is Tutorial.Tutor)
                {
                    Tutorial.Tutor tutor = w as Tutorial.Tutor;

                    if (tutor.korak == 3)
                    {
                        w.Activate();
                        tutor.IzborTipa();
                    }
                }
            }
        }
示例#5
0
        public void oznakaTuto()
        {
            foreach (Window w in Application.Current.Windows)
            {
                if (w is Tutorial.Tutor)
                {
                    Tutorial.Tutor tutor = w as Tutorial.Tutor;

                    if (tutor.korak == 2)
                    {
                        w.Activate();
                        tutor.UnosNaziva();
                    }
                }
            }
        }
示例#6
0
        private void Datum_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (Window w in Application.Current.Windows)
            {
                if (w is Tutorial.Tutor)
                {
                    Tutorial.Tutor tutor = w as Tutorial.Tutor;

                    if (tutor.korak == 5)
                    {
                        w.Activate();
                        tutor.KlikniDugme();
                    }
                }
            }
        }
示例#7
0
        private void OkBtn_Click(object sender, RoutedEventArgs e)
        {
            Close();

            foreach (Window w in Application.Current.Windows)
            {
                if (w is Tutorial.Tutor)
                {
                    Tutorial.Tutor tutor = w as Tutorial.Tutor;

                    if (tutor.korak == 7)
                    {
                        tutor.Close();
                    }
                }
            }
        }
示例#8
0
        private void TipCombo_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Tab)
            {
                foreach (Window w in Application.Current.Windows)
                {
                    if (w is Tutorial.Tutor)
                    {
                        Tutorial.Tutor tutor = w as Tutorial.Tutor;

                        if (tutor.korak == 4)
                        {
                            w.Activate();
                            tutor.IzborDatuma();
                        }
                    }
                }
            }
        }
示例#9
0
        private void DodajButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.OznakaText.Text.Equals(""))
            {
                MessageBox.Show("Polje Oznaka ne sme biti prazno", "Greška");
            }
            else if (this.NazivText.Text.Equals(""))
            {
                MessageBox.Show("Polje Naziv ne sme biti prazno", "Greška");
            }
            else if (TipCombo.Text.Equals(""))
            {
                MessageBox.Show("Morate izabrati tip spomenika", "Greška");
            }
            else
            {
                SQLiteConnection sqliteCon = new SQLiteConnection(dbConn);

                string[] split = this.TipCombo.Text.Split('-');
                string   ozn   = "";
                foreach (char c in split[0])
                {
                    if (!c.Equals(' '))
                    {
                        ozn += c;
                    }
                }



                try
                {
                    sqliteCon.Open();
                    string        query1   = "select * from tip where oznaka=@ozn1";
                    SQLiteCommand command1 = new SQLiteCommand(query1, sqliteCon);
                    command1.Parameters.AddWithValue("@ozn1", ozn);
                    command1.ExecuteNonQuery();
                    SQLiteDataReader dr = command1.ExecuteReader();

                    int oznaka = 0;
                    while (dr.Read())
                    {
                        oznaka++;
                    }

                    if (oznaka < 1)
                    {
                        MessageBox.Show("Uneti tip ne postoji");
                        return;
                    }


                    sqliteCon.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }



                foreach (var item in ListaEtikete.SelectedItems)
                {
                    sqliteCon.Open();
                    string        etike     = "insert into spomEtiketa (OznakaSpom,OznakaEtiketa) values (@ozn,'" + item.ToString() + "')";
                    SQLiteCommand etikeComm = new SQLiteCommand(etike, sqliteCon);
                    etikeComm.Parameters.AddWithValue("@ozn", this.OznakaText.Text);
                    etikeComm.ExecuteNonQuery();
                    sqliteCon.Close();
                }

                try
                {
                    string eugrozen = "false";
                    if (eUgrozen.IsChecked.Equals(true))
                    {
                        eugrozen = "true";
                    }

                    string suvrsta = "false";
                    if (uVrste.IsChecked.Equals(true))
                    {
                        suvrsta = "true";
                    }
                    string nasregion = "false";
                    if (nasRegion.IsChecked.Equals(true))
                    {
                        nasregion = "true";
                    }
                    //string[] split = this.TipCombo.SelectionBoxItem.ToString().Split('-');
                    //string ozn = "";
                    //foreach (char c in split[0])
                    //{
                    //    if (!c.Equals(' '))
                    //    {
                    //        ozn += c;
                    //    }
                    //}

                    if (icon == null)
                    {
                        try
                        {
                            sqliteCon.Open();
                            string        queryikona   = "select * from tip where oznaka=@ozn1";
                            SQLiteCommand commandikona = new SQLiteCommand(queryikona, sqliteCon);
                            commandikona.Parameters.AddWithValue("@ozn1", ozn);
                            commandikona.ExecuteNonQuery();
                            string           iconaa = "";
                            SQLiteDataReader dr     = commandikona.ExecuteReader();
                            while (dr.Read())
                            {
                                iconaa = dr.GetString(3);
                            }
                            sqliteCon.Close();
                            icon = new BitmapImage(new Uri(iconaa));
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }


                    sqliteCon.Open();
                    string datum = Datum.SelectedDate.Value.Month.ToString() + "." + Datum.SelectedDate.Value.Day.ToString() + "." + Datum.SelectedDate.Value.Year.ToString() + ".";
                    //TODO 1: INSERT INTO OZNAKATAG PROMENI SA NECIM
                    string        query   = "insert into spomenik (oznaka,naziv,opis,klima,tstatus,eugrozen,suvrsta,nasregion,prihod,oznakaTip,oznakaTag,icon,datum) values (@oznaka,@naziv,@opis,'" + KlimaDropdown.SelectionBoxItem.ToString() + "','" + TstatusDropdown.SelectionBoxItem.ToString() + "','" + eugrozen + "','" + suvrsta + "','" + nasregion + "',@prihod,@oznTip,'" + "Etiketa" + "',@icon,@datum)";
                    SQLiteCommand command = new SQLiteCommand(query, sqliteCon);
                    command.Parameters.AddWithValue("@oznaka", this.OznakaText.Text);
                    command.Parameters.AddWithValue("@naziv", this.NazivText.Text);
                    command.Parameters.AddWithValue("@opis", this.OpisText.Text);
                    command.Parameters.AddWithValue("@prihod", this.prihod.Text);
                    command.Parameters.AddWithValue("@oznTip", ozn);
                    command.Parameters.AddWithValue("@icon", icon);
                    command.Parameters.AddWithValue("@datum", datum);
                    command.ExecuteNonQuery();
                    sqliteCon.Close();
                    sqliteCon.Open();

                    string        query1   = "insert into zaDodavanje (oznaka,naziv,ikonica) values (@ozne,@nazive,@iconi)";
                    SQLiteCommand command1 = new SQLiteCommand(query1, sqliteCon);
                    command1.Parameters.AddWithValue("@ozne", this.OznakaText.Text);
                    command1.Parameters.AddWithValue("@nazive", this.NazivText.Text);
                    command1.Parameters.AddWithValue("@iconi", icon);

                    command1.ExecuteNonQuery();
                    sqliteCon.Close();


                    MainWindow mw = (MainWindow)Application.Current.MainWindow;
                    //mw.popuniListu();
                    mw.list.Add(new Model.Lista {
                        Ikonica = icon.ToString(), Naziv = NazivText.Text, Onaka = OznakaText.Text
                    });
                    mw.Listaspom.Add(new Model.Lista {
                        Ikonica = icon.ToString(), Naziv = NazivText.Text, Onaka = OznakaText.Text
                    });


                    var hehe = new Tutorial.Dodato();
                    hehe.Show();

                    foreach (Window w in Application.Current.Windows)
                    {
                        if (w is Tutorial.Tutor)
                        {
                            w.Activate();
                            Tutorial.Tutor tutor = w as Tutorial.Tutor;
                            tutor.uspeh();
                        }
                    }



                    Close();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                    if (ex.Message.Contains("UNIQUE"))
                    {
                        MessageBox.Show("Oznaka vec postoji!");
                    }
                    else if (ex.Message.Contains("Nullable object"))
                    {
                        MessageBox.Show("Morate uneti datum");
                    }
                    else
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }