public JObject CarregarDespesa(int codDespesa)
        {
            JObject    obj    = new JObject();
            JArray     arr    = new JArray();
            DespesaDAL desDAL = new DespesaDAL(db);

            MLL.Despesa despesa = desDAL.obtemPorId(codDespesa);

            if (!object.Equals(despesa, null))
            {
                arr.Add(new JObject(
                            new JProperty("Codigo_Despesa", despesa.Codigo_Despesa),
                            new JProperty("Descricao_Despesa", despesa.Descricao_Despesa),
                            new JProperty("Valor_Despesa", despesa.Valor_Despesa),
                            new JProperty("Status_Despesa", despesa.Status.Description()),
                            new JProperty("Forma_Pagamento_Despesa", despesa.Codigo_Pagamento),
                            new JProperty("Codigo_Vigencia_Despesa", despesa.Codigo_Vigencia),
                            new JProperty("Codigo_Usuario_Despesa", despesa.Codigo_Usuario)
                            ));

                obj.Add(new JProperty("listaDespesa", arr));
            }
            else
            {
                obj.Add(new JProperty("erro", desDAL.erro));
            }

            return(obj);
        }
        public JObject CadastrarDespesa(string objDespesa)
        {
            JObject obj = new JObject();
            JArray  arr = JArray.Parse(objDespesa);

            DespesaDAL desDAL = new DespesaDAL(db);

            string descricao   = arr[0].Value <string>("Descricao_Despesa").ToString();
            string valor       = arr[0].Value <decimal>("Valor_Despesa").ToString();
            string status      = arr[0].Value <int>("Status_Despesa").ToString();
            string formapag    = arr[0].Value <int>("Forma_Pagamento_Despesa").ToString();
            string codvigencia = arr[0].Value <int>("Codigo_Vigencia_Despesa").ToString();
            string codusuario  = arr[0].Value <int>("Codigo_Usuario_Despesa").ToString();

            MLL.Despesa des = new MLL.Despesa
            {
                Descricao_Despesa = descricao,
                Valor_Despesa     = Convert.ToDecimal(valor),
                Status            = (MLL.Status)Convert.ToInt32(status),
                Codigo_Pagamento  = Convert.ToInt32(formapag),
                Codigo_Vigencia   = Convert.ToInt32(codvigencia),
                Codigo_Usuario    = Convert.ToInt32(codusuario)
            };

            if (desDAL.Adicionar(des))
            {
                obj.Add(new JProperty("ok", "ok"));
            }
            else
            {
                obj.Add(new JProperty("erro", desDAL.erro));
            }

            return(obj);
        }
Esempio n. 3
0
        public string ExcluirDespesa(int codigo)
        {
            DespesaBLL desBLL = new DespesaBLL();

            MLL.Despesa despesa = desBLL.ObterPorId(codigo);

            return(desBLL.ExcluirDespesa(despesa));
        }
        public string ExcluirDespesa(MLL.Despesa despesa)
        {
            DespesaDAL desDAL = new DespesaDAL(db);
            string     result = "";

            if (desDAL.Remover(despesa))
            {
                result = "ok";
            }
            else
            {
                result = "erro - " + desDAL.erro;
            }

            return(result);
        }