public void PreencherGrid() { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) { try { string mSQL = "SELECT * FROM PECAS"; FbCommand cmd = new FbCommand(mSQL, connection); FbDataAdapter da = new FbDataAdapter(cmd); dtPeca = new DataTable(); da.Fill(dtPeca); this.gdPeca.DataSource = dtPeca; this.gdPeca.Columns["ID_PECA"].HeaderText = "Código"; this.gdPeca.Columns["ID_PECA"].Width = 70; this.gdPeca.Columns["PECA"].HeaderText = "Peça"; this.gdPeca.Columns["PECA"].Width = 300; this.gdPeca.Columns["OBS"].HeaderText = "Observaçoes"; this.gdPeca.Columns["OBS"].Width = 510; } catch (FbException fbex) { MessageBox.Show("Erro de acesso a dados da peça : " + fbex.Message, "Erro"); } } }
public void PreencherGrid() { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) { try { string mSQL = "SELECT * FROM USUARIOS"; FbCommand cmd = new FbCommand(mSQL, connection); FbDataAdapter da = new FbDataAdapter(cmd); dtUsuario = new DataTable(); da.Fill(dtUsuario); this.gdUsuarios.DataSource = dtUsuario; this.gdUsuarios.Columns["ID_USUARIO"].HeaderText = "Usuário"; this.gdUsuarios.Columns["ID_USUARIO"].Width = 70; this.gdUsuarios.Columns["NOME"].HeaderText = "Nome"; this.gdUsuarios.Columns["NOME"].Width = 280; this.gdUsuarios.Columns["LOGIN"].HeaderText = "Login"; this.gdUsuarios.Columns["SENHA"].Visible = false; } catch (FbException fbex) { MessageBox.Show("Erro de acesso a dados do Usuário : " + fbex.Message, "Erro"); } } }
public void PreencherGrid() { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) { try { string mSQL = "SELECT * FROM fornecedores"; FbCommand cmd = new FbCommand(mSQL, connection); FbDataAdapter da = new FbDataAdapter(cmd); dtCliente = new DataTable(); da.Fill(dtCliente); this.gdFornecedor.DataSource = dtCliente; this.gdFornecedor.Columns["ID_FORNECEDOR"].HeaderText = "Código"; this.gdFornecedor.Columns["ID_FORNECEDOR"].Width = 50; this.gdFornecedor.Columns["NOME_FANT"].HeaderText = "Razão Social"; this.gdFornecedor.Columns["NOME_FANT"].Width = 280; this.gdFornecedor.Columns["RG_INSC"].HeaderText = "CPF/CNPJ"; this.gdFornecedor.Columns["RG_INSC"].Width = 280; this.gdFornecedor.Columns["CPF_CNPJ"].HeaderText = "CPF/CNPJ"; this.gdFornecedor.Columns["FONEF"].HeaderText = "Telefone"; this.gdFornecedor.Columns["FONEC"].HeaderText = "Celular"; this.gdFornecedor.Columns["CIDADE"].HeaderText = "Cidade"; this.gdFornecedor.Columns["CIDADE"].Width = 150; this.gdFornecedor.Columns["EMAIL"].HeaderText = "E-mail"; this.gdFornecedor.Columns["EMAIL"].Width = 150; this.gdFornecedor.Columns["PESSOA"].Visible = false; this.gdFornecedor.Columns["RAZAO"].Visible = false; this.gdFornecedor.Columns["NASC_FUNDA"].Visible = false; this.gdFornecedor.Columns["ENDERECO"].Visible = false; this.gdFornecedor.Columns["NUMERO"].Visible = false; this.gdFornecedor.Columns["CEP"].Visible = false; this.gdFornecedor.Columns["BAIRRO"].Visible = false; this.gdFornecedor.Columns["UF"].Visible = false; this.gdFornecedor.Columns["FONEX"].Visible = false; this.gdFornecedor.Columns["OBS"].Visible = false; } catch (FbException fbex) { MessageBox.Show("Erro de acesso a dados do cliente : " + fbex.Message, "Erro"); } finally { } } }
public void AcessarBanco() { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) { try { } catch (FbException febex) { MessageBox.Show("Erro de acesso ao banco de dados " + febex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { connection.Close(); } } }
public void AcessarBanco() { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) { try { connection.Open(); } catch (FbException fbex) { MessageBox.Show("Erro de acesso ao banco de dados: " + fbex.Message, "Erro"); } finally { connection.Close(); } } }
public static void Cadastrar(Fornecedor fornecedor) { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) { try { connection.Open(); string mSQL = "INSERT into fornecedores Values (" + fornecedor.IdFornecedor + ",'" + // tem aspas simples so apos a virgula. fornecedor.Pessoa + "','" + fornecedor.Nome_Fant + "','" + fornecedor.Razao + "','" + fornecedor.Cpf_Cnpj + "','" + fornecedor.Rg_Insc + "','" + fornecedor.Nasc_Funda.ToString("dd.MM.yyyy") + "','" + fornecedor.Email + "','" + fornecedor.Endereco + "','" + fornecedor.Numero + "','" + fornecedor.Cep + "','" + fornecedor.Bairro + "','" + fornecedor.Cidade + "','" + fornecedor.UF + "','" + fornecedor.FoneF + "','" + fornecedor.FoneC + "','" + fornecedor.FoneX + "','" + fornecedor.Obs + "')"; FbCommand cmd = new FbCommand(mSQL, connection); // MessageBox.Show(mSQL, "Cadastro", MessageBoxButtons.OK); //mensagem para ver o que está indo para o Banco cmd.ExecuteNonQuery(); } catch (FbException fbex) { throw fbex; } finally { connection.Close(); } } }
public static void Cadastrar(Pecas peca) { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) { try { connection.Open(); string mSQL = "INSERT INTO Pecas Values (" + peca.IdPeca + ",'" + peca.Peca + "','" + peca.Obs + "')"; FbCommand cmd = new FbCommand(mSQL, connection); cmd.ExecuteNonQuery(); } catch (FbException fbex) { throw fbex; } finally { connection.Close(); } } }
public static void Cadastrar(Usuarios usuarios) { using (FbConnection connection = DaoBanco.GetInstancia().getConexao()) try { connection.Open(); string mSQL = "INSERT into Usuarios Values (" + usuarios.IdUsuario + ",'" + usuarios.Nome + "','" + usuarios.Email + "','" + usuarios.Login + "','" + usuarios.Senha + "')"; FbCommand cmd = new FbCommand(mSQL, connection); cmd.ExecuteNonQuery(); } catch (FbException febx) { throw febx; } finally { connection.Close(); } }
private void frmCadastroJob_Load(object sender, EventArgs e) { using (FbConnection conn = DaoBanco.GetInstancia().getConexao()) { //Combobox clientes string SqlCli = "SELECT nome_fant FROM clientes order by nome_fant"; FbCommand cmdCli = new FbCommand(SqlCli, conn); FbDataAdapter dacli = new FbDataAdapter(cmdCli); DataTable dtCli = new DataTable(); dacli.Fill(dtCli); cbCliente.DisplayMember = "nome_fant"; cbCliente.DataSource = dtCli; cbCliente.SelectedIndex = -1; //Primeira linha em branco no combobox //Combobox Atendimento string SqlUsrA = "SELECT nome FROM usuarios order by nome "; FbCommand cmdUsrA = new FbCommand(SqlUsrA, conn); FbDataAdapter dausra = new FbDataAdapter(cmdUsrA); DataTable dtUsrA = new DataTable(); dausra.Fill(dtUsrA); cbAtendimento.DisplayMember = "nome"; cbAtendimento.DataSource = dtUsrA; cbAtendimento.SelectedIndex = -1; //Combobox Criacao string SqlUsrC = "SELECT nome FROM usuarios order by nome"; FbCommand cmdUsrC = new FbCommand(SqlUsrC, conn); FbDataAdapter dausrc = new FbDataAdapter(cmdUsrC); DataTable dtUsrC = new DataTable(); dausrc.Fill(dtUsrC); cbCriacao.DisplayMember = "nome"; cbCriacao.DataSource = dtUsrC; cbCriacao.SelectedIndex = -1; //Combobox Peça1 string SqlUsrP1 = "SELECT peca FROM pecas order by peca"; FbCommand cmdUsrP1 = new FbCommand(SqlUsrP1, conn); FbDataAdapter dausrp1 = new FbDataAdapter(cmdUsrP1); DataTable dtUsrP1 = new DataTable(); dausrp1.Fill(dtUsrP1); cbPeca1.DisplayMember = "peca"; cbPeca1.DataSource = dtUsrP1; cbPeca1.SelectedIndex = -1; //Combobox Peça2 string SqlUsrP2 = "SELECT peca FROM pecas order by peca"; FbCommand cmdUsrP2 = new FbCommand(SqlUsrP2, conn); FbDataAdapter dausrp2 = new FbDataAdapter(cmdUsrP2); DataTable dtUsrP2 = new DataTable(); dausrp2.Fill(dtUsrP2); cbPeca2.DisplayMember = "peca"; cbPeca2.DataSource = dtUsrP1; cbPeca2.SelectedIndex = -1; //Combobox Peça3 string SqlUsrP3 = "SELECT peca FROM pecas order by peca"; FbCommand cmdUsrP3 = new FbCommand(SqlUsrP3, conn); FbDataAdapter dausrp3 = new FbDataAdapter(cmdUsrP3); DataTable dtUsrP3 = new DataTable(); dausrp3.Fill(dtUsrP3); cbPeca3.DisplayMember = "peca"; cbPeca3.DataSource = dtUsrP1; cbPeca3.SelectedIndex = -1; } }