Esempio n. 1
0
        private void CadastroFesta_Load(object sender, EventArgs e)
        {
            dateTimePicker1.MinDate = DateTime.Today.AddDays(-1);
            BD_CONVIDADOS convidados = new BD_CONVIDADOS();

            label1.Text          = convidados.TotalConvidados().ToString();
            textBox1.Text        = Festa.pegarNome();
            dateTimePicker1.Text = Festa.pegarData();
            textBox2.Text        = Festa.pegarLocal();
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
0
        public bool AtualizarFesta()
        {
            try
            {
                this.conn = new NpgsqlConnection(this.connString);
                Encoding enc = new UTF8Encoding(true, true);

                //Abra a conexão com o PgSQL
                this.conn.Open();

                string cmdInserir = String.Format("UPDATE festa SET local = '{0}', convidados = {1}, data = '{2}', nome_festa = '{3}' where id = {4} and id_usuario = {5}", Festa.pegarLocal(),
                                                  Festa.pegarConvidados(), Festa.pegarData(), Festa.pegarNome(), Festa.pegarId(), AutenticacaoCliente.pegarId());

                byte[] bytes = Encoding.Default.GetBytes(cmdInserir);
                cmdInserir = Encoding.UTF8.GetString(bytes);

                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();
            }
        }
Esempio n. 4
0
        public bool CadastrarFesta()
        {
            try
            {
                Encoding enc = new UTF8Encoding(true, true);
                this.conn = new NpgsqlConnection(this.connString);

                //Abra a conexão com o PgSQL
                this.conn.Open();

                string cmdInserir = String.Format("Insert Into festa(local, id_usuario, convidados, data, nome_festa) values('{0}',{1},{2},'{3}','{4}')", Festa.pegarLocal(), AutenticacaoCliente.pegarId(),
                                                  Festa.pegarConvidados(), Festa.pegarData(), Festa.pegarNome());

                byte[] bytes = Encoding.Default.GetBytes(cmdInserir);
                cmdInserir = Encoding.UTF8.GetString(bytes);

                using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand(cmdInserir, this.conn))
                {
                    pgsqlcommand.ExecuteNonQuery();
                    return(true);
                }
            }
            catch (NpgsqlException ex)
            {
                throw ex;
                //return true;
            }
            catch (Exception ex)
            {
                throw ex;
                //return true;
            }
            finally
            {
                this.conn.Close();
            }
        }
Esempio n. 5
0
 private void MenuCliente_Load(object sender, EventArgs e)
 {
     Festa.limparFesta();
 }