Exemplo n.º 1
0
 public Peca[] BuscarTodos(int obra, int eixo)
 {
     int registros = rPeca.buscarTudo(obra, eixo).Rows.Count;
     DataTable resultado = rPeca.buscarTudo(obra, eixo);
     Peca[] peca = new Peca[registros];
     for (int i = 0; i < registros; i++)
     {
         Peca item = new Peca();
         item.IdPeca = Convert.ToInt32(resultado.Rows[i][0].ToString());
         item.IdObra = Convert.ToInt32(resultado.Rows[i][1].ToString());
         item.IdEixo = Convert.ToInt32(resultado.Rows[i][2].ToString());
         item.NomePeca = resultado.Rows[i][3].ToString();
         peca[i] = item;
     }
     return peca;
 }
Exemplo n.º 2
0
 public Peca[] BuscarPeca(string nome, string idEixo, string idObra, string campo)
 {
     DataTable resultado = rPeca.buscar(nome, idEixo, idObra, campo);
     Peca[] peca = new Peca[resultado.Rows.Count];
     Peca item = new Peca();
     for (int i = 0; i < resultado.Rows.Count; i++)
     {
         item.IdPeca = Convert.ToInt32(resultado.Rows[i][0].ToString());
         item.IdObra = Convert.ToInt32(resultado.Rows[i][1].ToString());
         item.IdEixo = Convert.ToInt32(resultado.Rows[i][2].ToString());
         item.NomePeca = resultado.Rows[i][3].ToString();
         peca[i] = item;
     }
     if (peca.Length < 0)
     {
         MessageBox.Show("Peça não encontrada",
         "Erro ao Buscar",
         MessageBoxButtons.OK,
         MessageBoxIcon.Exclamation,
         MessageBoxDefaultButton.Button1);
     }
     return peca;
 }
Exemplo n.º 3
0
 public void InserirPeca(string idObra, string idEixo, string nome)
 {
     Peca[] peca = BuscarPeca(nome, idEixo, idObra, "cNomePeca");
     if (peca.Length > 0)
     {
         MessageBox.Show("Peça ja Cadastrada",
         "Erro ao Cadastrar",
         MessageBoxButtons.OK,
         MessageBoxIcon.Exclamation,
         MessageBoxDefaultButton.Button1);
     }
     else
     {
         Peca iPeca = new Peca();
         iPeca.IdEixo = Convert.ToInt32(idEixo);
         iPeca.IdObra = Convert.ToInt32(idObra);
         iPeca.NomePeca = nome;
         rPeca.inserir(iPeca);
     }
 }
Exemplo n.º 4
0
 public void inserir(Peca peca)
 {
     con.open();
     con.executeQuery("INSERT INTO tblPeca (cIDObra, cIDEixo, cNomePeca) VALUES ("+ peca.IdObra + ", " + peca.IdEixo + ", '" + peca.NomePeca + "') ");
     con.close();
 }
Exemplo n.º 5
0
 public void editar(Peca peca, string nome)
 {
     con.open();
     con.executeQuery("UPDATE tblPeca SET cNomePeca = '" + nome + "' WHERE cIDPeca =" + peca.IdPeca + " AND cIDEixo = " + peca.IdEixo + " AND cIDObra = " + peca.IdObra);
     con.close();
 }