private void atualizarCampos() { cc = new ClasseConexao(); ds = new DataSet(); string sql = string.Format("select * from cliente where id_funcionario = {0}", txtID_func.Text); ds = cc.executarSQL(sql); if (ds == null || ds.Tables[0].Rows.Count < 1) { txtID_func.Text = txtNome.Text = txtSenha.Text = txtIdade.Text = txtDate_nasc.Text = txtEnd.Text = txtTelefone.Text = txtCel.Text = txtRG.Text = txtCPF.Text = txtCEP.Text = txtMail.Text = ""; } else { txtID_func.Text = ds.Tables[0].Rows[0]["id_cliente"].ToString(); txtNome.Text = ds.Tables[0].Rows[0]["nome"].ToString(); txtSenha.Text = ds.Tables[0].Rows[0]["senha"].ToString(); txtIdade.Text = ds.Tables[0].Rows[0]["idade"].ToString(); txtDate_nasc.Text = ds.Tables[0].Rows[0]["dt_nascim"].ToString(); txtEnd.Text = ds.Tables[0].Rows[0]["endereco"].ToString(); txtTelefone.Text = ds.Tables[0].Rows[0]["telefone"].ToString(); txtCel.Text = ds.Tables[0].Rows[0]["celular"].ToString(); txtRG.Text = ds.Tables[0].Rows[0]["rg"].ToString(); txtCPF.Text = ds.Tables[0].Rows[0]["cpf"].ToString(); txtCEP.Text = ds.Tables[0].Rows[0]["cep"].ToString(); txtMail.Text = ds.Tables[0].Rows[0]["email"].ToString(); } }
private void fagundes() { cc = new ClasseConexao(); ds = new DataSet(); ds = cc.executarSQL("select * from funcionario"); dataGridView1.DataSource = ds.Tables[0]; }
} // INITIALIZE private void btnLogar_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); cc = new ClasseConexao(); string sql = "select * from funcionario where nome='" + txtUser.Text + "' and senha='" + txtPass.Text + "'"; ds = cc.executarSQL(sql); int quantidade = ds.Tables[0].Rows.Count; if (quantidade != 0) { id = ds.Tables[0].Rows[0]["id_permissao"].ToString(); nome = ds.Tables[0].Rows[0]["nome"].ToString(); cc = new ClasseConexao(); ds = new DataSet(); string sql2 = "select * from permissao where id_permissao='" + id + "'"; ds = cc.executarSQL(sql2); nm_permissao = ds.Tables[0].Rows[0]["nm_permissao"].ToString(); permissao = ds.Tables[0].Rows[0]["lista_permissoes"].ToString(); frmMDI fp = new frmMDI(txtUser.Text, nm_permissao, permissao); this.Hide(); fp.Show(); } else { MessageBox.Show("Usuário e/ou senha incorreto(s). Tente novamente"); txtUser.Text = ""; txtPass.Text = ""; } } //Log com banco de dados
private void atualizarCampos() { cc = new ClasseConexao(); ds = new DataSet(); string sql = string.Format("select * from funcionario where id_funcionario = {0}", txtID_Func.Text); ds = cc.executarSQL(sql); if (ds == null || ds.Tables[0].Rows.Count < 1) {
private void button1_Click(object sender, EventArgs e) { cc = new ClasseConexao(); ds = new DataSet(); string sql = "select Evt.id_cliente as ID, Prod.nm_produto as Nome, Prod.preco as Preço, PraEvt.qtd_produto as Quantidade, Frn.empresa as Empresa, Frn.representante as Representante, Prod.tipo_produto as Tipo, Evt.id_lugar as Lugar, Evt.valor_orcamento as Valor_Total, Evt.dt_evento as Data, Evt.hr_inicio as Inicio from evento AS Evt , pratos_evento AS PraEvt , fornecedor_perecivel AS Frn , produto AS Prod where Evt.id_evento ='" + textBox1.Text + "' AND PraEvt.id_orcamento ='" + textBox1.Text + "' AND Prod.id_produto = PraEvt.id_produto AND Frn.id_produto = PraEvt.id_produto "; ds = cc.executarSQL(sql); dataGridView1.DataSource = ds.Tables[0]; x = ds.Tables[0].Rows.Count; }
private void frmTeste_Load(object sender, EventArgs e) { DateTime ag; DateTime.TryParse(txtDate_nasc.Text, out ag); TimeSpan t = DateTime.Now - ag; txtIdade.Text = Math.Floor(t.Days / 365d) + ""; pr = new Persist(); cc = new ClasseConexao(); ds = new DataSet(); string sql = ("select * from cliente where id_cliente like '" + pr.getId()+"'"); ds = cc.executarSQL(sql); if (ds == null || ds.Tables[0].Rows.Count < 1) {
private void btnInserir_Click(object sender, EventArgs e) { if (radioButton1.Checked) { if (txtCPF.Text.Replace(".","").Replace ("-", "") == "") { MessageBox.Show("Por favor insira seu CPF","Atenção!"); } if (txtRG.Text == "") { MessageBox.Show("Por favor insira seu RG", "Atenção!"); } else { x = 1; } } else { if (txtCNPJ.Text == "") { MessageBox.Show("Por favor insira seu CNPJ", "Atenção!"); } if (txtIE.Text == "") { MessageBox.Show("Por favor insira seu IE", "Atenção!"); } else { y = 1; } } if (txtNome.Text == "" || txtSenha.Text == "" || txtIdade.Text == "" || txtDate_nasc.Text == "" || txtTelefone.Text == "" || txtCel.Text == "" || txtEnd.Text == "" || txtCEP.Text == "" || txtMail.Text == "") { MessageBox.Show("Por favor insira todos os dados requeridos", "Atenção!"); } else { if (x == 1 || y == 1) { if (radioButton1.Checked) <<<<<<< HEAD { string sqlrB1 = ("select id_cliente from cliente where cpf_cnpj ='" + txtCPF.Text + "'"); cc = new ClasseConexao(); ds = new DataSet(); ds = cc.executarSQL(sqlrB1); } if (radioButton2.Checked) {
private void btnProcurar_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Insira algo no campo para pesquisar na lista de clientes"); dataGridView1.DataSource = ""; } else { cc = new ClasseConexao(); ds = new DataSet(); <<<<<<< HEAD string sql = ("select Func.id_funcionario as ID, Func.nome as Nome, Func.senha as Senha, Func.dt_nascim as Nascimento, Func.endereco as Endereço, Func.telefone as Telefone, Func.celular as Celular, Func.cep as Cep, Func.cpf as CPF, Func.rg as RG, Func.email as Email from funcionario as Func where Func.id_funcionario like '" + textBox1.Text + "' or nome = '" + textBox1.Text + "' or senha = '" + textBox1.Text + "' or dt_nascim like '" + textBox1.Text + "' or endereco = '" + textBox1.Text + "' or telefone = '" + textBox1.Text + "' or celular = '" + textBox1.Text + "' or cep = '" + textBox1.Text + "' or cpf = '" + textBox1.Text + "' or rg = '" + textBox1.Text + "' or email = '" + textBox1.Text + "'"); ======= string sql = ("select * from funcionario where id_funcionario like '" + textBox1.Text + "' or nome = '" + textBox1.Text + "' or senha = '" + textBox1.Text + "' or dt_nascim like '" + textBox1.Text + "' or endereco = '" + textBox1.Text + "' or telefone = '" + textBox1.Text + "' or celular = '" + textBox1.Text + "' or cep = '" + textBox1.Text + "' or cpf = '" + textBox1.Text + "' or rg = '" + textBox1.Text + "' or email = '" + textBox1.Text + "'"); >>>>>>> origin/master ds = cc.executarSQL(sql); dataGridView1.DataSource = ds.Tables[0]; } }
private void frmEdit_Prod_Load(object sender, EventArgs e) { PR = new Persist(); cc = new ClasseConexao(); ds = new DataSet(); string sql = ("select * from produto where id_produto like '" + PR.getId()+"'"); ds = cc.executarSQL(sql); if (ds == null || ds.Tables[0].Rows.Count < 1) { txtNome.Text = txtPreço.Text = txtQuant.Text = txtTipo.Text = ""; } else { txtID_Produto.Text = ds.Tables[0].Rows[0]["id_produto"].ToString(); txtNome.Text = ds.Tables[0].Rows[0]["nm_produto"].ToString(); txtPreço.Text = ds.Tables[0].Rows[0]["preco"].ToString(); txtPreço.Text = txtPreço.Text.Replace(",", "."); txtQuant.Text = ds.Tables[0].Rows[0]["quantidade"].ToString(); txtTipo.Text = ds.Tables[0].Rows[0]["tipo_produto"].ToString(); } }
private void btnInserir_Click(object sender, EventArgs e) { cc = new ClasseConexao(); ds = new DataSet(); var = 1; do { cc = new ClasseConexao(); ds = new DataSet(); string sql = ("select nome from funcionario where id_funcionario = '" + var + "'"); ds = cc.executarSQL(sql); if (ds.Tables[0].Rows.Count > 0) var++; else break; } while (true); <<<<<<< HEAD frmInser_Func fIF = new frmInser_Func(var); fIF.Show(); fIF.Location = new Point(448, 133); }
private void button1_Click(object sender, EventArgs e) { try { if (dataGridView1.Rows.Count > 1) { for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++) { string v1 = dataGridView1.Rows[i].Cells[1].Value.ToString(); string v2 = dataGridView1.Rows[i].Cells[2].Value.ToString(); string sql = "insert into contatos (nome,telefone) values ('" + v1 + "','" + v2 + "')"; cc = new ClasseConexao(); ds = new DataSet(); ds = cc.executarSQL(sql); } } fagundes(); } catch(Exception erro) { MessageBox.Show("Erro ao inserir"+erro.ToString()); } }
private void atualizarCampos() { cc = new ClasseConexao(); ds = new DataSet(); string sql = "select Frn.*,Prd.nm_produto from fornecedor_consumivel AS Frn, produto AS Prd where Frn.id_fornecedor_consumivel = '"+txtID_Forn.Text+"' AND Prd.id_produto = Frn.id_produto"; ds = cc.executarSQL(sql); if (ds == null || ds.Tables[0].Rows.Count < 1) { txtID_Forn.Text = --var_x + ""; } else { txtProduto.Text = ds.Tables[0].Rows[0]["nm_produto"].ToString(); txtEmpresa.Text = ds.Tables[0].Rows[0]["empresa"].ToString(); txtEnd.Text = ds.Tables[0].Rows[0]["endereco"].ToString(); txtTel.Text = ds.Tables[0].Rows[0]["telefone"].ToString(); txtCel.Text = ds.Tables[0].Rows[0]["celular"].ToString(); txtCNPJ.Text = ds.Tables[0].Rows[0]["cnpj"].ToString(); txtMail.Text = ds.Tables[0].Rows[0]["email"].ToString(); txtSite.Text = ds.Tables[0].Rows[0]["website"].ToString(); txtCEP.Text = ds.Tables[0].Rows[0]["cep"].ToString(); txtRepre.Text = ds.Tables[0].Rows[0]["representante"].ToString(); } }
private void button1_Click(object sender, EventArgs e) { cc = new ClasseConexao(); ds = new DataSet(); string sql = "select Orc.id_orcamento as ID, Cli.id_cliente as Cliente, Cli.nome as Nome,Lug.nome_lugar as Lugar, Lug.endereco as Endereço, Orc.num_convidados as NúmeroConvidados, Orc.tema as Tema, Orc.email_cliente as Email, Orc.dt_orcamento as DataEvento, Orc.hr_inicio as HoraInicio, Orc.valor_orcamento as Valor, Orc.acrescimos from orcamento AS Orc, lugar AS Lug, cliente AS Cli where Orc.id_orcamento = '" + txtOrça.Text + "' AND Lug.id_lugar=Orc.id_lugar AND Cli.id_cliente = Orc.id_cliente"; ds = cc.executarSQL(sql); dataGridView1.DataSource = ds.Tables[0]; string id_orcamento = ds.Tables[0].Rows[0]["ID"].ToString(); id_orcamentods = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); id_clienteds = int.Parse(ds.Tables[0].Rows[0]["Cliente"].ToString()); nomeds = ds.Tables[0].Rows[0]["Nome"].ToString(); lugards = ds.Tables[0].Rows[0]["Lugar"].ToString(); enderecods = ds.Tables[0].Rows[0]["Endereço"].ToString(); convidadosds = int.Parse(ds.Tables[0].Rows[0]["NúmeroConvidados"].ToString()); temads = ds.Tables[0].Rows[0]["Tema"].ToString(); emailds = ds.Tables[0].Rows[0]["Email"].ToString(); datads = DateTime.Parse(ds.Tables[0].Rows[0]["DataEvento"].ToString()); horads = DateTime.Parse(ds.Tables[0].Rows[0]["HoraInicio"].ToString()); valords = double.Parse(ds.Tables[0].Rows[0]["Valor"].ToString()); acrecimos = ds.Tables[0].Rows[0]["acrescimos"].ToString(); cc = new ClasseConexao(); ds = new DataSet(); string sql3 = "select id_lugar from lugar where nome_lugar = '" + lugards + "'"; ds = cc.executarSQL(sql3); id_lugards = int.Parse(ds.Tables[0].Rows[0]["id_lugar"].ToString()); cc = new ClasseConexao(); ds = new DataSet(); string sql2 = "select Pra_Evt.id_produto as ID, Prod.nm_produto as Nome, Prod.preco as Preço, Pra_Evt.qtd_produto as Quantidade FROM produto AS Prod, pratos_evento AS Pra_Evt WHERE Pra_Evt.id_orcamento =" + id_orcamento + " AND Prod.id_produto = Pra_Evt.id_produto "; ds = cc.executarSQL(sql2); dataGridView2.DataSource = ds.Tables[0]; button2.Enabled = true; qtd_pratosds = ds.Tables[0].Rows.Count; }
private void button2_Click(object sender, EventArgs e) { button2.Visible = false; button3.Visible = true; cc = new ClasseConexao(); ds = new DataSet(); if (dataGridView1.DataSource == "") MessageBox.Show("Campo de procura vazio"); else { string sql = "select representante from fornecedor_perecivel where empresa = '" + dataGridView1.Rows[0].Cells[4].Value.ToString() + "'"; ds = cc.executarSQL(sql); nm_repre = ds.Tables[0].Rows[0]["representante"].ToString(); DateTime dtn = DateTime.Now; string dtnn = dtn.ToShortDateString(); r = " " + dtnn + "\nBom Dia,\nVenho por meio deste requisitar os seguintes produtos:\n\n"; for (int i = 0; i < x; i++) { string y = dataGridView1.Rows[i].Cells[3].Value.ToString(); string w = dataGridView1.Rows[i].Cells[1].Value.ToString(); string v = dataGridView1.Rows[i].Cells[4].Value.ToString(); string z = dataGridView1.Rows[i].Cells[5].Value.ToString(); r += w + " - " + y + " unidades, do fornecedor " + v + "(" + z + ")\n"; } richTextBox1.Text = r; dataGridView1.Visible = false; richTextBox1.Visible = true; close = 0; close2 = 1; } }
private void button2_Click(object sender, EventArgs e) { int max = dataGridView1.Rows.Count - 2; string v1 = dataGridView1.Rows[max].Cells[1].Value.ToString(); string v2 = dataGridView1.Rows[max].Cells[2].Value.ToString(); string sql = "inser into contatos(nome,telefone) values ('" + v1 + "', '" + v2 + "')"; cc = new ClasseConexao(); ds = new DataSet(); ds = cc.executarSQL(sql); fagundes(); }
private void frmInser_Forn_Load(object sender, EventArgs e) { do { cc = new ClasseConexao(); ds = new DataSet(); string sql = ("select empresa from fornecedor_perecivel where id_fornecedor_perecivel = '" + var_per + "'"); ds = cc.executarSQL(sql); if (ds.Tables[0].Rows.Count > 0) var_per++; else break; } while (true); do { cc = new ClasseConexao(); ds = new DataSet(); string sql = ("select empresa from fornecedor_consumivel where id_fornecedor_consumivel = '" + var_con + "'"); ds = cc.executarSQL(sql); if (ds.Tables[0].Rows.Count > 0) var_con++; else break; } while (true); }
private void button2_Click(object sender, EventArgs e) { if (txtNome.Visible == false) { txtNome.Visible = txtData.Visible = true; btnNext.Visible = false; btnAprovar.Visible = true; txtData.Text = dt.ToString(); txtNome.Text = "Insira seu Nome.."; } else { cc = new ClasseConexao(); ds = new DataSet(); string sql = "select id_funcionario,id_permissao from funcionario where nome = '" + txtNome.Text + "'"; ds = cc.executarSQL(sql); if (ds == null || ds.Tables[0].Rows.Count < 1) { MessageBox.Show("Nome do funcionário incorreto"); txtNome.Text = ""; } else { id_funcionariods = int.Parse(ds.Tables[0].Rows[0]["id_funcionario"].ToString()); id_permissaods = int.Parse(ds.Tables[0].Rows[0]["id_permissao"].ToString()); funcionariods = txtNome.Text; DateTime var = DateTime.Parse(txtData.Text); aprovação = var.ToShortDateString(); cc = new ClasseConexao(); ds = cc.executarSQL("SELECT (MAX(id_evento) + 1) AS novo_id FROM evento"); string id_evento = ds.Tables[0].Rows[0]["novo_id"].ToString().Trim(); if (id_evento == "") id_evento = "1"; cc = new ClasseConexao(); string sql2 = string.Format("INSERT INTO evento VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, '{7}', {8}, '{9}', '{10}', '{11}', '{12}', '{13}', '{14}')", id_evento, id_lugards, id_clienteds, id_permissaods, id_funcionariods, valords.ToString().Replace(',', '.'), convidadosds, datads, qtd_pratosds, lugards, temads, emailds, aprovação, horads, acrecimos); cc.executarSQL(sql2); cc = new ClasseConexao(); string sqlproduto = string.Format("UPDATE pratos_evento SET id_evento = {1}, id_orcamento = NULL WHERE id_orcamento = {0}", id_orcamentods, id_evento); cc.executarSQL(sqlproduto); MessageBox.Show("Operação Concluída!"); } } }
private void btnAlterar2_Click(object sender, EventArgs e) { if (txtNome.Text == "" || txtPreço.Text == "" || txtQuant.Text == "" || txtTipo.Text == "") { MessageBox.Show("Campos vazios detectados"); } else { if (txtTipo.Text == "perecivel" || txtTipo.Text == "consumivel") { DialogResult res = MessageBox.Show("Deseja alterar o campo selecionado?", "Aviso", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { txtPreço.Text = txtPreço.Text.Replace(",", "."); string sql = string.Format("UPDATE produto SET nm_produto = '{0}', preco = '{1}', quantidade = '{2}', tipo_produto = '{3}' where id_produto = {4}", txtNome.Text, txtPreço.Text, txtQuant.Text, txtTipo.Text, txtID_Produto.Text); cc = new ClasseConexao(); cc.executarSQL(sql); MessageBox.Show("Operação concluída!"); } else { MessageBox.Show("Operação Cancelada"); } txtNome.Enabled = false; txtPreço.Enabled = false; txtQuant.Enabled = false; txtTipo.Enabled = false; btnAlterar2.Visible = false; //btnExcluir.Enabled = true; } else { MessageBox.Show("Tipo de produto inexistente"); txtTipo.Text = ""; } } }
private void btnInserir_Click(object sender, EventArgs e) { if (txtPerm.Text == "Estoquista") { IDPERM = 1; } if (txtPerm.Text == "Atendente") { IDPERM = 2; } if (txtPerm.Text == "Administrador") { IDPERM = 1; } cc = new ClasseConexao(); ds = new DataSet(); string sql = string.Format ("insert into funcionario values({0},{1},'{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}', '{11}','{12}')", txtID_Func.Text, IDPERM, txtNome.Text, txtSenha.Text, txtDate_nasc.Text, txtEnd.Text, txtTelefone.Text, txtCel.Text, txtCEP.Text, txtCPF.Text, txtRG.Text, "SP", txtMail.Text); cc.executarSQL(sql); MessageBox.Show("Operação Concluída"); }