Exemple #1
0
        public static bool Update_Client(ClienteDAL clienteDAL)
        {
            bool sucesso = false;

            try
            {
                SqlCommand cmd = new SqlCommand("update JOALHERIA.CLIENTE set nome = @nome, tipo_documento = @tipo_documento, rg = @rg, cpf = @cpf, data_nascimento = @data_nascimento, email = @email, telefone = @telefone, endereco = @endereco, cidade = @cidade, uf = @uf, complemento = @complemento, tipo_pessoa = @tipo_pessoa, tipo_cliente = @tipo_cliente, data_registro = @data_registro where idcliente = @idcliente;");
                cmd.Parameters.AddWithValue(@"idcliente", clienteDAL.Idpessoa);
                cmd.Parameters.AddWithValue(@"nome", clienteDAL.Nome);
                cmd.Parameters.AddWithValue(@"tipo_documento", clienteDAL.Tipo_documento);
                cmd.Parameters.AddWithValue(@"rg", clienteDAL.Documento);
                cmd.Parameters.AddWithValue(@"cpf", clienteDAL.Cpf_cnpj);
                cmd.Parameters.AddWithValue(@"data_nascimento", clienteDAL.Data_nascimento);
                cmd.Parameters.AddWithValue(@"email", clienteDAL.Email);
                cmd.Parameters.AddWithValue(@"telefone", clienteDAL.Telefone);
                cmd.Parameters.AddWithValue(@"endereco", clienteDAL.Endereco);
                cmd.Parameters.AddWithValue(@"cidade", clienteDAL.Cidade);
                cmd.Parameters.AddWithValue(@"uf", clienteDAL.Uf);
                cmd.Parameters.AddWithValue(@"complemento", clienteDAL.Complemento);
                cmd.Parameters.AddWithValue(@"tipo_pessoa", clienteDAL.Tipo_pessoa);
                cmd.Parameters.AddWithValue(@"tipo_cliente", clienteDAL.Tipo_cliente);
                cmd.Parameters.AddWithValue(@"data_registro", clienteDAL.Data_registro);

                Acces.ExecuteNonQuery(cmd);
                sucesso = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Falha ao atualizar dados do Cliente! \n\r\n\r " + (ex.InnerException != null ? ex.InnerException.Message : ""), "1) " + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                sucesso = false;
            }
            return(sucesso);
        }
