private void button3_Click(object sender, EventArgs e)
        {
            bool       ret  = false;
            Fornecedor forn = new Fornecedor();
            Gerente    gr   = new Gerente();

            if (atForCNPJ.Text == "  .   .   /    -")
            {
                MessageBox.Show("Por favor Faça uma Consulta!", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                forn.CNPJ     = atForCNPJ.Text;
                forn.Nome     = atForNome.Text;
                forn.Telefone = atForTelefone.Text;
                forn.Endereco = atForEndereco.Text;

                ret = gr.AtualizarFornecedor(forn);

                if (ret == false)
                {
                    atForUsrMsg.BackColor = Color.LightSalmon;
                    atForUsrMsg.Text      = "Atualização mau sucedida! Por favor Contactar o Admnistrador do Sistema.\r ERRO:" + forn.MsgErro;
                }
                else
                {
                    atForUsrMsg.BackColor = Color.LightGreen;
                    atForUsrMsg.Text      = "Atualizado Com Sucesso!";
                    button3.Enabled       = false;
                }
            }
        }
        private void button10_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            Gerente   gr = new Gerente();

            dt = gr.LerTodosRelatorio();
            dgRelatorio.DataSource = dt;
        }
        private void cadasForCadastrar_Click(object sender, EventArgs e)
        {
            bool ret = false;

            Produto   prod  = new Produto();
            Produto   IDPRO = new Produto();
            DataTable dt    = new DataTable();
            Gerente   gr    = new Gerente();

            if (cadasForCNPJ.Text == "11.111.111/1111-11")
            {
                MessageBox.Show("Por favor Digite o Campo CNPJ.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasForNome.Text == "Ex. Fulano de Tal")
            {
                MessageBox.Show("Por favor Digite o Campo Nome.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasForTelefone.Text == "(99)9999-9999")
            {
                MessageBox.Show("Por favor Digite o Campo Telefone.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasForEndereco.Text == "R. Alameda")
            {
                MessageBox.Show("Por favor Digite o Campo Endereço.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                prod.CNPJ     = cadasForCNPJ.Text;
                prod.Nome     = cadasForNome.Text;
                prod.Telefone = cadasForTelefone.Text;
                prod.Endereco = cadasForEndereco.Text;
                ret           = gr.CadastrarFornecedor(prod);

                if (ret == false)
                {
                    cadasForUsrMsg.BackColor = Color.LightSalmon;
                    cadasForUsrMsg.Text      = "Cadastramento mau sucedido! Por favor Contactar o Admnistrador do Sistema.\r ERRO:" + prod.MsgErro;
                }
                else
                {
                    cadasForCadastrar.Enabled = false;

                    cadasForCNPJ.Enabled     = false;
                    cadasForNome.Enabled     = false;
                    cadasForTelefone.Enabled = false;
                    cadasForEndereco.Enabled = false;

                    cadasForUsrMsg.BackColor = Color.LightGreen;
                    cadasForUsrMsg.Text      = "Cadastramento Bem sucedido";
                }
            }
        }
        public DataTable ConsultaTodosFornecedores()
        {
            DataTable dt = null;

            try
            {
                Gerente gr = new Gerente();
                dt = gr.LerTodosFornecedores();
            }
            catch (Exception ex)
            {
                string err = ex.Message;
            }

            return(dt);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int         IDVenda;
            string      id;
            bool        ret = false, ret1 = false, ret2 = false;
            DataTable   dt, dt1, dt2 = new DataTable();
            DataSet     ds   = new DataSet();
            Funcionario func = new Funcionario();
            Gerente     gr   = new Gerente();
            Vendedor    vend = new Vendedor();
            Produto     prod = new Produto();

            dt = func.ConsultaIDProd_Forn(Convert.ToInt32(vendaIDPROD.Text));
            id = dt.Rows[0]["IDForn_prod"].ToString();

            vend.IDuser      = Convert.ToInt32(vendaCodID.Text);
            vend.IDForn_Prod = Convert.ToInt32(id);
            vend.DataVenda   = vendaDataVenda.Value;
            vend.TotalVenda  = Convert.ToInt32(vendaVlTotal.Value);


            dt2 = gr.LerTodosProdutos();
            object sumObject;

            sumObject = dt2.Compute("Sum(QuantidadeProduto)", "");

            ret     = gr.CadastrarVenda(vend);
            dt1     = func.ConsultaIDVenda(vend);
            IDVenda = Convert.ToInt32(dt1.Rows[0]["IDVenda"].ToString());

            ret1 = gr.CadastrarRelatorio(IDVenda, Convert.ToInt32(sumObject.ToString()), Convert.ToInt32(vendaVdaQtdPROD.Value.ToString()), Convert.ToInt32(vendaVlTotal.Value));


            prod.IDprod            = Convert.ToInt32(vendaIDPROD.Text);
            prod.QuantidadeProduto = Convert.ToInt32(vendaVdaQtdPROD.Value.ToString());
            ret2 = gr.AtualizarProd(prod);
            if (ret == false || ret1 == false || ret2 == false)
            {
                vendaMsg.BackColor = Color.LightSalmon;
                vendaMsg.Text      = "Venda mal sucedida! Por favor Contactar o Admnistrador do Sistema.\r ERRO:";
            }
            else
            {
                vendaMsg.BackColor = Color.LightGreen;
                vendaMsg.Text      = "Venda Efetuada Com Sucesso";
            }
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            Funcionario func = new Funcionario();
            Gerente     gr   = new Gerente();
            DataTable   dt   = new DataTable();

            dt = gr.ConsultarFuncionario(LgCodUsr.Text);

            try
            {
                if (LgCodUsr.Text == "" && LgSenhaUsr.Text == "")
                {
                    MessageBox.Show("Por Favor Digite o ID e a Senha.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                if (LgCodUsr.Text == "")
                {
                    MessageBox.Show("Por Favor Digite o ID", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                if (LgSenhaUsr.Text == "")
                {
                    MessageBox.Show("Por Favor Digite a Senha.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (LgCodUsr.Text == dt.Rows[0]["IDUsuario"].ToString() && LgSenhaUsr.Text == dt.Rows[0]["senha"].ToString())
                    {
                        DialogResult = DialogResult.OK;
                        cargo        = dt.Rows[0]["cargo"].ToString();
                        email        = dt.Rows[0]["email"].ToString();
                    }
                    else
                    {
                        MessageBox.Show("ID ou Senha incorretos", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
            }
            catch
            {
                MessageBox.Show("ID Não existe.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
        private void button13_Click(object sender, EventArgs e)
        {
            bool ret = false, ret1 = false;

            Produto   prod  = new Produto();
            Produto   IDPRO = new Produto();
            DataTable dt    = new DataTable();
            Gerente   gr    = new Gerente();

            if (cadasPRODCategoria.Text == "")
            {
                MessageBox.Show("Por favor Digite o Campo Categoria.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODMarca.Text == "")
            {
                MessageBox.Show("Por favor Digite o Campo Marca.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODTamanho.Text == "")
            {
                MessageBox.Show("Por favor Digite o Campo Tamanho.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODQuantidadeProd.Value == 0)
            {
                MessageBox.Show("Por favor Digite o Campo Quantidade do Produto.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODValorCompraProd.Value == 0)
            {
                MessageBox.Show("Por favor Digite o Campo Valor de Compra de Produto.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODValorVendaProd.Value == 0)
            {
                MessageBox.Show("Por favor Digite o Campo Valor de Venda.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODQtdMax.Value == 0)
            {
                MessageBox.Show("Por favor Digite o Campo Quantidade Máxima do Estoque.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODQtdMin.Value == 0)
            {
                MessageBox.Show("Por favor Digite o Campo Quantidade Mínima do Estoque.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cadasPRODCNPJ.Text == "  .   .   /    -")
            {
                MessageBox.Show("Por favor Faça uma busca do CNPJ do Fornecedor", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                prod.Categoria            = cadasPRODCategoria.Text;
                prod.Marca                = cadasPRODMarca.Text;
                prod.Tamanho              = cadasPRODTamanho.Text;
                prod.QuantidadeProduto    = Convert.ToInt32(cadasPRODQuantidadeProd.Value);
                prod.ValorCompraProd      = Convert.ToInt32(cadasPRODValorCompraProd.Value);
                prod.ValorVendaProd       = Convert.ToInt32(cadasPRODValorVendaProd.Value);
                prod.QuantidadeMaxEstoque = Convert.ToInt32(cadasPRODQtdMax.Value);
                prod.QuantidadeMinEstoque = Convert.ToInt32(cadasPRODQtdMin.Value);

                ret1 = gr.CadastrarFornecedorProduto(prod);//

                dt = gr.ConsultarIDProd(prod);
                int id = Convert.ToInt32(dt.Rows[0]["IDProd"].ToString());
                IDPRO.IDprod = id;
                IDPRO.CNPJ   = cadasPRODCNPJ.Text;
                ret          = gr.CadastrarForn_IDProd(IDPRO);

                if (ret == false || ret1 == false)
                {
                    cadasPRODUsrMsg.BackColor = Color.LightSalmon;
                    cadasPRODUsrMsg.Text      = "Cadastramento mau sucedido! Por favor Contactar o Admnistrador do Sistema.\r ERRO:" + prod.MsgErro + IDPRO.MsgErro;
                }
                else
                {
                    cadasPRODCadastrar.Enabled = false;

                    cadasPRODCategoria.Enabled       = false;
                    cadasPRODMarca.Enabled           = false;
                    cadasPRODTamanho.Enabled         = false;
                    cadasPRODQuantidadeProd.Enabled  = false;
                    cadasPRODValorCompraProd.Enabled = false;
                    cadasPRODValorVendaProd.Enabled  = false;
                    cadasPRODQtdMax.Enabled          = false;
                    cadasPRODQtdMin.Enabled          = false;

                    cadasPRODUsrMsg.BackColor = Color.LightGreen;
                    cadasPRODUsrMsg.Text      = "Cadastramento Bem sucedido";
                }
            }
        }
        private void btnCadastrarUsu_Click(object sender, EventArgs e)
        {
            bool        ret = false;
            Funcionario func = new Funcionario();
            Gerente     grt = new Gerente();
            DataTable   dt = new DataTable();
            string      nome, id;

            usrMsg.BackColor = Color.LightGray;
            if (usrNome.Text == "Ex. Fulano de Tal")
            {
                MessageBox.Show("Por favor Digite o Campo Nome.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (usrSenha.Text == "123456")
            {
                MessageBox.Show("Por favor Digite o Campo Senha.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (usrTelefone.Text == "(99)9999-9999")
            {
                MessageBox.Show("Por favor Digite o Campo Telefone.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (usrEmail.Text == "*****@*****.**")
            {
                MessageBox.Show("Por favor Digite o Campo E-mail.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (usrEndereco.Text == "R. Alameda")
            {
                MessageBox.Show("Por favor Digite o Campo Endereço.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (usrCargo.Text == "")
            {
                MessageBox.Show("Por favor selecione o Cargo.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (usrNome.Text.Trim().Length > 0)
                {
                    func.Nome = usrNome.Text;
                }
                else
                {
                    EscreveMsgUsuario("Nome Invalido"); return;
                }

                if (usrSenha.Text.Trim().Length > 0)
                {
                    func.Senha = usrSenha.Text;
                }
                else
                {
                    EscreveMsgUsuario("Senha Invalida"); return;
                }
                if (usrF.Checked)
                {
                    func.Sexo = "F";
                }
                else
                {
                    func.Sexo = "M";
                }
                func.Telefone = usrTelefone.Text;
                func.Email    = usrEmail.Text;
                func.Endereco = usrEndereco.Text;
                func.Cargo    = usrCargo.Text;
                func.DataNasc = usrDataNasc.Value;
                func.Status   = "A";

                ret = grt.CadastrarFuncionario(func);

                if (ret == false)
                {
                    usrMsg.BackColor = Color.LightSalmon;
                    usrMsg.Text      = "Cadastramento mau sucedido! Por favor Contactar o Admnistrador do Sistema.\r ERRO:" + func.MsgErro;
                }
                else
                {
                    Funcionario f = new Funcionario();
                    dt               = f.lerIDNomeFuncionario(usrEmail.Text);
                    id               = dt.Rows[0]["IDUsuario"].ToString();
                    nome             = dt.Rows[0]["nome"].ToString();
                    usrMsg.BackColor = Color.LightGreen;
                    usrMsg.Text      = "Cadastramento Bem sucedido";
                    MessageBox.Show("Senhor(a): " + nome + "\nseu novo ID: " + id, "Cadastrado", MessageBoxButtons.OK, MessageBoxIcon.Information);


                    usrNome.Clear();
                    usrSenha.Clear();
                    usrTelefone.Clear();
                    usrEmail.Clear();
                    usrEndereco.Clear();
                    usrCargo.ResetText();
                    usrDataNasc.ResetText();
                    usrDataNasc.Text = DateTime.Now.ToShortTimeString();
                    usrF.Checked     = false;
                    usrM.Checked     = false;
                }
            }
        }
        private void button7_Click(object sender, EventArgs e)
        {
            bool        ret  = false;
            Funcionario func = new Funcionario();
            Gerente     grt  = new Gerente();

            atUsrMsg.BackColor = Color.LightGray;
            if (atUsrCod.Text == "")
            {
                MessageBox.Show("Por favor Faça uma Consulta!", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                func.ID = Convert.ToInt32(atUsrCod.Text);
                if (atUsrNome.Text.Trim().Length > 0)
                {
                    func.Nome = atUsrNome.Text;
                }
                else
                {
                    EscreveMsgUsuario("Nome Invalido"); return;
                }

                if (atUsrSenha.Text.Trim().Length > 0)
                {
                    func.Senha = atUsrSenha.Text;
                }
                else
                {
                    EscreveMsgUsuario("Senha Invalida"); return;
                }
                if (atUsrF.Checked)
                {
                    func.Sexo = "F";
                }
                else
                {
                    func.Sexo = "M";
                }
                func.Telefone = atUsrTelefone.Text;
                func.Email    = atUsrEmail.Text;
                func.Endereco = atUsrEndereco.Text;
                func.Cargo    = atUsrCargo.Text;
                func.DataNasc = atUsrDataNasc.Value;
                if (atUsrA.Checked)
                {
                    func.Status = "A";
                }
                else
                {
                    func.Status = "I";
                }

                ret = grt.AtualizarPorIdFuncionario(func);

                if (ret == false)
                {
                    atUsrMsg.BackColor = Color.LightSalmon;
                    atUsrMsg.Text      = "Atualização mau sucedida! Por favor Contactar o Admnistrador do Sistema.\r ERRO:" + func.MsgErro;
                }
                else
                {
                    atUsrMsg.BackColor = Color.LightGreen;
                    atUsrMsg.Text      = "Atualizado Com Sucesso!";


                    button5.Enabled = false;

                    atUsrNome.Enabled     = false;
                    atUsrSenha.Enabled    = false;
                    atUsrTelefone.Enabled = false;
                    atUsrEmail.Enabled    = false;
                    atUsrEndereco.Enabled = false;
                    atUsrCargo.Enabled    = false;
                    atUsrDataNasc.Enabled = false;
                    atUsrF.Enabled        = false;
                    atUsrM.Enabled        = false;
                    atUsrA.Enabled        = false;
                    atUsrI.Enabled        = false;

                    atUsrCod.Enabled = false;
                    atUsrCod.Clear();
                    atUsrNome.Clear();
                    atUsrSenha.Clear();
                    atUsrTelefone.Clear();
                    atUsrEmail.Clear();
                    atUsrEndereco.Clear();
                    atUsrCargo.ResetText();
                    atUsrDataNasc.ResetText();
                    atUsrDataNasc.Text = DateTime.Now.ToShortTimeString();
                    atUsrF.Checked     = false;
                    atUsrM.Checked     = false;
                    atUsrA.Checked     = false;
                    atUsrI.Checked     = false;
                }
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            Funcionario func = new Funcionario();
            Gerente     gr   = new Gerente();
            DataTable   dt   = new DataTable();

            atUsrMsg.BackColor = Color.LightGray;

            atUsrNome.Clear();
            atUsrSenha.Clear();
            atUsrTelefone.Clear();
            atUsrEmail.Clear();
            atUsrEndereco.Clear();
            atUsrCargo.ResetText();
            atUsrDataNasc.ResetText();
            atUsrF.Checked = false;
            atUsrM.Checked = false;
            atUsrA.Checked = false;
            atUsrI.Checked = false;

            dt = gr.ConsultarFuncionario(atUsrCod.Text);
            try
            {
                if (atUsrCod.Text == "")
                {
                    atUsrMsg.Text      = "Por Favor Digite o ID!";
                    atUsrMsg.BackColor = Color.LightSalmon;

                    atUsrNome.Enabled     = false;
                    atUsrSenha.Enabled    = false;
                    atUsrTelefone.Enabled = false;
                    atUsrEmail.Enabled    = false;
                    atUsrEndereco.Enabled = false;
                    atUsrCargo.Enabled    = false;
                    atUsrDataNasc.Enabled = false;
                    atUsrF.Enabled        = false;
                    atUsrM.Enabled        = false;
                    atUsrA.Enabled        = false;
                    atUsrI.Enabled        = false;
                }
                else
                {
                    atUsrNome.Enabled     = true;
                    atUsrSenha.Enabled    = true;
                    atUsrTelefone.Enabled = true;
                    atUsrEmail.Enabled    = true;
                    atUsrEndereco.Enabled = true;
                    atUsrCargo.Enabled    = true;
                    atUsrDataNasc.Enabled = true;
                    atUsrF.Enabled        = true;
                    atUsrM.Enabled        = true;
                    atUsrA.Enabled        = true;
                    atUsrI.Enabled        = true;

                    atUsrNome.Text     = dt.Rows[0]["nome"].ToString();
                    atUsrSenha.Text    = dt.Rows[0]["senha"].ToString();
                    atUsrTelefone.Text = dt.Rows[0]["telefone"].ToString();
                    atUsrEmail.Text    = dt.Rows[0]["email"].ToString();
                    atUsrEndereco.Text = dt.Rows[0]["endereco"].ToString();
                    atUsrCargo.Text    = dt.Rows[0]["cargo"].ToString();
                    atUsrDataNasc.Text = dt.Rows[0]["datanasc"].ToString();
                    if (dt.Rows[0]["sexo"].ToString() == "F")
                    {
                        atUsrF.Checked = true;
                    }
                    else
                    {
                        atUsrM.Checked = true;
                    }
                    if (dt.Rows[0]["Status"].ToString() == "A")
                    {
                        atUsrA.Checked = true;
                    }
                    else
                    {
                        atUsrI.Checked = true;
                    }
                    atUsrMsg.BackColor    = Color.LightGreen;
                    atUsrMsg.Text         = "Consulta Bem sucedida";
                    atUsrCod.Enabled      = false;
                    atUsrVerUsers.Enabled = false;
                    button5.Enabled       = false;
                }
            }
            catch (Exception ex)
            {
                atUsrCod.Enabled   = false;
                atUsrMsg.Text      = "Usuário não existe! Erro: " + ex.Message;
                atUsrMsg.BackColor = Color.LightSalmon;
                button5.Enabled    = false;
                button7.Enabled    = false;

                atUsrNome.Enabled     = false;
                atUsrSenha.Enabled    = false;
                atUsrTelefone.Enabled = false;
                atUsrEmail.Enabled    = false;
                atUsrEndereco.Enabled = false;
                atUsrCargo.Enabled    = false;
                atUsrDataNasc.Enabled = false;
                atUsrF.Enabled        = false;
                atUsrM.Enabled        = false;
                atUsrA.Enabled        = false;
                atUsrI.Enabled        = false;
            }
        }