internal async Task BorrarAsync(TipoGasto tipoGastos)
        {
            tipoGastos.Borrar();
            await TipoGastoService.Guardar(tipoGastos);

            await BuscarAsync();
        }
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            this.Datos.RaiseListChangedEvents = false;

            TipoGasto temp = _entity.Clone();

            temp.ApplyEdit();

            // do the save
            try
            {
                _entity = temp.Save();
                _entity.ApplyEdit();

                return(true);
            }
            catch (Exception ex)
            {
                PgMng.ShowInfoException(ex);
                return(false);
            }
            finally
            {
                this.Datos.RaiseListChangedEvents = true;
            }
        }
        internal async Task ModificarAsync(TipoGasto tipoGasto)
        {
            GastoTipoDetalleForm gastoTipoDetalleForm = new GastoTipoDetalleForm(tipoGasto);

            gastoTipoDetalleForm.ShowDialog();
            await BuscarAsync();
        }
            public static void adicionar(TipoGasto categoria)
            {
                SGFEntities db = new SGFEntities();

                db.TipoGasto.Add(categoria);
                db.SaveChanges();
            }
示例#5
0
        public async Task <IHttpActionResult> Create(TipoGasto tipoGasto)
        {
            try
            {
                var result = new AjaxResult();

                var tipoGastoTemp = await db.TipoGastos.Where(u => u.TipoGastoID == tipoGasto.TipoGastoID).FirstOrDefaultAsync();

                if (tipoGastoTemp == null)
                {
                    db.TipoGastos.Add(tipoGasto);
                    await db.SaveChangesAsync();

                    AddLog("", tipoGasto.TipoGastoID, tipoGasto);
                }
                else
                {
                    return(Ok(result.False("Spent Type already exists")));
                }


                return(Ok(result.True()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#6
0
 /// <summary>
 /// Obtiene una lista con todos los tipos dce gasto.
 /// Si no encuentra nada devuelve excepcion propia
 /// </summary>
 public List <TipoGasto> BuscarListTipoGasto()
 {
     BeginTransaction();
     try
     {
         DataTable dt = selectTipoGasto();
         if (dt == null || dt.Rows.Count == 0)
         {
             throw new ExcepcionPropia("No se han encontrado tipos de gastos");
         }
         List <TipoGasto> listTg = new List <TipoGasto>();
         foreach (DataRow row in dt.Rows)
         {
             TipoGasto tg = buscarTipoGasto(Convert.ToInt32(row["idtipo_gasto"]));
             listTg.Add(tg);
         }
         CommitTransaction();
         return(listTg);
     }
     catch (ExcepcionPropia myex)
     {
         RollbackTransaction();
         ControladorExcepcion.tiraExcepcion(myex.Message);
         return(null);
     }
     catch (Npgsql.NpgsqlException myex)
     {
         RollbackTransaction();
         ControladorExcepcion.tiraExcepcion(myex.Message);
         return(null);
     }
 }
示例#7
0
 private void dgTipoGasto_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     EjecutarAsync(async() =>
     {
         TipoGasto tipoGasto = (TipoGasto)dgTipoGasto.CurrentRow.DataBoundItem;
         await gastoTipoListadoViewModel.ModificarAsync(tipoGasto);
     });
 }
            public static void atualizar(int id, String nome)
            {
                SGFEntities db  = new SGFEntities();
                TipoGasto   cat = db.TipoGasto.SingleOrDefault(x => x.id == id);

                cat.nome = nome;
                db.SaveChanges();
            }
示例#9
0
 public TipoGastoViewModel(TipoGasto pai)
 {
     this.IncluirCommand = new Command(async() =>
     {
         // incluir nova entrada na agenda
         await pai.Navigation.PushAsync(new TipoGastoAdd());
     });
 }
示例#10
0
        public override int GetHashCode()
        {
            int hashCode = 13;

            hashCode = (hashCode * 7) + IdFactura.GetHashCode();
            hashCode = (hashCode * 7) + TipoGasto.GetHashCode();
            return(hashCode);
        }
        public ActionResult RemoverCategoriaDireto()
        {
            int       id        = Convert.ToInt32(Request.QueryString["cat"]);
            TipoGasto categoria = LAD.TipoGastoLAD.Pesquisar.id(id);

            LAD.TipoGastoLAD.delete(categoria);

            return(RedirectToAction("PlanilhaDeGastos", "Financeiro"));
        }
        public override void OpenAddForm()
        {
            TipoGastoAddForm form = new TipoGastoAddForm();

            AddForm(form);
            if (form.ActionResult == DialogResult.OK)
            {
                _entity = form.Entity;
            }
        }
        public ActionResult AdicionarCategoria(EditCategoriaView ecv)
        {
            TipoGasto categoria = new TipoGasto();

            categoria.nome       = ecv.categoriaNome;
            categoria.usuario_id = (int)Session["User"];

            LAD.TipoGastoLAD.adicionar(categoria);
            return(RedirectToAction("PlanilhaDeGastos", "Financeiro"));
        }
        public override void OpenEditForm()
        {
            TipoGastoEditForm form = new TipoGastoEditForm(ActiveOID);

            if (form.Entity != null)
            {
                AddForm(form);
                _entity = form.Entity;
            }
        }
        public ActionResult AdicionarCategoriaDireto()
        {
            TipoGasto categoria = new TipoGasto();

            categoria.nome       = Request.QueryString["cat"];
            categoria.usuario_id = (int)Session["User"];

            LAD.TipoGastoLAD.adicionar(categoria);
            return(RedirectToAction("PlanilhaDeGastos", "Financeiro"));
        }
示例#16
0
        // GET: TipoGasto/Details/5
        public async Task <ActionResult> Details(int id)
        {
            TipoGasto entidad = await _ctx.TipoGasto.FindAsync(id);

            if (entidad == null)
            {
                return(View("Error"));
            }
            TipoGastoViewModel vm = Mapper.Map <TipoGastoViewModel>(entidad);

            return(View("Create", vm));
        }
示例#17
0
        internal async Task Guardar(TipoGasto tipoGasto)
        {
            if (tipoGasto.Id == 0)
            {
                _context.TipoGasto.Add(tipoGasto);
            }
            else
            {
                _context.Entry(tipoGasto).State = EntityState.Modified;
            }

            await _context.SaveChangesAsync();
        }
示例#18
0
        public static Task Guardar(TipoGasto tipoGasto)
        {
            TipoGastoValidador validador          = new TipoGastoValidador();
            ValidationResult   validadorResultado = validador.Validate(tipoGasto);

            if (!validadorResultado.IsValid)
            {
                throw new NegocioException(string.Join(Environment.NewLine, validadorResultado.Errors.Select(x => x.ErrorMessage)));
            }

            TipoGastoRepository tipoGastoRepository = new TipoGastoRepository(new Context());

            return(tipoGastoRepository.Guardar(tipoGasto));
        }
        // GET: /TipoGasto/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TipoGasto tipogasto = db.TipoGastos.Find(id);

            if (tipogasto == null)
            {
                return(HttpNotFound());
            }
            return(View(tipogasto));
        }
        public override void UpdateList()
        {
            switch (_current_action)
            {
            case molAction.Add:
                if (_entity == null)
                {
                    return;
                }
                List.AddItem(_entity.GetInfo(false));
                if (FilterType == IFilterType.Filter)
                {
                    TipoGastoList listA = TipoGastoList.GetList(_filter_results);
                    listA.AddItem(_entity.GetInfo(false));
                    _filter_results = listA.GetSortedList();
                }
                break;

            case molAction.Edit:
            case molAction.Unlock:
                if (_entity == null)
                {
                    return;
                }
                ActiveItem.CopyFrom(_entity);
                break;

            case molAction.Delete:
                if (ActiveItem == null)
                {
                    return;
                }
                List.RemoveItem(ActiveOID);
                if (FilterType == IFilterType.Filter)
                {
                    TipoGastoList listD = TipoGastoList.GetList(_filter_results);
                    listD.RemoveItem(ActiveOID);
                    _filter_results = listD.GetSortedList();
                }
                break;
            }

            RefreshSources();
            if (_entity != null)
            {
                Select(_entity.Oid);
            }
            _entity = null;
        }
示例#21
0
        /// <summary>
        /// Obtiene un tipo gasto. Si no lo encuentra devuelve excepcpion propia
        /// </summary>
        /// <param name="idTipoGasto"></param>
        /// <returns></returns>
        private TipoGasto buscarTipoGasto(int idTipoGasto)
        {
            DataTable dt = selectTipoGasto(idTipoGasto);

            if (dt == null || dt.Rows.Count == 0)
            {
                throw new ExcepcionPropia("No se ha encontrado el tipo gasto");
            }
            DataRow   row = dt.Rows[0];
            TipoGasto tg  = new TipoGasto();

            tg.Descripcion = row["descripcion"].ToString();
            tg.IdTipoGasto = Convert.ToInt32(row["idtipo_gasto"]);
            return(tg);
        }
示例#22
0
 private void dgTipoGasto_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     EjecutarAsync(async() =>
     {
         TipoGasto tipoGasto = (TipoGasto)dgTipoGasto.CurrentRow.DataBoundItem;
         if (dgTipoGasto.Columns[e.ColumnIndex].Name == "Editar")
         {
             await gastoTipoListadoViewModel.ModificarAsync(tipoGasto);
         }
         if (dgTipoGasto.Columns[e.ColumnIndex].Name == "Eliminar")
         {
             if (DialogResult.Yes == CustomMessageBox.ShowDialog(Resources.eliminarElemento, this.Text, MessageBoxButtons.YesNo, CustomMessageBoxIcon.Info))
             {
                 await gastoTipoListadoViewModel.BorrarAsync(tipoGasto);
             }
         }
     });
 }
示例#23
0
        public async Task <IHttpActionResult> Edit(TipoGasto tipoGasto)
        {
            try
            {
                var result = new AjaxResult();

                db.Entry(tipoGasto).State = EntityState.Modified;
                await db.SaveChangesAsync();

                AddLog("", tipoGasto.TipoGastoID, tipoGasto);

                return(Ok(result.True()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
            public static void delete(TipoGasto categoria)
            {
                SGFEntities db  = new SGFEntities();
                var         cat = db.TipoGasto.SingleOrDefault(x => x.id == categoria.id);

                foreach (Gasto gasto in cat.Gasto.ToList())
                {
                    foreach (Item item in gasto.Item.ToList())
                    {
                        var item1 = db.Item.SingleOrDefault(x => x.id == item.id);
                        db.Item.Remove(item1);
                    }
                    var gasto1 = db.Gasto.SingleOrDefault(x => x.id == gasto.id);
                    db.Gasto.Remove(gasto1);
                }

                db.TipoGasto.Remove(cat);

                db.SaveChanges();
            }
示例#25
0
        public ActionResult Update(TipoGastoViewModel vm)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("Create", vm));
                }

                TipoGasto entidad = Mapper.Map <TipoGasto>(vm);
                _ctx.Entry(entidad).State = System.Data.Entity.EntityState.Modified;
                _ctx.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Create", vm));
            }
        }
        public ActionResult DeleteConfirmed(long id)
        {
            TipoGasto tipogasto = db.TipoGastos.Find(id);
            // Validar que el pago no tenga el tipo de gasto asociado
            bool tipoGastoExisteEnRelaciones = false;

            tipoGastoExisteEnRelaciones = db.Pagos.Where(x => x.TipoGastoID == tipogasto.TipoGastoID).FirstOrDefault() == null ? false :true;
            if (tipoGastoExisteEnRelaciones)
            {
                ModelState.AddModelError(string.Empty, "El tipo de gasto " + tipogasto.Nombre + " esta siendo usado, no se puede eliminar.");
                return(View(tipogasto));
            }
            else
            {
                //db.TipoGastos.Remove(tipogasto);
                tipogasto.EsActivo        = false;
                db.Entry(tipogasto).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Edit([Bind(Include = "TipoGastoID,Nombre,EsActivo")] TipoGasto tipogasto)
        {
            // Validar si nombre existe
            bool existeTipoGasto = false;

            if (db.TipoGastos.Any() && !string.IsNullOrEmpty(tipogasto.Nombre))
            {
                existeTipoGasto = db.TipoGastos.Where(x => x.Nombre == tipogasto.Nombre && x.TipoGastoID != tipogasto.TipoGastoID).FirstOrDefault() == null ? false : true;
                if (existeTipoGasto)
                {
                    ModelState.AddModelError(string.Empty, "Existe el tipo de gasto con nombre: " + tipogasto.Nombre + ", ingrese otro nombre.");
                }
            }
            if (ModelState.IsValid)
            {
                db.Entry(tipogasto).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(tipogasto));
        }
示例#28
0
 /// <summary>
 /// Obtiene un tipo gasto si no encuentra nada devuelve excepcion propia
 /// </summary>
 /// <param name="idTipoGasto"></param>
 /// <returns></returns>
 public TipoGasto BuscarTipoGasto(int idTipoGasto)
 {
     BeginTransaction();
     try
     {
         TipoGasto tg = buscarTipoGasto(idTipoGasto);
         CommitTransaction();
         return(tg);
     }
     catch (ExcepcionPropia myex)
     {
         RollbackTransaction();
         ControladorExcepcion.tiraExcepcion(myex.Message);
         return(null);
     }
     catch (Npgsql.NpgsqlException myex)
     {
         RollbackTransaction();
         ControladorExcepcion.tiraExcepcion(myex.Message);
         return(null);
     }
 }
        public List <TipoGasto> listaTiposGastos(string schema)
        {
            List <TipoGasto>  listaTiposGastos = new List <TipoGasto>();
            NpgsqlConnection  conexion         = null;
            NpgsqlCommand     cmd  = null;
            NpgsqlTransaction tran = null;
            NpgsqlDataReader  dr   = null;

            try
            {
                conexion        = Conexion.getInstance().ConexionDB();
                cmd             = new NpgsqlCommand("logueo.spgettiposgastos", conexion);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("parm_schema", schema);
                conexion.Open();
                tran = conexion.BeginTransaction();
                dr   = cmd.ExecuteReader();
                while (dr.Read())
                {
                    TipoGasto tipoGasto = new TipoGasto();
                    tipoGasto.id        = Convert.ToInt32(dr["ID"].ToString());
                    tipoGasto.nombre    = dr["DESCRIPCION"].ToString();
                    tipoGasto.es_activo = Convert.ToBoolean(dr["ESACTIVO"].ToString());
                    listaTiposGastos.Add(tipoGasto);
                }
                dr.Close();
            }
            catch (Exception e)
            {
                listaTiposGastos = null;
                throw (e);
            }
            finally
            {
                tran.Commit();
                conexion.Close();
            }
            return(listaTiposGastos);
        }
示例#30
0
        public ActionResult DeleteConfirmed(string[] ids)
        {
            try
            {
                TipoGasto tipoGasto = db.TipoGastos.Find(ids);
                db.TipoGastos.Remove(tipoGasto);
                db.SaveChanges();

                //Auditoria
                Seguridad.Seguridad seguridad    = new Seguridad.Seguridad();
                Auditoria           auditoria    = new Auditoria();
                Seguridadcll        seguridadcll = (Seguridadcll)Session["seguridad"];

                auditoria.AuditoriaFecha  = System.DateTime.Now;
                auditoria.AuditoriaHora   = System.DateTime.Now.TimeOfDay;
                auditoria.usuarioId       = seguridadcll.Usuario.UsuarioId;
                auditoria.AuditoriaEvento = "Eliminar";
                auditoria.AuditoriaDesc   = "Eliminó TipoGasto: " + tipoGasto.TipoGastoID;
                auditoria.ObjetoId        = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString();

                seguridad.insertAuditoria(auditoria);
                //Auditoria
            }
            catch (Exception e)
            {
                var tipoGastos = db.TipoGastos.Find(ids);
                if (tipoGastos == null)
                {
                    ViewBag.Error = "Advertencia, Registro no encontrado o Invalido " + ids;
                }
                else
                {
                    ViewBag.Error = e.ToString();
                }
            }
            return(RedirectToAction("Index"));
        }
示例#31
0
        private void btnGrabar_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                //MessageBox.Show("nombre: " + txtNombre.Text + "clave: " + txtClave.Text + "Año: " + Canio.Text + "Vigencia: " + CHvigente.IsChecked);

                if (txtNombre.Text == "")
                {
                    MessageBox.Show("Ingresar Nombre");
                }
                else if (txtClave.Text == "")
                {
                    MessageBox.Show("Ingresar Clave");
                }
                else if (Canio.Text == "")
                {
                    MessageBox.Show("Ingresar Año");
                }
                else if (CHvigente.IsChecked == false)
                {
                    MessageBox.Show("La vigencia esta Desactivada");
                }
                else
                {
                    Table<TipoGasto> tablaTG = con2.GetTable<TipoGasto>();
                    TipoGasto tTG = new TipoGasto();
                    tTG.idTG = 0;
                    tTG.nombreTG = txtNombre.Text;
                    tTG.clavePresupuestal = txtClave.Text;
                    tTG.anioAplica = Convert.ToInt32(Canio.Text);
                    tTG.fechaReg = Convert.ToDateTime(fechRegistro);
                    tTG.idEmpleado = id_Empleado;
                    tTG.vigente = CHvigente.IsChecked;
                    tablaTG.InsertOnSubmit(tTG);
                    tablaTG.Context.SubmitChanges();
                    octipGasto.Clear();
                    llenarTabla();
                    MessageBox.Show("Se Inserto Correctamente");

                }
            }
            catch (Exception Ex)
            {

                MessageBox.Show(Ex.Message);

                return;

            }
        }