Exemple #2
0
        public static bool Insert_Client(ClienteDAL clienteDAL)
        {
            bool sucesso = false;

            try
            {
                SqlCommand cmd = new SqlCommand("insert into JOALHERIA.CLIENTE (nome, tipo_documento, rg, cpf, data_nascimento, email, telefone, endereco, cidade, uf, complemento, tipo_pessoa, tipo_cliente, data_registro) values (@nome, @tipo_documento, @rg, @cpf, @data_nascimento, @email, @telefone, @endereco, @cidade, @uf, @complemento, @tipo_pessoa, @tipo_cliente, @data_registro);");
                cmd.Parameters.AddWithValue(@"nome", clienteDAL.Nome);
                cmd.Parameters.AddWithValue(@"tipo_documento", clienteDAL.Tipo_documento);
                cmd.Parameters.AddWithValue(@"rg", clienteDAL.Documento);
                cmd.Parameters.AddWithValue(@"cpf", clienteDAL.Cpf_cnpj);
                cmd.Parameters.AddWithValue(@"data_nascimento", clienteDAL.Data_nascimento);
                cmd.Parameters.AddWithValue(@"email", clienteDAL.Email);
                cmd.Parameters.AddWithValue(@"telefone", clienteDAL.Telefone);
                cmd.Parameters.AddWithValue(@"endereco", clienteDAL.Endereco);
                cmd.Parameters.AddWithValue(@"cidade", clienteDAL.Cidade);
                cmd.Parameters.AddWithValue(@"uf", clienteDAL.Uf);
                cmd.Parameters.AddWithValue(@"complemento", clienteDAL.Complemento);
                cmd.Parameters.AddWithValue(@"tipo_pessoa", clienteDAL.Tipo_pessoa);
                cmd.Parameters.AddWithValue(@"tipo_cliente", clienteDAL.Tipo_cliente);
                cmd.Parameters.AddWithValue(@"data_registro", clienteDAL.Data_registro);

                Acces.ExecuteNonQuery(cmd);

                sucesso = true;
            }
            catch (Exception ex)
            {
                sucesso = false;
                MessageBox.Show("Falha ao cadastrar Cliente! \n\r\n\r " + (ex.InnerException != null ? ex.InnerException.Message : ""), "1) " + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(sucesso);
        }
        public void Excluir(JOALHERIABLL.ProdutoBLL produtoBLL)
        {
            SqlCommand cmd = new SqlCommand("DELETE FROM JOALHERIA.PRODUTO WHERE IDPRODUTO = @IDPRODUTO", con.Conectar());

            cmd.Parameters.AddWithValue("@IDPRODUTO", produtoBLL.Idproduto);

            Acces.ExecuteNonQuery(cmd);
        }
        //BAIXAR ESTOQUE
        public void BaixarEstoque(JOALHERIABLL.ProdutoBLL produtoBLL)
        {
            SqlCommand cmd = new SqlCommand("UPDATE JOALHERIA.PRODUTO SET QUANTIDADE = QUANTIDADE - @QUANTIDADE WHERE IDPRODUTO = @IDPRODUTO", con.Conectar());

            cmd.Parameters.AddWithValue("@IDPRODUTO", produtoBLL.Idproduto);
            cmd.Parameters.AddWithValue("@QUANTIDADE", produtoBLL.Quantidade);
            Acces.ExecuteNonQuery(cmd);
        }
Exemple #5
0
        public void Alterar(JOALHERIABLL.LoginBLL loginBLL)
        {
            SqlCommand cmd = new SqlCommand("UPDATE JOALHERIA.LOGIN SET VALOR_CAIXA = @VALOR_CAIXA WHERE IDLOGIN = @IDLOGIN", con.Conectar());

            cmd.Parameters.AddWithValue(@"IDLOGIN", loginBLL.Idlogin);
            cmd.Parameters.AddWithValue(@"VALOR_CAIXA", loginBLL.Valor_caixa);

            Acces.ExecuteNonQuery(cmd);
        }
Exemple #6
0
        public static ClienteDAL GetById(int idcliente)
        {
            ClienteDAL result = new ClienteDAL();
            SqlCommand cmd    = new SqlCommand("select * from JOALHERIA.CLIENTE where IDCLIENTE = '" + idcliente + "';");
            DataTable  dt     = Acces.ExecuteReader(cmd).Tables[0];

            if (dt.Rows.Count > 0)
            {
                result = new ClienteDAL(dt.Rows[0]);
            }
            return(result);
        }
Exemple #7
0
        public static List <Pessoa> ListarClientes()
        {
            List <Pessoa> result = new List <Pessoa>();

            SqlCommand cmd = new SqlCommand("select * from JOALHERIA.CLIENTE");

            foreach (DataRow cliente in Acces.ExecuteReader(cmd).Tables[0].Rows)
            {
                result.Add(new ClienteDAL(cliente));
            }
            return(result);
        }
Exemple #8
0
        public List <UsuarioBLL> ListarTodosUsuarios()
        {
            List <UsuarioBLL> result = new List <UsuarioBLL>();
            SqlCommand        cmd    = new SqlCommand("SELECT * FROM JOALHERIA.USUARIO", con.Conectar());

            foreach (DataRow row in Acces.ExecuteReader(cmd).Tables[0].Rows)
            {
                result.Add(new UsuarioBLL(row));
            }

            con.Desconectar();
            return(result);
        }
        public static JOALHERIABLL.ProdutoBLL GetById(int id)
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM JOALHERIA.PRODUTO WHERE IDPRODUTO = '" + id + "';");

            JOALHERIABLL.ProdutoBLL produto = new JOALHERIABLL.ProdutoBLL();
            DataTable result = Acces.ExecuteReader(cmd).Tables[0];

            foreach (DataRow row in result.Rows)
            {
                produto = new JOALHERIABLL.ProdutoBLL(row);
            }
            return(produto);
        }
Exemple #10
0
        //METODO CADASTRAR
        public int Cadastrar_Login(JOALHERIABLL.LoginBLL loginBLL)
        {
            SqlCommand cmd = new SqlCommand("INSERT INTO JOALHERIA.LOGIN (IDCAIXA, IDUSUARIO, USUARIO, DATA_LOGIN, VALOR_CAIXA) VALUES (@IDCAIXA, @IDUSUARIO, @USUARIO, @DATA_LOGIN, @VALOR_CAIXA);SELECT SCOPE_IDENTITY();");

            cmd.Parameters.AddWithValue(@"IDCAIXA", loginBLL.Idcaixa);
            cmd.Parameters.AddWithValue(@"IDUSUARIO", loginBLL.Idusuario);
            cmd.Parameters.AddWithValue(@"USUARIO", loginBLL.Usuario);
            cmd.Parameters.AddWithValue(@"DATA_LOGIN", loginBLL.Data_login);
            cmd.Parameters.AddWithValue(@"VALOR_CAIXA", loginBLL.Valor_caixa);

            int chave_gerada = Acces.ExecuteScalar(cmd);

            return(chave_gerada);
        }
        public void Alterar(JOALHERIABLL.ProdutoBLL produtoBLL)
        {
            SqlCommand cmd = new SqlCommand("UPDATE JOALHERIA.PRODUTO SET IDCATEGORIA = @IDCATEGORIA, DESCRICAO = @DESCRICAO, QUANTIDADE = @QUANTIDADE, PRECOIMPORTADO = @PRECOIMPORTADO, PRECOVENDA = @PRECOVENDA, LUCRO = @LUCRO, OBSERVACOES = @OBSERVACOES, IMAGEM = @IMAGEM WHERE IDPRODUTO = @IDPRODUTO", con.Conectar());

            cmd.Parameters.AddWithValue("@IDPRODUTO", produtoBLL.Idproduto);
            cmd.Parameters.AddWithValue("@IDCATEGORIA", produtoBLL.Idcategoria);
            cmd.Parameters.AddWithValue("@DESCRICAO", produtoBLL.Descricao);
            cmd.Parameters.AddWithValue("@QUANTIDADE", produtoBLL.Quantidade);
            cmd.Parameters.AddWithValue("@PRECOIMPORTADO", produtoBLL.Precoimportado);
            cmd.Parameters.AddWithValue("@PRECOVENDA", produtoBLL.Precovenda);
            cmd.Parameters.AddWithValue("@LUCRO", produtoBLL.Lucro);
            cmd.Parameters.AddWithValue("@OBSERVACOES", produtoBLL.Observacoes);
            cmd.Parameters.AddWithValue("@IMAGEM", produtoBLL.Imagem);

            Acces.ExecuteNonQuery(cmd);
        }
        public void Cadastrar(JOALHERIABLL.ProdutoBLL produtoBLL)
        {
            string     comand  = "INSERT INTO JOALHERIA.PRODUTO (IDCATEGORIA, DESCRICAO, QUANTIDADE, PRECOIMPORTADO, PRECOVENDA, LUCRO, OBSERVACOES, IMAGEM) VALUES (@IDCATEGORIA, @DESCRICAO, @QUANTIDADE, @PRECOIMPORTADO, @PRECOVENDA, @LUCRO, @OBSERVACOES, @IMAGEM)";
            SqlCommand command = new SqlCommand(comand);

            command.Parameters.AddWithValue("@IDCATEGORIA", produtoBLL.Idcategoria);
            command.Parameters.AddWithValue("@DESCRICAO", produtoBLL.Descricao);
            command.Parameters.AddWithValue("@QUANTIDADE", produtoBLL.Quantidade);
            command.Parameters.AddWithValue("@PRECOIMPORTADO", produtoBLL.Precoimportado);
            command.Parameters.AddWithValue("@PRECOVENDA", produtoBLL.Precovenda);
            command.Parameters.AddWithValue("@LUCRO", produtoBLL.Lucro);
            command.Parameters.AddWithValue("@OBSERVACOES", produtoBLL.Observacoes);
            command.Parameters.AddWithValue("@IMAGEM", produtoBLL.Imagem);

            Acces.ExecuteNonQuery(command);
        }
Exemple #13
0
        public static bool Delete_Client(int idcliente)
        {
            bool sucesso = false;

            try
            {
                SqlCommand cmd = new SqlCommand("DELETE FROM JOALHERIA.CLIENTE where IDCLIENTE = @idcliente;");
                cmd.Parameters.AddWithValue(@"idcliente", idcliente);

                Acces.ExecuteNonQuery(cmd);

                sucesso = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não foi possível excluir o cliente! \n\r\n\r" + (ex.InnerException != null ? ex.InnerException.Message : ""), "1) " + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                sucesso = false;
            }
            return(sucesso);
        }
        public static List <JOALHERIABLL.ProdutoBLL> ListarProdutos()
        {
            List <JOALHERIABLL.ProdutoBLL> result = new List <JOALHERIABLL.ProdutoBLL>();
            string     query = "SELECT * FROM JOALHERIA.PRODUTO";
            SqlCommand cmd   = new SqlCommand(query);

            foreach (DataRow row in Acces.ExecuteReader(cmd).Tables[0].Rows)
            {
                result.Add(new JOALHERIABLL.ProdutoBLL(row));
            }

            if (result.Count > 0)
            {
                return(result);
            }

            else
            {
                return(new List <JOALHERIABLL.ProdutoBLL>());
            }
        }