示例#1
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();
        }
示例#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);
            }
        }
示例#3
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!");
        }
示例#4
0
        private void salvar_Click(object sender, EventArgs e)
        {
            Database = Database.ReadJson();
            Noticia noticia = new Noticia();

            noticia.Cod_noticia = txtCod.Text;
            noticia.Fonte       = txtFonte.Text;
            noticia.Manchete    = txtManchete.Text;
            noticia.Descrição   = txtDescricao.Text;

            foreach (string n in listIndices.Items)
            {
                noticia.Indices.Add(Globals.GetIndice(n));
            }

            List <Noticia> noticias = Database.noticias;

            noticias.Remove(noticias.Where(i => i.Cod_noticia == cod).FirstOrDefault());
            noticias.Add(noticia);
            Database.noticias = noticias;
            Database.WriteJson(Database);

            MessageBox.Show("Salvo com sucesso!");
            ClearFields();
        }
示例#5
0
        private void button3_Click(object sender, EventArgs e)
        {
            Database = Database.ReadJson();
            Açao açao = new Açao();

            açao.Cod_Acao        = txtCod.Text;
            açao.Titulo          = txtTitulo.Text;
            açao.Descricao       = txtDesc.Text;
            açao.Custo           = int.Parse(txtCusto.Text);
            açao.FatorCusto      = Globals.GetFator(cbFator.Text);
            açao.IsCustoVariavel = chkVariavel.Checked;

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

            açao.Efeitos = efeitos;


            if (cod != "" && cod != null)
            {
                List <Açao> acoes = Database.açoes;
                acoes.Remove(acoes.Where(i => i.Cod_Acao == cod).FirstOrDefault());
                acoes.Add(açao);
                Database.açoes = acoes;
                Database.WriteJson(Database);
            }
            else
            {
                Database.açoes.Add(açao);
                Database.WriteJson(Database);
            }

            MessageBox.Show("Salvo com sucesso!");
            ClearFields();
        }
示例#6
0
        private void botaoSalvar(object sender, EventArgs e)
        {
            Database = Database.ReadJson();
            Fator fator = new Fator();

            fator.Nome = txtCod.Text;
            //todo mudar se converter os valores
            fator.ValorMax = int.Parse(textBox1.Text);

            List <Fator> fatores = Database.fatores;

            fatores.Remove(fatores.Where(f => f.Nome == cod).FirstOrDefault());
            fatores.Add(fator);
            Database.fatores = fatores;
            Database.WriteJson(Database);

            MessageBox.Show("Salvo com sucesso!");
            ClearFields();
        }