Exemplo n.º 1
0
        private void botaoSalvar(object sender, EventArgs e)
        {
            Database = Database.ReadJson();
            Evento evento = new Evento();

            evento.Cod_Evento       = txtCod.Text;
            evento.Descricao        = txtDesc.Text;
            evento.Probab_Acontecer = decimal.Parse(textBox2.Text);
            evento.Titulo           = txtTitulo.Text;
            evento.Noticias         = new List <Noticia>();

            foreach (string n in listBoxNoticia.Items)
            {
                evento.Noticias.Add(Globals.GetNoticia(n));
            }

            evento.Efeitos = efeitos;

            List <Evento> eventos = Database.eventos;

            eventos.Remove(eventos.Where(ed => ed.Cod_Evento == cod).FirstOrDefault());
            eventos.Add(evento);
            Database.eventos = eventos;
            Database.WriteJson(Database);

            MessageBox.Show("Salvo com sucesso!");
        }
Exemplo n.º 2
0
        private void button8_Click(object sender, EventArgs e)
        {
            JsonDatabase   jh         = new JsonDatabase();
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Filter           = "Arquivo Json (*.json)| *.json";
            saveDialog.FilterIndex      = 1;
            saveDialog.RestoreDirectory = true;
            JsonDatabase jd;

            if (File.Exists(Globals.FilePath + Globals.FileName))
            {
                jd = jh.ReadJson();
            }
            else
            {
                jd = new JsonDatabase();
            }

            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                FileInfo newFile     = new FileInfo(saveDialog.FileName);
                var      configFile  = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                var      appSettings = ConfigurationManager.AppSettings;

                configFile.AppSettings.Settings["FILEPATH"].Value = newFile.DirectoryName;
                configFile.AppSettings.Settings["FILENAME"].Value = newFile.Name;

                configFile.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");
                jh.WriteJson(jd);
            }
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            Database = Database.ReadJson();

            Indice indice = new Indice();

            indice.Cod_Indice = txtCod.Text;
            indice.Metodo     = txtMetodo.Text;
            indice.Indices.Clear();

            foreach (string ind in listBoxIndices.Items)
            {
                indice.Indices.Add(Globals.GetIndice(ind));
            }

            if (cod != "" && cod != null)
            {
                List <Indice> inds = Database.indices;
                inds.Remove(inds.Where(i => i.Cod_Indice == cod).FirstOrDefault());
                inds.Add(indice);
                Database.indices = inds;
                Database.WriteJson(Database);
            }
            else
            {
                Database.indices.Add(indice);
                Database.WriteJson(Database);
            }

            MessageBox.Show("Salvo com sucesso!");
            ClearFields();
        }
Exemplo n.º 4
0
        private void LoadAçao()
        {
            Database = Database.ReadJson();
            List <Açao> acoes = Database.açoes;

            using (SearchForm s = new SearchForm())
            {
                s.CreateTable(acoes, typeof(Açao));
                s.ShowDialog();
                cod = s.ID;
            }

            if (cod != "")
            {
                selectedAcao = Globals.GetAçao(cod);
            }
        }
Exemplo n.º 5
0
        private void LoadFatoresTable()
        {
            Database = Database.ReadJson();
            List <Fator> fatores = Database.fatores;

            using (SearchForm s = new SearchForm())
            {
                s.CreateTable(fatores, typeof(Fator));
                s.ShowDialog();
                cod = s.ID;
            }

            if (cod != "")
            {
                selectedFator = Globals.GetFator(cod);
            }
        }
Exemplo n.º 6
0
        //Carrega todas as Ações no botão de pesquisa
        private void LoadAçao()
        {
            Database = Database.ReadJson();
            List <Açao> acoes = Database.açoes.Where(ac => ac.Cod_Acao.Contains(txtCod.Text) || ac.Titulo.Contains(txtCod.Text) || ac.Descricao.Contains(txtCod.Text)).ToList();

            using (SearchForm s = new SearchForm())
            {
                s.CreateTable(acoes, typeof(Açao));
                s.ShowDialog();
                cod = s.ID;
            }

            if (cod != "")
            {
                selectedAcao = Globals.GetAçao(cod);
            }
        }
Exemplo n.º 7
0
        private void LoadNoticias()
        {
            Database = Database.ReadJson();
            List <Noticia> noticias = Database.noticias.Where(not => not.Cod_noticia.Contains(txtCod.Text) || not.Descrição.Contains(txtCod.Text) || not.Manchete.Contains(txtCod.Text)).ToList();

            using (SearchForm s = new SearchForm())
            {
                s.CreateTable(noticias, typeof(Noticia));
                s.ShowDialog();
                cod = s.ID;
            }

            if (cod != "")
            {
                selectedNoticia = Globals.GetNoticia(cod);
            }
        }
Exemplo n.º 8
0
        private void LoadIndices()
        {
            Database    = new JsonDatabase();
            Database    = Database.ReadJson();
            indicesList = Database.indices;
            using (SearchForm s = new SearchForm())
            {
                s.CreateTable(indicesList, typeof(Indice));
                s.ShowDialog();
                cod = s.ID;
            }

            if (cod != "")
            {
                selectedIndice = Globals.GetIndice(cod);
            }
        }