private void Buscar()
    {
        DataTable dataTable = new DataTable();
        Retiro    retiro;

        Ocultar();
        retiro = new Retiro(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        try
        {
            dataTable = retiro.Consultar(TextBox_BUSCAR.Text);

            if (dataTable.Rows.Count > 0)
            {
                GridView_RESULTADOS_BUSQUEDA.DataSource = dataTable;
                GridView_RESULTADOS_BUSQUEDA.DataBind();
                Mostrar(Acciones.Encontrar);
            }
            else
            {
                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "No se encontró información para " + this.DropDownList_BUSCAR.SelectedItem + " : " + this.TextBox_BUSCAR.Text, Proceso.Advertencia);
            }
        }
        catch (Exception e)
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, e.Message, Proceso.Error);
        }
        if (dataTable == null)
        {
            dataTable.Dispose();
        }
    }
Beispiel #2
0
        private void txtValor_TextChanged(object sender, EventArgs e)
        {
            Retiro a = (Retiro)modelo;

            try { a.Validar(txtValor.Text, "Valor"); }
            catch (Exception ex) { MessageBox.Show(modelo.exibirMensagemErro(ex, 2)); }
        }
Beispiel #3
0
        private void txtLocal_TextChanged(object sender, EventArgs e)
        {
            Retiro a = (Retiro)modelo;

            try { a.Local = txtLocal.Text; }
            catch (Exception ex) { MessageBox.Show(modelo.exibirMensagemErro(ex, 2)); }
        }
Beispiel #4
0
        private void FrmCadastrarRetiro_Load(object sender, EventArgs e)
        {
            var form = "Retiro";

            if (CondicaoAtualizar)
            {
                this.Text = "Atualizar registro - " + form;
            }
            if (CondicaoDeletar)
            {
                this.Text = "Deletar registro - " + form;
            }
            if (CondicaoDetalhes)
            {
                this.Text = "Detalhes registro - " + form;
            }
            if (!CondicaoDeletar && !CondicaoAtualizar && !CondicaoDetalhes)
            {
                this.Text = "Cadastro - " + form;
            }

            Retiro a = (Retiro)modelo;

            try { txtValor.Text = a.Valor.ToString(); }
            catch (Exception ex) { MessageBox.Show(modelo.exibirMensagemErro(ex, 2)); }
            try { checkBoxPagou.Checked = a.Pago; }
            catch (Exception ex) { MessageBox.Show(modelo.exibirMensagemErro(ex, 2)); }
            try { txtLocal.Text = a.Local; }
            catch (Exception ex) { MessageBox.Show(modelo.exibirMensagemErro(ex, 2)); }
        }
    protected void Button_RevertirRetiro_Click(object sender, EventArgs e)
    {
        decimal idEmpleado = Convert.ToDecimal(TextBox_id_empleado.Text);

        Retiro _r = new Retiro(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

        DataTable _tablaResultado = _r.ReversarRetiroTemporal(idEmpleado);

        if (String.IsNullOrEmpty(_r.MensajeError) == false)
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, _r.MensajeError, Proceso.Error);
        }
        else
        {
            DataRow filaResultado = _tablaResultado.Rows[0];

            if (filaResultado["TIPO"].ToString().ToUpper() == "ERROR")
            {
                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, filaResultado["MENSAJE"].ToString(), Proceso.Advertencia);
            }
            else
            {
                Limpiar();
                Bloquear();
                Cargar(idEmpleado);

                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, filaResultado["MENSAJE"].ToString(), Proceso.Correcto);
            }
        }
    }
        public IHttpActionResult Create(Retiro retiros)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }



            _UnityOfWork.Retiros.Add(retiros);

            try
            {
                _UnityOfWork.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (RetiroExists(retiros.RetiroId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = retiros.RetiroId }, retiros));
        }
Beispiel #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationUserId,Date,Monto,Detalles")] Retiro retiro)
        {
            if (id != retiro.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(retiro);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RetiroExists(retiro.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(retiro));
        }
Beispiel #8
0
 public IActionResult SaveRetiro([FromBody] Retiro retiro)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (retiro.IdRetiro == 0)
             {
                 PosUoW.RetirosRepository.Add(retiro);
             }
             else
             {
                 PosUoW.RetirosRepository.Update(retiro);
             }
             PosUoW.Save();
             return(Ok(retiro));
         }
         else
         {
             return(BadRequest("Error al guardar el retiro"));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex));
     }
 }
Beispiel #9
0
        public IHttpActionResult Create(Retiro Retiro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            //var floreria = Mapper.Map<FloreriaDto, Florerias>(floreriaDTO);

            _UnityOfWork.Retiro.Add(Retiro);

            try
            {
                _UnityOfWork.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (RetiroExists(Retiro.RetiroId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = Retiro.RetiroId }, Retiro));
        }
