Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (Txt_nomeProd.Text == "" || Txt_precoCompra.Text == "" || Txt_precoVenda.Text == "")
            {
                MessageBox.Show("Todos os campos são obrigatórios!");
                return;
            }
            Txt_nomeProd.Enabled    = false;
            Nud_qtde.Enabled        = false;
            Txt_precoCompra.Enabled = false;
            Txt_precoVenda.Enabled  = false;
            Cb_fornecedor.Enabled   = false;
            Btn_salvar.Enabled      = false;
            Btn_novo.Enabled        = true;
            string query = String.Format(@"
                            INSERT 
                                INTO
                                    tb_produtos
                                               (
                                                T_NOMEPRODUTO,
                                                N_QTDE,
                                                N_PRECOCOMPRA,
                                                N_PRECOVENDA,
                                                N_IDFORNECEDOR
                                                )
                                VALUES(
                                        '{0}',{1},{2},{3},{4}
                                       )
            ", Txt_nomeProd.Text, Nud_qtde.Value, Convert.ToDouble(Txt_precoCompra.Text), Convert.ToDouble(Txt_precoVenda.Text), Cb_fornecedor.SelectedValue);

            Banco.dml(query);
            MessageBox.Show("Produto Cadastrado!");
        }
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            string query = String.Format(@"
                                    UPDATE
                                            tb_produtos
                                    SET
                                            T_NOMEPRODUTO = '{0}',
                                            N_QTDE = {1},
                                            N_PRECOCOMPRA = {2},
                                            N_PRECOVENDA = {3},
                                            N_IDFORNECEDOR = {4}
                                    WHERE
                                            N_IDPRODUTO = {5}
            ", Txt_nome.Text, Nud_qtde.Value, Txt_precoCompra.Text, Txt_precoVenda.Text, Cb_fornecedor.SelectedValue, Txt_id.Text);

            Banco.dml(query);
            MessageBox.Show("Dados do produto actualizado!");

            string sql = String.Format(@"
                                SELECT 
                                       tbp.N_IDPRODUTO as 'Id',
                                       tbp.T_NOMEPRODUTO as 'Nome do Produto',
                                       tbp.N_QTDE as 'Quantidade',
                                       tbp.N_PRECOCOMPRA as 'Preço de Compra',
                                       tbp.N_PRECOVENDA as 'Preço de Venda',
                                       tbf.T_NOMEFORNECEDOR as 'Fornecedor'
                                FROM
                                        tb_produtos as tbp
                                INNER JOIN
                                        tb_fornecedores as tbf on tbf.N_IDFORNECEDOR = tbp.N_IDFORNECEDOR
            ");

            Dgv_produtos.DataSource = Banco.dql(sql);
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string query = String.Format(@"
                                UPDATE 
                                        tb_clientes
                                SET
                                        T_NOMECLIENTE = '{0}',
                                        T_CONTACTO = '{1}'
                                WHERE
                                        N_IDCLIENTE = {2}
            ", Txt_nomeCliente.Text, Mtxt_contacto.Text, Txt_id.Text);

            Banco.dml(query);
            MessageBox.Show("Cadastro Actualizado!");

            string sql = String.Format(@"
                                SELECT 
                                        N_IDCLIENTE as 'Id',
                                        T_NOMECLIENTE as 'Nome do Cliente',
                                        T_CONTACTO as 'Contacto'
                                FROM
                                        tb_clientes
            ");

            Dgv_clientes.DataSource = Banco.dql(sql);
        }
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            string query = String.Format(@"
                        UPDATE
                                tb_fornecedores 
                        SET
                                T_NOMEFORNECEDOR = '{0}', 
                                T_TELEFONE = '{1}', 
                                T_NIF = '{2}'
                        WHERE
                                N_IDFORNECEDOR = {3}
            ", Txt_nome.Text, Txt_telefone.Text, Txt_nif.Text, Txt_id.Text);

            Banco.dml(query);
            MessageBox.Show("Dados do fornecedor actualizado!");
            string sql = String.Format(@"
                                    SELECT 
                                            N_IDFORNECEDOR as 'Id',
                                            T_NOMEFORNECEDOR as 'Nome',
                                            T_TELEFONE as 'Teçefone',
                                            T_NIF as 'NIF'
                                    FROM
                                            tb_fornecedores
            ");

            Dgv_fornecedor.DataSource = Banco.dql(sql);
        }
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            string    query = String.Format(@"
                            SELECT 
                                    *
                            FROM
                                    tb_usuarios
                            WHERE
                                    N_IDFUNCIONARIO = {0}
            ", Cb_funcionarios.SelectedValue);
            DataTable VerificaFuncionario = new DataTable();

            VerificaFuncionario = Banco.dql(query);
            if (VerificaFuncionario.Rows.Count > 0)
            {
                string nome = Dgv_usuarios.SelectedRows[0].Cells[5].Value.ToString();
                MessageBox.Show("Passou: " + nome);
                if (Cb_funcionarios.Text.ToString() != nome)
                {
                    MessageBox.Show("Este funcionário já possuí conta associada!");
                    return;
                }
            }
            String sql = String.Format(@"
                                            UPDATE 
                                                    tb_usuarios
                                            SET
                                                    T_USERNAME = '******',
                                                    T_SENHA = '{1}',
                                                    N_NIVEL = {2},
                                                    T_STATUS = '{3}',
                                                    N_IDFUNCIONARIO = {4}
                                            WHERE
                                                    N_IDUSUARIO = {5}
            ", Txt_username.Text, Txt_senha.Text, Nud_nivel.Value, Cb_status.SelectedValue, Cb_funcionarios.SelectedValue, Txt_id.Text);

            Banco.dml(sql);
            MessageBox.Show("Dados actualizados.");

            string sqlActualizar = String.Format(@"
                                            SELECT
                                                    tbu.N_IDUSUARIO as 'Id',
                                                    tbu.T_USERNAME as 'Username',
                                                    tbu.T_SENHA as 'Senha',
                                                    tbu.N_NIVEL as 'Nível',
                                              CASE
                                                  WHEN tbu.T_STATUS = 'A' THEN 'Activa'
                                                  WHEN tbu.T_STATUS = 'B' THEN 'Bloqueado' 
                                                  WHEN tbu.T_STATUS = 'I' THEN 'Inativo' 
                                              END as 'Status',
                                                    tbf.T_NOMEFUNCIONARIO as 'Nome do Funcionário'
                                            FROM 
                                                    tb_usuarios as 'tbu'
                                            INNER JOIN
                                                    tb_funcionario as 'tbf' on tbf.N_IDFUNCIONARIO = tbu.N_IDFUNCIONARIO
            ");

            Dgv_usuarios.DataSource = Banco.dql(sqlActualizar);
        }
        private void Btn_excluir_Click(object sender, EventArgs e)
        {
            string sql = String.Format(@"
                                DELETE FROM
                                        tb_fornecedores
                                WHERE
                                        N_IDFORNECEDOR = {0}
            ", Txt_id.Text);

            Banco.dml(sql);
            MessageBox.Show("Registo apagado!");
            Dgv_fornecedor.Rows.Remove(Dgv_fornecedor.CurrentRow);
        }
        private void Btn_excluir_Click(object sender, EventArgs e)
        {
            string queryApagar = String.Format(@"
                            DELETE FROM
                                               tb_produtos
                            WHERE
                                                N_IDPRODUTO = {0}
            ", Txt_id.Text);

            Banco.dml(queryApagar);

            MessageBox.Show("Registo apagado!");
            Dgv_produtos.Rows.Remove(Dgv_produtos.CurrentRow);
        }
 private void Btn_excluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Deseja Excluir usuário ?", "Confirmar", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         string sql = String.Format(@"
                                 DELETE FROM
                                             tb_usuarios
                                 WHERE
                                              N_IDUSUARIO = {0}
         ", Txt_id.Text);
         Banco.dml(sql);
         Dgv_usuarios.Rows.Remove(Dgv_usuarios.CurrentRow);
     }
 }
Example #9
0
 private void Btn_excluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Quer eliminar registo?", "Confirmar", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
     {
         string sql = String.Format(@"
                             DELETE FROM
                                         tb_clientes
                             WHERE
                                         N_IDCLIENTE = {0}
         ", Txt_id.Text);
         Banco.dml(sql);
         MessageBox.Show("Registo excluido!");
         Dgv_clientes.Rows.Remove(Dgv_clientes.CurrentRow);
     }
 }
 private void Btn_excluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Deseja apagar registo?", "Continuar?", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         String sql = String.Format(@"
                     DELETE FROM
                                 tb_funcionario
                     WHERE
                                 N_IDFUNCIONARIO ={0}
         ", Txt_id.Text);
         Banco.dml(sql);
         MessageBox.Show("Registo apagado!");
         Dgv_funcionarios.Rows.Remove(Dgv_funcionarios.CurrentRow);
     }
 }
Example #11
0
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            string    query = String.Format(@"
                            SELECT 
                                    *
                            FROM
                                    tb_usuarios
                            WHERE
                                    N_IDFUNCIONARIO = {0}
            ", Cb_nome.SelectedValue);
            DataTable VerificaFuncionario = new DataTable();

            VerificaFuncionario = Banco.dql(query);
            if (VerificaFuncionario.Rows.Count > 0)
            {
                MessageBox.Show("Este funcionário já possuí conta associada!");
                return;
            }
            if (Txt_senha.Text != Txt_senha2.Text)
            {
                MessageBox.Show("As senhas não são iguais!");
                return;
            }
            if (Txt_username.Text == "" || Txt_senha.Text == "" || Txt_senha2.Text == "")
            {
                MessageBox.Show("Preencha todos os campos!");
                return;
            }

            string sql = String.Format(@"INSERT 
                                            INTO 
                                                tb_usuarios(T_USERNAME,T_SENHA,N_NIVEL,T_STATUS,N_IDFUNCIONARIO)
                                        VALUES(
                                                '{0}','{1}',{2},'{3}',{4}
                                               )
            ", Txt_username.Text, Txt_senha.Text, Nud_nivel.Value, Cb_status.SelectedValue, Cb_nome.SelectedValue);

            Banco.dml(sql);
            MessageBox.Show("Usuário cadastrado!");
            Cb_nome.Enabled      = false;
            Nud_nivel.Enabled    = false;
            Cb_status.Enabled    = false;
            Txt_senha.Enabled    = false;
            Txt_senha2.Enabled   = false;
            Txt_username.Enabled = false;
            Btn_novo.Enabled     = true;
            Btn_salvar.Enabled   = false;
        }
Example #12
0
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            if (Txt_nome.Text == "" || Txt_nome.Text == "")
            {
                MessageBox.Show("Todos os campos são obrigatórios!");
                return;
            }
            string query = String.Format(@"
                                INSERT 
                                    INTO
                                           tb_clientes(T_NOMECLIENTE,T_CONTACTO)
                                VALUES('{0}','{1}')
            ", Txt_nome.Text, Mtxt_contacto.Text);

            Banco.dml(query);
            MessageBox.Show("Cliente cadastrado!");
            Txt_nome.Enabled      = false;
            Mtxt_contacto.Enabled = false;
            Btn_salvar.Enabled    = false;
            Btn_novo.Enabled      = true;
        }
Example #13
0
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            if (Txt_nome.Text == "" || Txt_telefone.Text == "" || Txt_nif.Text == "")
            {
                MessageBox.Show("Todos os campos são obrigatórios!");
                return;
            }
            Txt_nome.Enabled     = false;
            Txt_telefone.Enabled = false;
            Txt_nif.Enabled      = false;
            Btn_salvar.Enabled   = false;
            Btn_novo.Enabled     = true;

            string query = String.Format(@"
                                            INSERT INTO 
                                                        tb_fornecedores(T_NOMEFORNECEDOR,T_TELEFONE,T_NIF)
                                            VALUES('{0}','{1}','{2}')                                            
            ", Txt_nome.Text, Txt_telefone.Text, Txt_nif.Text);

            Banco.dml(query);
            MessageBox.Show("Fornecedor Cadastrado!");
        }
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            if (Txt_nome.Text == "" || Txt_pai.Text == "" || Txt_mae.Text == "" || Txt_natural.Text == "" || Txt_BI.Text == "" || Txt_email.Text == "" || Txt_facebook.Text == "" || Txt_municipio.Text == "" || Txt_bairro.Text == "" || Mtxt_telefone.Text == "")
            {
                MessageBox.Show("TODOS OS CAMPOS SÃO OBRIGATÓRIOS!");
                return;
            }
            if (destinoCompleto == "")
            {
                if (MessageBox.Show("Sem foto selecionada, deseja continuar ?", "Continuar?", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            if (destinoCompleto != "")
            {
                System.IO.File.Copy(origemCompleto, destinoCompleto, true);
                if (File.Exists(destinoCompleto))
                {
                    Pb_foto.ImageLocation = destinoCompleto;
                }
                else
                {
                    if (MessageBox.Show("ERRO ao localizar a imagem, deseja continuar ?", "Continuar?", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            string query = String.Format(@" INSERT 
                                INTO 
                                    tb_funcionario
                                (
                                  T_NOMEFUNCIONARIO,
                                   T_PAI,
                                    T_MAE,
                                    T_BI,
                                    T_NATURALIDADE,
                                    T_TELEFONE,
                                    T_EMAIL,
                                    T_FACEBOOK,
                                    T_BAIRRO,
                                    T_MUNICIPIO,
                                    T_FOTO
                                )
                            VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')
         ", Txt_nome.Text, Txt_pai.Text, Txt_mae.Text, Txt_BI.Text, Txt_natural.Text, Mtxt_telefone.Text, Txt_email.Text, Txt_facebook.Text, Txt_bairro.Text, Txt_municipio.Text, destinoCompleto);

            Banco.dml(query);
            MessageBox.Show("Funcionário Cadastrado!");

            Txt_nome.Enabled      = false;
            Txt_pai.Enabled       = false;
            Txt_mae.Enabled       = false;
            Txt_BI.Enabled        = false;
            Txt_natural.Enabled   = false;
            Mtxt_telefone.Enabled = false;
            Txt_email.Enabled     = false;
            Txt_facebook.Enabled  = false;
            Txt_bairro.Enabled    = false;
            Txt_municipio.Enabled = false;
            Btn_salvar.Enabled    = false;
            Btn_foto.Enabled      = false;
            Btn_novo.Enabled      = true;
        }
        private void Btn_salvar_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Imagem antiga: " + imagemAntiga + "|||| Imagem final: " + destinoCompleto);
            if (destinoCompleto != "")
            {
                System.IO.File.Copy(origemCompleto, destinoCompleto, true);
                if (imagemAntiga != destinoCompleto)
                {
                    System.IO.File.Delete(imagemAntiga);
                }

                if (File.Exists(destinoCompleto))
                {
                    Pb_foto.ImageLocation = destinoCompleto;
                }
                else
                {
                    if (MessageBox.Show("ERRO ao localizar a imagem, deseja continuar?", "ERRO", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            string sql = String.Format(@"
                                            UPDATE
                                                    tb_funcionario
                                            SET
                                                    T_NOMEFUNCIONARIO = '{0}',
                                                    T_PAI = '{1}',
                                                    T_MAE = '{2}',
                                                    T_BI = '{3}',
                                                    T_NATURALIDADE = '{4}',
                                                    T_TELEFONE = '{5}',
                                                    T_EMAIL = '{6}',
                                                    T_FACEBOOK = '{7}',
                                                    T_BAIRRO = '{8}',
                                                    T_MUNICIPIO = '{9}',
                                                    T_FOTO = '{10}'
                                             WHERE
                                                    N_IDFUNCIONARIO = {11}
                    
            ", Txt_nome.Text, Txt_pai.Text, Txt_mae.Text, Txt_bi.Text, Txt_naturalidade.Text, Txt_telefone.Text, Txt_email.Text, Txt_Facebook.Text, Txt_bairro.Text, Txt_municipio.Text, destinoCompleto, Txt_id.Text);

            Banco.dml(sql);
            MessageBox.Show("Dados do funcionário actualizado!");
            string query = String.Format(@"
                        SELECT 
                                N_IDFUNCIONARIO as 'Id',
                                T_NOMEFUNCIONARIO as 'Nome',
                                T_PAI as 'Pai',
                                T_MAE as 'Mãe',
                                T_BI as 'Nº do BI',
                                T_NATURALIDADE as 'Naturalidade',
                                T_TELEFONE as 'Telefone',
                                T_EMAIL as 'Email',
                                T_FACEBOOK as 'Facebook',
                                T_BAIRRO as 'Bairro',
                                T_MUNICIPIO as 'Municipio'
                        FROM
                                tb_funcionario
            ");

            Dgv_funcionarios.DataSource = Banco.dql(query);
        }