public JsonResult JsCreate(ProdutoMaterial model)
        {
            try
            {
                LogBLL.Insert(new LogDado("JsCreate", "ProdutoMaterial", _idUsuario));
                using (var db = new Context())
                {
                    using (var trans = new RP.DataAccess.RPTransactionScope(db))
                    {
                        var _bll = new BLL.ProdutoMaterialBLL(db, _idUsuario);
                        var _produtoBLL = new BLL.ProdutoBLL(db, _idUsuario);

                        _bll.Insert(model);
                        _bll.SaveChanges();
                        trans.Complete();

                        decimal totalCusto = model.quantidade * model.valor;
                        decimal totalGanho = ((model.margemGanho / 100) * totalCusto) + totalCusto;
                        decimal totalLiquido = totalGanho - totalCusto;
                        var result = new
                        {
                            idMaterial = model.idMaterial,
                            idProduto = model.idProduto,
                            model.quantidade,
                            model.margemGanho,
                            model.valor,
                            model.Material.nome,
                            model.idProdutoMaterial,
                            totalCusto = totalCusto,
                            totalGanho = totalGanho,
                            totalLiquido = totalLiquido
                        };

                        return Json(new { model = result }, JsonRequestBehavior.AllowGet);
                    }
                }
            }

            catch (Exception ex)
            {
                Response.StatusCode = 500;
                return Json(RP.Util.Exception.Message.Get(ex), JsonRequestBehavior.AllowGet);
            }
        }
        public JsonResult JsDelete(int idProdutoMaterial)
        {
            try
            {
                LogBLL.Insert(new LogDado("JsDelete", "ProdutoMaterial", _idUsuario));
                using (var db = new Context())
                {
                    using (var trans = new RP.DataAccess.RPTransactionScope(db))
                    {
                        var _bll = new BLL.ProdutoMaterialBLL(db, _idUsuario);

                        _bll.Delete(u => u.idProdutoMaterial == idProdutoMaterial);
                        _bll.SaveChanges();

                        trans.Complete();

                        return Json(new { msg = "Item removido com sucesso!" }, JsonRequestBehavior.AllowGet);
                    }
                }
            }

            catch (Exception ex)
            {
                Response.StatusCode = 500;
                return Json(RP.Util.Exception.Message.Get(ex), JsonRequestBehavior.AllowGet);
            }
        }