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!"); }
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); } }
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(); }
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(); }
private static void TestJsonDatabase() { JsonDatabase db = new JsonDatabase(@"C:\tmp"); db.OutputIndent = true; Cat origin = new Cat() { Name = "Garfield", Legs = 4 }; db.Save<Cat>(origin); db.Save<Cat>(origin.Id, origin); db.Delete<Cat>(origin.Id); }
/// <summary> /// Usuwa osobe z listy po numerze indeksu /// </summary> /// <param name="id">W funkcji deletePerson param id zostanie zinkrementowany</param> public void DeletePerson(int id) { id--; this.People.RemoveAt(id); // zaktualizowanie listy w pliku json //pobranie na danych z nowym userem z pliku var db = new JsonDatabase(); db.UpdateDatabase(People); this.People = db.GetData(); }
private void Acoes_Load(object sender, EventArgs e) { efeitos = new List <Efeito>(); Database = new JsonDatabase(); cod = ""; List <Fator> fatores = Globals.GetFatores(); foreach (Fator item in fatores) { cbFator.Items.Add(item.Nome); comboBox1.Items.Add(item.Nome); } }
private Indice LoadIndices() { Database = Database.ReadJson(); List <Indice> indices = Database.indices; Indice n; using (SearchForm s = new SearchForm()) { s.CreateTable(indices, typeof(Indice)); s.ShowDialog(); n = Globals.GetIndice(s.ID); } return(n); }
private Noticia LoadNoticias() { Database = Database.ReadJson(); List <Noticia> noticias = Database.noticias; Noticia n; using (SearchForm s = new SearchForm()) { s.CreateTable(noticias, typeof(Noticia)); s.ShowDialog(); n = Globals.GetNoticia(s.ID); } return(n); }
private Noticia LoadNoticias() { Database = Database.ReadJson(); List <Noticia> noticias = Database.noticias.Where(not => not.Cod_noticia.Contains(textBox2.Text) || not.Manchete.Contains(textBox2.Text) || not.Descrição.Contains(textBox2.Text)).ToList(); Noticia n; using (SearchForm s = new SearchForm()) { s.CreateTable(noticias, typeof(Noticia)); s.ShowDialog(); n = Globals.GetNoticia(s.ID); } return(n); }
private static void TestJsonDatabase() { JsonDatabase db = new JsonDatabase(@"C:\tmp"); db.OutputIndent = true; Cat origin = new Cat() { Name = "Garfield", Legs = 4 }; db.Save <Cat>(origin); db.Save <Cat>(origin.Id, origin); db.Delete <Cat>(origin.Id); }
private void LoadEventosTable() { Database = Database.ReadJson(); List <Evento> eventos = Database.eventos.Where(e => e.Cod_Evento.Contains(txtCod.Text) || e.Titulo.Contains(txtCod.Text) || e.Descricao.Contains(txtCod.Text)).ToList(); using (SearchForm s = new SearchForm()){ s.CreateTable(eventos, typeof(Evento)); s.ShowDialog(); cod = s.ID; } if (cod != "") { selectedEvento = Globals.GetEvento(cod); } }
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); } }
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); } }
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); } }
static void Main(string[] prefixes) //Uniform resource Identifer (URI) prefixes { var logger = Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .WriteTo.File(Path.Combine(Directory.GetCurrentDirectory(), "Logs", "log.txt"), rollingInterval: RollingInterval.Day) .CreateLogger(); var database = new JsonDatabase(Path.Combine(Directory.GetCurrentDirectory(), "DataAccess", "Users.json")); var dataManager = new DataManager(database); var server = new Server(logger, dataManager); server.StartServer(); Log.CloseAndFlush(); }
//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); } }
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); } }
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(); }
/// <summary> /// Pobiera argumenty z ktorych tworzy obiekt Person /// </summary> /// <returns>Zwraca obiekt Person gotowny do dodania do serializacji</returns> public void CreateNewPerson(string login, string pass, string name, string surname, string pesel, int position = 0, int specialization = 0) { var newPerson = new Person { Login = login, Haslo = pass, Imie = name, Nazwisko = surname, Pesel = pesel, Posada = (Professions)position, Specjalizacja = (Specializations)specialization }; this.People.Add(newPerson); // zaktualizowanie listy w pliku json //pobranie na danych z nowym userem z pliku var db = new JsonDatabase(); db.UpdateDatabase(People); this.People = db.GetData(); }
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(); }
private void Indices_Load(object sender, EventArgs e) { Database = new JsonDatabase(); }
private void LoadFatores(object sender, EventArgs e) { Database = new JsonDatabase(); cod = ""; }
public override void OnStartup() { _database = new JsonDatabase(GetPathForFile("Bans.json"), JsonDatabase.DatabaseSaveOptions.Automatic); }
public Manage() { var db = new JsonDatabase(); this.People = db.GetData(); }
private void LoadNotifications(object sender, EventArgs e) { Database = new JsonDatabase(); cod = ""; }