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 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 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 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(); } }
public bool RemoverAluguel(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("delete from aluguel where id = {0}", 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(); } }
public long TotalAluguel() { BD_FESTA festa = new BD_FESTA(); try { this.conn = new NpgsqlConnection(this.connString); //Abra a conexão com o PgSQL this.conn.Open(); string totalConvidados = String.Format("Select COUNT(*) from aluguel where id_festa = {0}", festa.pegarFesta(AutenticacaoCliente.pegarId())); using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand(totalConvidados, 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); }
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 long quantidadeCarne() { 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}' and (grupo = 'CHURRASCO' and (tipo like '%CARNE%' or tipo like '%LINGUI%'))", 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 void relatorio(int id, int idFesta) { using (var doc = new PdfSharp.Pdf.PdfDocument()) { BD_FESTA festa = new BD_FESTA(); BD_ITENS itens = new BD_ITENS(); String[] dados = new String[4]; dados = festa.pegarDadosFesta(id, idFesta); var page = doc.AddPage(); var graphics = PdfSharp.Drawing.XGraphics.FromPdfPage(page); var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics); XBrush titulos = new XSolidBrush(XColor.FromArgb(22, 93, 180)); var font = new PdfSharp.Drawing.XFont("Comic Sans MS", 20); var font2 = new PdfSharp.Drawing.XFont("Verdana", 12); graphics.DrawRoundedRectangle(PdfSharp.Drawing.XPens.Black, 10, 10, 576, 822, 10, 10); textFormatter.DrawString(dados[0], font, titulos, new PdfSharp.Drawing.XRect(40, 50, page.Width, page.Height)); graphics.DrawImage(PdfSharp.Drawing.XImage.FromFile(@"C:\Users\erick\Desktop\Projeto Interdisciplinar 2º Semestre\LAFIESTA\METODIKU\Resources\tiozao.png"), 530, 30, 50, 50); textFormatter.DrawString("Local da festa: ", font2, titulos, new PdfSharp.Drawing.XRect(40, 100, 150, 70)); textFormatter.DrawString(dados[1], font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(132, 100, 150, 70)); textFormatter.DrawString("Total de convidados: ", font2, titulos, new PdfSharp.Drawing.XRect(350, 100, 150, 70)); textFormatter.DrawString(dados[2], font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, 100, 150, 70)); textFormatter.DrawString("Data da festa: ", font2, titulos, new PdfSharp.Drawing.XRect(40, 120, 150, 70)); textFormatter.DrawString(dados[3], font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(132, 120, 250, 70)); textFormatter.DrawString("Comidas: ", font2, titulos, new PdfSharp.Drawing.XRect(40, 160, 150, 70)); textFormatter.DrawString("Número", font2, titulos, new PdfSharp.Drawing.XRect(60, 180, 30, 70)); textFormatter.DrawString("Tipo", font2, titulos, new PdfSharp.Drawing.XRect(170, 180, 100, 70)); textFormatter.DrawString("Nome", font2, titulos, new PdfSharp.Drawing.XRect(310, 180, 100, 70)); textFormatter.DrawString("Unidade", font2, titulos, new PdfSharp.Drawing.XRect(470, 180, 100, 70)); DataTable comidas = new DataTable(); comidas = itens.comidas(idFesta); int y = 205; string item = null; if (comidas != null) { for (int i = 0; i < comidas.Rows.Count; i++) { DataRow dr = comidas.Rows[i]; textFormatter.DrawString(dr[0].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(80, y, 550, 70)); textFormatter.DrawString(dr[1].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(140, y, 550, 70)); textFormatter.DrawString(dr[2].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(270, y, 550, 70)); textFormatter.DrawString(dr[3].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, y, 550, 70)); y += 20; } } textFormatter.DrawString("Bebidas: ", font2, titulos, new PdfSharp.Drawing.XRect(40, y + 20, 150, 70)); y += 40; textFormatter.DrawString("Número", font2, titulos, new PdfSharp.Drawing.XRect(60, y, 30, 70)); textFormatter.DrawString("Tipo", font2, titulos, new PdfSharp.Drawing.XRect(150, y, 100, 70)); textFormatter.DrawString("Nome", font2, titulos, new PdfSharp.Drawing.XRect(290, y, 100, 70)); textFormatter.DrawString("Unidade", font2, titulos, new PdfSharp.Drawing.XRect(470, y, 100, 70)); DataTable bebidas = new DataTable(); bebidas = itens.bebidas(idFesta); if (bebidas != null) { y += 30; for (int i = 0; i < bebidas.Rows.Count; i++) { DataRow dr = bebidas.Rows[i]; textFormatter.DrawString(dr[0].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(80, y, 550, 70)); textFormatter.DrawString(dr[1].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(140, y, 550, 70)); textFormatter.DrawString(dr[2].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(270, y, 550, 70)); textFormatter.DrawString(dr[3].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, y, 550, 70)); y += 20; } } textFormatter.DrawString("Utensilios: ", font2, titulos, new PdfSharp.Drawing.XRect(40, y + 20, 150, 70)); y += 40; textFormatter.DrawString("Número", font2, titulos, new PdfSharp.Drawing.XRect(60, y, 30, 70)); textFormatter.DrawString("Tipo", font2, titulos, new PdfSharp.Drawing.XRect(150, y, 100, 70)); textFormatter.DrawString("Nome", font2, titulos, new PdfSharp.Drawing.XRect(290, y, 100, 70)); textFormatter.DrawString("Unidade", font2, titulos, new PdfSharp.Drawing.XRect(470, y, 100, 70)); DataTable utensilios = new DataTable(); utensilios = itens.utensilios(idFesta); if (utensilios != null) { y += 30; for (int i = 0; i < utensilios.Rows.Count; i++) { DataRow dr = utensilios.Rows[i]; textFormatter.DrawString(dr[0].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(80, y, 550, 70)); textFormatter.DrawString(dr[1].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(140, y, 550, 70)); textFormatter.DrawString(dr[2].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(270, y, 550, 70)); textFormatter.DrawString(dr[3].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, y, 550, 70)); y += 20; } } doc.Save(dados[0] + ".pdf"); System.Diagnostics.Process.Start(dados[0] + ".pdf"); } }