Exemple #1
0
 public static void Registro(string texto)
 {
     try
     {
         int index;
         int preferencia;
         using (var tipoContext = new TErrosContext(_DB))
         {
             var tipo = tipoContext.TiposErro.Where(s => s.Nome == texto).FirstOrDefault();
             index       = tipo.Id;
             preferencia = tipo.Prioridade;
         }
         using (var regContext = new RegistroContext(_DB))
         {
             regContext.Registros.Add(new Registro(Labname, Computername, Ip, index, idGrupo, preferencia));
             regContext.SaveChanges();
             MessageBox.Show("Realizado com sucesso!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemple #2
0
 private void btnCadastro_Click(object sender, EventArgs e)
 {
     try
     {
         int idTipo;
         using (var tipoContext = new TErrosContext(_DB))
         {
             var index = comboBoxTipos.SelectedItem.ToString().IndexOf("Nome:") + 6;
             var tipo  = comboBoxTipos.SelectedItem.ToString().Substring(index);
             idTipo = tipoContext.TiposErro.Where(s => s.Nome == tipo).FirstOrDefault().Id;
         }
         using (var grupoContext = new GErrosContext(_DB))
         {
             int idGrupo = Convert.ToInt32(textBoxIdGrupo.Text.ToString());
             grupoContext.GruposErro.Add(new GruposDeErro(idGrupo, idTipo));
             grupoContext.SaveChanges();
             MessageBox.Show("Realizado com sucesso!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemple #3
0
 private void pegarIdTipo()
 {
     try
     {
         using (var tipoContext = new TErrosContext(_DB))
         {
             var lista = tipoContext.TiposErro.ToList();
             foreach (var item in lista)
             {
                 comboBoxTipos.Items.Add("Id: " + item.Id + " Nome: " + item.Nome);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro ao pegar os ripos de erro");
         MessageBox.Show(ex.Message);
     }
 }
Exemple #4
0
 private void btnRemover_Click(object sender, EventArgs e)
 {
     try
     {
         using (var tipoContext = new TErrosContext(_DB))
         {
             var id   = tipoContext.TiposErro.Where(s => s.Nome == comboBoxTipos.SelectedItem.ToString()).FirstOrDefault().Id;
             var tipo = tipoContext.TiposErro.FirstOrDefault(s => s.Id == id);
             tipoContext.TiposErro.Remove(tipo);
             tipoContext.SaveChanges();
             MessageBox.Show("Realizado com sucesso!");
             comboBoxTipos.Items.RemoveAt(comboBoxTipos.SelectedIndex);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemple #5
0
 private void btnListar_Click(object sender, EventArgs e)
 {
     comboBoxTipos.Items.Clear();
     try
     {
         using (var tipoContext = new TErrosContext(_DB))
         {
             IList <TiposDeErro> tipos = tipoContext.TiposErro.ToList();
             foreach (var item in tipos)
             {
                 comboBoxTipos.Items.Add(item.Nome);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemple #6
0
 private void btnCadastro_Click(object sender, EventArgs e)
 {
     try
     {
         using (var tipoContext = new TErrosContext(_DB))
         {
             string nome       = textBoxNome.Text.ToString();
             string descricao  = textBoxDescricao.Text.ToString();
             int    prioridade = Convert.ToInt32(textBoxPrio.Text.ToString());
             tipoContext.TiposErro.Add(new TiposDeErro(nome, descricao, prioridade));
             tipoContext.SaveChanges();
             MessageBox.Show("Realizado com sucesso!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemple #7
0
 static void listaTipoErro(Maquina maq)
 {
     try
     {
         using (var Labcont = new LaboratorioContext(_DB))
         {
             var lab = Labcont.Laboratorios.FirstOrDefault(c => c.Id == maq.IdLab);
             Labname = lab.Nome;
             idGrupo = lab.IdGrupoErro;
             using (var GrupoCont = new GErrosContext(_DB))
             {
                 IList <GruposDeErro> TodoErros     = GrupoCont.GruposErro.Where(c => c.IdGrupo == lab.IdGrupoErro).ToList();
                 List <int>           idDeTodoErros = TodoErros.Select(s => s.IdTipoErro).ToList();
                 using (var tErros = new TErrosContext(_DB))
                 {
                     IList <TiposDeErro> tiposDeErros = tErros.TiposErro.ToList();
                     Lista = new string[idDeTodoErros.Count];
                     int index = 0;
                     foreach (var item in idDeTodoErros)
                     {
                         if (tiposDeErros.Select(s => s.Id).Contains(item))
                         {
                             var nome = tiposDeErros.FirstOrDefault(s => s.Id == item).Nome;
                             Lista[index] = nome;
                             index++;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         MessageBox.Show(ex.StackTrace);
     }
 }