Beispiel #10
0
        public IHttpActionResult PutRetiro(int id, Retiro retiro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != retiro.RetiroId)
            {
                return(BadRequest());
            }

            _UnityOfWork.StateModified(retiro);


            try
            {
                _UnityOfWork.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RetiroExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
    private void Actualizar()
    {
        Retiro   retiro;
        DateTime fecha = new DateTime();

        Decimal idEmpleado = Convert.ToDecimal(TextBox_id_empleado.Text);

        retiro = new Retiro(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        try
        {
            if (retiro.Actualizar(idEmpleado, string.IsNullOrEmpty(TextBox_fecha_retiro.Text)? fecha:Convert.ToDateTime(TextBox_fecha_retiro.Text), TextBox_notas.Text, DropDownList_estado.SelectedValue, TextBox_carpeta.Text))
            {
                Limpiar();
                Bloquear();
                Cargar(idEmpleado);

                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "El retiro fue actualizado correctamente.", Proceso.Correcto);
            }
            else
            {
                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "Se genero un error al intentar actualizar el retiro.", Proceso.Error);
            }
        }

        catch (Exception e)
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, e.Message, Proceso.Error);
        }
    }
Beispiel #12
0
        public Retiro Extraer(ExtraccionDto model)
        {
            var tarjeta = this.tarjetaRepository.GetByNumeroTarjeta(model.NumeroTarjeta);

            if (tarjeta != null)
            {
                if (tarjeta.Monto < model.Monto)
                {
                    throw new Exception("El monto a extraer excede el monto actual de la tarjeta.");
                }
                else
                {
                    var nuevoRetiro = new Retiro()
                    {
                        Monto       = model.Monto,
                        FechaRetiro = DateTime.Now,
                        TarjetaId   = tarjeta.Id
                    };

                    var retiroAgregado = this.Add(nuevoRetiro);

                    tarjeta.Monto -= model.Monto;

                    this.tarjetaRepository.Update(tarjeta);

                    return(retiroAgregado);
                }
            }
            else
            {
                throw new Exception("La tarjeta no existe en el sistema.");
            }
        }
Beispiel #13
0
        public async Task <ActionResult <StandardResponse> > Retiro(Retiro retiro)
        {
            Tarjeta tarjeta = await _context.Tarjeta.Where(b => b.TarjetaId == retiro.TarjetaId).FirstOrDefaultAsync();

            if (tarjeta == null)
            {
                return(NotFound());
            }
            long?cuentaOrigen;

            if (retiro.tipoCuenta.Equals("A"))
            {
                cuentaOrigen = tarjeta.CuentaBancariaAhorroId;
            }
            else
            {
                cuentaOrigen = tarjeta.CuentaBancariaId;
            }
            CuentaBancaria cuentaBancariaOrigen = await _context.CuentaBancaria.Where(b => b.CuentaBancariaId == cuentaOrigen).FirstOrDefaultAsync();

            if (cuentaBancariaOrigen == null)
            {
                return(NotFound());
            }
            StandardResponse standardResponse = new StandardResponse();

            if ((cuentaBancariaOrigen.Saldo - retiro.Monto) < 0)
            {
                standardResponse.Code    = 200;
                standardResponse.Message = "Saldo Insuficiente";
                standardResponse.data    = tarjeta.TarjetaId.ToString();
                return(Ok(standardResponse));
            }
            cuentaBancariaOrigen.Saldo -= retiro.Monto;
            _context.Entry(cuentaBancariaOrigen).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
            //Guarda Bitacora
            long     cuenta   = tarjeta.CuentaBancariaId;
            Bitacora bitacora = new Bitacora();

            bitacora.CuentaBancariaDestino = cuenta;
            bitacora.CuentaBancariaOrigen  = cuenta;
            bitacora.Monto = retiro.Monto;
            _context.Bitacora.Add(bitacora);
            await _context.SaveChangesAsync();

            //Devuuelve Respuesta
            standardResponse.Code    = 200;
            standardResponse.Message = "Retiro Exitoso";
            standardResponse.data    = tarjeta.TarjetaId.ToString();
            return(Ok(standardResponse));
        }
Beispiel #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            Retiro retiro = db.Retiro.Find(id);

            db.Retiro.Remove(retiro);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Retiro retiro = _UnityOfWork.Retiros.Get(id);

            _UnityOfWork.Retiros.Remove(retiro);
            _UnityOfWork.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #16
0
        public async Task <bool> RetirarAsync(Retiro retiro)
        {
            var myTask = Task.Run(() => retiro.retirar());

            bool result = await myTask;

            return(result);
        }
