private void Comida_Load(object sender, EventArgs e) { comboBox1.DataSource = itens.grupoComidas(); comboBox1.DisplayMember = "nome"; comboBox1.ValueMember = "id"; comboBox1.Text = ""; comboBox2.DataSource = null; dataGridView1.DataSource = itens.comidas(festa.pegarFesta(AutenticacaoCliente.pegarId())); }
private void button2_Click(object sender, EventArgs e) { GerarPdf pdf = new GerarPdf(); int id = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()); pdf.relatorio(id, festa.pegarFesta(AutenticacaoCliente.pegarId())); }
private void button2_Click(object sender, EventArgs e) { BD_FESTA festa = new BD_FESTA(); if (Festa.pegarId() == 0) { Festa.CadastrarFesta(textBox2.Text, int.Parse(label1.Text), dateTimePicker1.Text, textBox1.Text); bool sucesso = festa.CadastrarFesta(); Festa.setarId(festa.pegarFesta(AutenticacaoCliente.pegarId())); if (sucesso) { if (dataGridView1.DataSource != null && dataGridView1.CurrentRow.Cells[0].Value.ToString() != "") { int id = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()); bool criado = aluguel.CadastraAlguel(id); if (!criado) { MessageBox.Show("ERRO!!", "Convidado não foi cadastrado!", MessageBoxButtons.OK); } } this.Hide(); Comida comida = new Comida(); comida.Show(); } } else if (Festa.pegarId() != 0) { Festa.setarId(festa.pegarFesta(AutenticacaoCliente.pegarId())); Festa.CadastrarFesta(textBox2.Text, int.Parse(label1.Text), dateTimePicker1.Text, textBox1.Text); bool sucesso = festa.AtualizarFesta(); if (sucesso) { this.Hide(); Comida comida = new Comida(); comida.Show(); } else if (!sucesso) { MessageBox.Show("ERRO!!", "Convidado não foi cadastrado!", MessageBoxButtons.OK); } } }
public bool CadastrarUtensilio(String grupo, String tipo, String quantidade) { try { BD_FESTA festa = new BD_FESTA(); this.conn = new NpgsqlConnection(this.connString); //Abra a conexão com o PgSQL this.conn.Open(); string cmdInserir = String.Format("Insert Into utensilio(tipo, id_festa, grupo, quantidade) values('{0}',{1}, '{2}', '{3}')", tipo, festa.pegarFesta(AutenticacaoCliente.pegarId()), grupo, quantidade); using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand(cmdInserir, this.conn)) { pgsqlcommand.ExecuteNonQuery(); return(true); } } catch (NpgsqlException ex) { throw ex; //return false; } catch (Exception ex) { throw ex; //return false; } finally { this.conn.Close(); } }
public void AtualizarPasteis(String quantidade) { try { BD_FESTA festa = new BD_FESTA(); this.conn = new NpgsqlConnection(this.connString); //Abra a conexão com o PgSQL this.conn.Open(); string atualizar = String.Format("UPDATE comida SET quantidade = '{0}' where id_festa = {1} and (grupo = 'FINGER FOODS' and tipo like '%PASTEL%')", quantidade, festa.pegarFesta(AutenticacaoCliente.pegarId())); Console.WriteLine(atualizar); using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand(atualizar, this.conn)) { pgsqlcommand.ExecuteNonQuery(); } } catch (NpgsqlException ex) { //throw ex; } catch (Exception ex) { //throw ex; } finally { this.conn.Close(); } }
public long totalComidas() { try { BD_FESTA festa = new BD_FESTA(); this.conn = new NpgsqlConnection(this.connString); //Abra a conexão com o PgSQL this.conn.Open(); string verificaComida = String.Format("select count(*) from comida where id_festa = {0}", festa.pegarFesta(AutenticacaoCliente.pegarId())); using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand(verificaComida, this.conn)) { NpgsqlDataReader dr = pgsqlcommand.ExecuteReader(); if (dr.HasRows) { if (dr.Read()) { return(dr.GetInt64(0)); } } else { Console.WriteLine("Não funcionou!"); } } } catch (NpgsqlException ex) { throw ex; } catch (Exception ex) { throw ex; } finally { this.conn.Close(); } return(0); }
public DataTable ListaAlugueis() { BD_FESTA festa = new BD_FESTA(); DataTable dt = new DataTable(); try { this.conn = new NpgsqlConnection(this.connString); //Abra a conexão com o PgSQL this.conn.Open(); string convidados = String.Format("select a.id, p.tipo, p.observacao, p.cidade from aluguel a INNER JOIN produto p ON a.id_produto = p.id where a.id_festa = {0}", festa.pegarFesta(AutenticacaoCliente.pegarId())); using (NpgsqlDataAdapter pgsqlcommand = new NpgsqlDataAdapter(convidados, this.conn)) { pgsqlcommand.Fill(dt); } } catch (NpgsqlException ex) { //throw ex; } catch (Exception ex) { //throw ex; } finally { this.conn.Close(); } return(dt); }
public bool CadastraAlguel(int tipo) { try { BD_FESTA festa = new BD_FESTA(); this.conn = new NpgsqlConnection(this.connString); //Abra a conexão com o PgSQL this.conn.Open(); string cmdInserir = String.Format("Insert Into aluguel(id_festa, id_produto) values({0},{1})", festa.pegarFesta(AutenticacaoCliente.pegarId()), tipo); using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand(cmdInserir, this.conn)) { pgsqlcommand.ExecuteNonQuery(); return(true); } } catch (NpgsqlException ex) { throw ex; //return false; } catch (Exception ex) { throw ex; //return false; } finally { this.conn.Close(); } }
private void button2_Click(object sender, EventArgs e) { GerarPdf pdf = new GerarPdf(); pdf.relatorio(AutenticacaoCliente.pegarId(), festa.pegarFesta(AutenticacaoCliente.pegarId())); }