예제 #1
0
        public override void OnDialogOpened(IDialogParameters parameters)
        {
            ListaOrganizatora = parameters.GetValue <ObservableCollection <OrganizatorModel> >("listaOrganizatora");
            ID_Organizatora   = parameters.GetValue <int>("idOrganizator");

            Organizator = new OrganizatorModel()
            {
                ID_Organizator = ID_Organizatora
            };
            UcitajOrganizatora(ID_Organizatora);
        }
예제 #2
0
        private void UcitajOrganizatora(int ID)
        {
            if (ID == -1)
            {
                return;
            }

            using (var con = new SQLiteConnection(SQLPostavke.ConnectionStr))
            {
                con.Open();

                var selectSQL = new SQLiteCommand(@"SELECT * FROM Organizator WHERE ID_organizator=@Id", con);
                selectSQL.Parameters.AddWithValue("@Id", ID);

                try
                {
                    var reader = selectSQL.ExecuteReader();

                    if (!reader.HasRows)
                    {
                        return;
                    }

                    reader.Read();

                    Organizator = new OrganizatorModel()
                    {
                        ID_Organizator = ID,
                        Naziv          = reader["NazivOrganizatora"].ToString(),
                        Drzava         = reader["Drzava"].ToString(),
                        Osnovan        = reader["Osnovan"].ToString(),
                    };
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Neuspješno čitanje organizatora iz baze, greška: {ex.Message}");
                }

                con.Close();
            }
        }