Beispiel #17
0
        public IHttpActionResult GetRetiro(int id)
        {
            Retiro retiro = _UnityOfWork.Retiro.Get(id);

            if (retiro == null)
            {
                return(NotFound());
            }

            return(Ok(retiro));
        }
        public IHttpActionResult GetRetiro(int id)
        {
            Retiro retiro = db.Retiro.Find(id);

            if (retiro == null)
            {
                return(NotFound());
            }

            return(Ok(retiro));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            //Retiro retiro = db.Retiro.Find(id);
            Retiro retiro = (Retiro)_UnityOfWork.Retiro.Get(id);

            //db.Retiro.Remove(retiro);
            _UnityOfWork.Retiro.Delete(retiro);
            //db.SaveChanges();
            _UnityOfWork.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "RetiroId")] Retiro retiro)
 {
     if (ModelState.IsValid)
     {
         _UnityOfWork.StateModified(retiro);
         //db.SaveChanges();
         _UnityOfWork.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(retiro));
 }
        public IHttpActionResult PostRetiro(Retiro retiro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Retiro.Add(retiro);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = retiro.idRetiro }, retiro));
        }
Beispiel #22
0
 public ActionResult Edit([Bind(Include = "retiroId,fechaRetiro,montoRetiro,atmId,dispensadorEfectivoId")] Retiro retiro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(retiro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.atmId = new SelectList(db.Atm, "atmId", "desAtm", retiro.atmId);
     ViewBag.dispensadorEfectivoId = new SelectList(db.DispensadorEfectivos, "dispensadorEfectivoId", "ubicacion", retiro.dispensadorEfectivoId);
     return(View(retiro));
 }
 public ActionResult Edit([Bind(Include = "RetiroId,Monto,DescRetiro,FechaRetiro,ATMId,CuentaId")] Retiro retiro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(retiro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ATMId    = new SelectList(db.ATMs, "ATMId", "DescATM", retiro.ATMId);
     ViewBag.CuentaId = new SelectList(db.Cuentas, "CuentaId", "DescCuenta", retiro.CuentaId);
     return(View(retiro));
 }
Beispiel #24
0
 public ActionResult Edit([Bind(Include = "idRetiro,Monto,DNIPersona,NombrePersona,idATM,idCuenta")] Retiro retiro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(retiro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idATM    = new SelectList(db.ATM, "idATM", "Direccion", retiro.idATM);
     ViewBag.idCuenta = new SelectList(db.Cuenta, "idCuenta", "idCuenta", retiro.idCuenta);
     return(View(retiro));
 }
Beispiel #25
0
        private void checkBoxPagou_CheckedChanged(object sender, EventArgs e)
        {
            Retiro a = (Retiro)modelo;

            if (checkBoxPagou.Checked)
            {
                a.Pago = true;
            }
            else
            {
                a.Pago = false;
            }
        }
        public IHttpActionResult DeleteRetiro(int id)
        {
            Retiro retiro = db.Retiro.Find(id);

            if (retiro == null)
            {
                return(NotFound());
            }

            db.Retiro.Remove(retiro);
            db.SaveChanges();

            return(Ok(retiro));
        }
Beispiel #27
0
        public IHttpActionResult DeleteRetiro(int id)
        {
            Retiro retiro = _UnityOfWork.Retiro.Get(id);

            if (retiro == null)
            {
                return(NotFound());
            }

            _UnityOfWork.Retiro.Remove(retiro);
            _UnityOfWork.SaveChanges();

            return(Ok(retiro));
        }
        // GET: Retiros/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Retiro retiro = _UnityOfWork.Retiros.Get(id);

            if (retiro == null)
            {
                return(HttpNotFound());
            }
            return(View(retiro));
        }
Beispiel #29
0
        // GET: Retiroes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Retiro retiro = db.Retiro.Find(id);

            if (retiro == null)
            {
                return(HttpNotFound());
            }
            return(View(retiro));
        }
 public ActionResult Edit([Bind(Include = "RetiroId,Monto")] Retiro retiro)
 {
     if (ModelState.IsValid)
     {
         _UnityOfWork.StateModified(retiro);
         _UnityOfWork.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RetiroId = new SelectList(_UnityOfWork.ATMs.GetEntity(), "AtmId", "Mensaje", retiro.RetiroId);
     ViewBag.RetiroId = new SelectList(_UnityOfWork.BaseDatos.GetEntity(), "BaseDatosId", "Administrador", retiro.RetiroId);
     ViewBag.RetiroId = new SelectList(_UnityOfWork.DispensadorEfectivos.GetEntity(), "DispensadorefectivoId", "DispensadorefectivoId", retiro.RetiroId);
     ViewBag.RetiroId = new SelectList(_UnityOfWork.Pantallas.GetEntity(), "PantallaId", "PantallaId", retiro.RetiroId);
     ViewBag.RetiroId = new SelectList(_UnityOfWork.Teclados.GetEntity(), "TecladoId", "Marca", retiro.RetiroId);
     return(View(retiro));
 }