Beispiel #1
0
        public void Inicializado()
        {
            clienteDA    = new ClienteDA();
            alquilerDA   = new AlquilerDA();
            devolucionDA = new DevolucionDA();
            devolucion   = new Devolucion();

            detalleTemp           = new DevolucionDetalle();
            dtpFechaIngreso.Value = DateTime.Now;

            tablaCliente             = clienteDA.ListarClientes();
            cmbCliente.DataSource    = tablaCliente;
            cmbCliente.DisplayMember = "nombre_razonSocial";
            cmbCliente.ValueMember   = "idCliente";

            cmbCliente.SelectedIndex = 0;

            int i = cmbCliente.SelectedIndex;

            int idCliente = Convert.ToInt32(tablaCliente.Rows[i]["idCliente"].ToString());

            txtNroDocumento.Text = tablaCliente.Rows[i]["nroDocumento"].ToString();

            tablaLaptops = devolucionDA.ListarLaptopsClientesEstadoAlquilado(idCliente);

            ObtenerDatosDevolucion();
            devolucion.LlenarDatos(tablaLaptops);
            dgvLaptopsSeleccionados.PrimaryGrid.DataSource          = tablaLaptops;
            dgvLaptopsSeleccionados.PrimaryGrid.AutoGenerateColumns = false;
        }
Beispiel #2
0
        private void Inicilize()
        {
            conceptoMovInvController = new ConceptoMovInvController();
            devolucionpController    = new DevolucionpController();
            devolucionController     = new DevolucionController();
            proveedorController      = new ProveedorController();
            productoController       = new ProductoController();
            movInvController         = new MovInvController();
            loteController           = new LoteController();


            conceptoMovInv = null;
            devolucion     = null;
            partida        = null;
            proveedor      = null;
            producto       = null;
            lote           = null;

            //Listas
            partidas = new List <Devolucionp>();

            //Variables
            sobreGrid = false;
            Subtotal  = 0;
            Impuesto  = 0;
            CreaDevolucion();
        }
Beispiel #3
0
 private void txtBuscar_TextChanged(object sender, EventArgs e)
 {
     if (cmbCampo.SelectedIndex == 0)
     {
         //buscar por todos los campos de la tabla
         Devolucion D      = new Devolucion();
         string     buscar = '%' + txtBuscar.Text + '%';
         dgvHistorialDevolucion.DataSource = D.FiltrarDevolucionTC(buscar);
     }
     else
     {
         try
         {
             //buscar por un campo especifico de la tabla
             Devolucion D      = new Devolucion();
             string     buscar = '%' + txtBuscar.Text + '%';
             string     value  = cmbCampo.SelectedValue.ToString();
             dgvHistorialDevolucion.DataSource = D.FiltrarDevolucion(value, buscar);
         }
         catch (Exception ex)
         {
             MessageBox.Show("Ocurrio un error : " + ex + "", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #4
0
        public TransactionResult createP(DevolucionVo devolucion_vo, User user_log)
        {
            Devolucion devolucion = DevolucionAdapter.voToObject(devolucion_vo);

            devolucion.user = user_log;


            int id = devolucion_repository.createP(devolucion);

            if (id > 0)
            {
                var tr = TransactionResult.CREATED;
                foreach (RegistroDetalleDevVo rvo in devolucion_vo.registros)
                {
                    rvo.devolucion_id = id;
                    rvo.user_id       = devolucion.user.id;
                    tr = devolucion_repository.createRegistroDetalleDev(RegistroDetalleDevAdapter.voToObject(rvo));
                    if (tr != TransactionResult.CREATED)
                    {
                        return(tr);
                    }
                }
                return(tr);
            }
            return(TransactionResult.ERROR);
        }
        /// <summary>
        /// construye una devolucion y lo hace con los
        /// valores del prestamo para que haya concordancia con
        /// la fecha de prestamo
        /// </summary>
        /// <param name="libro"></param>
        /// <returns></returns>
        public Devolucion devolucion(Libro libro)
        {
            SqlConnection con        = new SqlConnection(Conexion.Cadena);
            Devolucion    devolucion = null;

            try
            {
                con.Open();
                string sql = "PA_tramitesSelect";

                SqlCommand comando = new SqlCommand(sql, con);
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@idLibro", libro.Codigo);

                SqlDataReader reader = comando.ExecuteReader();


                while (reader.Read())
                {
                    devolucion = new Devolucion();
                    devolucion.FechaPrestamo = Convert.ToDateTime(reader["fechaPrestamo"].ToString());
                    devolucion.Libro         = libro;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                con.Close();
            }
            return(devolucion);
        }
Beispiel #6
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,FechaDevolucion,PrecioFinal,AlquilerId")] Devolucion devolucion)
        {
            if (id != devolucion.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(devolucion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DevolucionExists(devolucion.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AlquilerId"] = new SelectList(_context.Alquileres, "Id", "Id", devolucion.AlquilerId);
            return(View(devolucion));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DevolucionID,PrestamoID,Fecha")] Devolucion devolucion)
        {
            if (id != devolucion.DevolucionID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(devolucion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DevolucionExists(devolucion.DevolucionID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PrestamoID"] = new SelectList(_context.Prestamo, "PrestamoID", "PrestamoID", devolucion.PrestamoID);
            return(View(devolucion));
        }
Beispiel #8
0
        private void ResetPDD()
        {
            //Listas
            partidas = new List <Devolucionp>();

            conceptoMovInv = null;
            devolucion     = null;
            partida        = null;
            proveedor      = null;
            producto       = null;
            lote           = null;

            //Variables
            sobreGrid = false;
            Subtotal  = 0;
            Impuesto  = 0;

            TxtConceptoMovInv.Text = "";
            TxtProveedor.Text      = "";
            TxtDocto.Text          = "";
            TxtFecha.Text          = DateTime.Now.ToString("dd-MM-yyyy");
            TxtProducto.Text       = "";
            TxtDescrip.Text        = "";
            TxtLote.Text           = "";
            TxtCaducidad.Text      = "";

            Malla.Rows.Clear();
            CreaDevolucion();
        }
        public static void agregarDevolucion(Devolucion devolucion)
        {
            SqlCommand sqlCommand = DataBase.ejecutarSP("404_NOT_FOUND.SP_AGREGAR_DEVOLUCION", buildParametrosDevolucion(devolucion));

            devolucion.id = Convert.ToInt32(sqlCommand.Parameters["@devolucion_id"].Value);

            agregarItemsDevolucion(devolucion);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Devolucion devolucion = db.Devolucion.Find(id);

            db.Devolucion.Remove(devolucion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #11
0
 private void btnCancelar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Estas seguro que deseas cancelar el proceso", "◄ AVISO | LEASEIN S.A.C. ►", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
     {
         estadoComponentes(TipoVista.Limpiar);
         devolucion = new Devolucion();
         dgvLaptopsSeleccionados.PrimaryGrid.DataSource = null;
     }
 }
Beispiel #12
0
 public ActionResult Guardar(Devolucion devolucion)
 {
     using (var db = new ModelProyecto())
     {
         db.Devolucion.Add(devolucion);
         db.SaveChanges();
     }
     return(Redirect("/Devoluciones/Index"));
 }
 public static void agregarItemsDevolucion(Devolucion devolucion)
 {
     foreach (int factura_numero in devolucion.getFacturasADevolver())
     {
         List <SqlParameter> parametros_item = new List <SqlParameter>();
         parametros_item.Add(new SqlParameter("@factura", factura_numero));
         parametros_item.Add(new SqlParameter("@devolucion_id", devolucion.id));
         DataBase.WriteInBase("404_NOT_FOUND.SP_AGREGAR_ITEM_DEVOLUCION", "SP", parametros_item);
     }
 }
Beispiel #14
0
        public bool InsertarDevolucionDetalle(Devolucion devolucion, string usuario)
        {
            bool error = false;

            foreach (DevolucionDetalle det in devolucion.Detalles)
            {
                parametrosEntrada     = new MySqlParameter[15];
                parametrosEntrada[0]  = new MySqlParameter("@_idDevolucion", MySqlDbType.Int32);
                parametrosEntrada[1]  = new MySqlParameter("@_idLC", MySqlDbType.Int32);
                parametrosEntrada[2]  = new MySqlParameter("@_codigoLC", MySqlDbType.VarChar, 255);
                parametrosEntrada[3]  = new MySqlParameter("@_marcaLC", MySqlDbType.VarChar, 255);
                parametrosEntrada[4]  = new MySqlParameter("@_modeloLC", MySqlDbType.VarChar, 255);
                parametrosEntrada[5]  = new MySqlParameter("@_pagaraCliente", MySqlDbType.Int32);
                parametrosEntrada[6]  = new MySqlParameter("@_danoLC", MySqlDbType.Int32);
                parametrosEntrada[7]  = new MySqlParameter("@_caracteristicas", MySqlDbType.VarChar, 255);
                parametrosEntrada[8]  = new MySqlParameter("@_estadoLC", MySqlDbType.Int32);
                parametrosEntrada[9]  = new MySqlParameter("@_observacion", MySqlDbType.VarChar, 100);
                parametrosEntrada[10] = new MySqlParameter("@_estado", MySqlDbType.Int32);
                parametrosEntrada[11] = new MySqlParameter("@_usuario_ins", MySqlDbType.VarChar, 100);
                parametrosEntrada[12] = new MySqlParameter("@_idSalidaDet", MySqlDbType.Int32);
                parametrosEntrada[13] = new MySqlParameter("@_idSucursal", MySqlDbType.Int32);
                parametrosEntrada[14] = new MySqlParameter("@_idDevolucionDet", MySqlDbType.Int32);

                parametrosEntrada[0].Value  = devolucion.IdDevolucion;
                parametrosEntrada[1].Value  = det.IdLC;
                parametrosEntrada[2].Value  = det.CodigoLC;
                parametrosEntrada[3].Value  = det.MarcaLC;
                parametrosEntrada[4].Value  = det.ModeloLC;
                parametrosEntrada[5].Value  = det.Cobrar;;
                parametrosEntrada[6].Value  = det.Danado;;
                parametrosEntrada[7].Value  = det.Caracteristicas;;
                parametrosEntrada[8].Value  = det.EstadoLC;;
                parametrosEntrada[9].Value  = det.Observacion;;
                parametrosEntrada[10].Value = 1;
                parametrosEntrada[11].Value = usuario;
                parametrosEntrada[12].Value = det.IdSalidaDetalle;
                parametrosEntrada[13].Value = det.IdSucursal;

                string[] datosSalida = new string[1];
                objManager.EjecutarProcedureConDatosDevueltos(parametrosEntrada, "insert_devolucion_det",
                                                              14, 15, out datosSalida, 1);

                if (datosSalida != null)
                {
                    int idDevolucionDet = Convert.ToInt32(datosSalida[0]);
                    error = true;
                }
                else
                {
                    error = false;
                    return(error);
                }
            }
            return(error);
        }
Beispiel #15
0
        public Devolucion LlamarDevolucionModificable(int idDevolucion)
        {
            Devolucion      devolucion = new Devolucion();
            MySqlDataReader reader;
            string          sql = "";

            sql    = "Select * From devolucion where idDevolucion=" + idDevolucion + " ;";
            reader = objManager.MostrarInformacion(sql);

            while (reader.Read())
            {
                devolucion.IdDevolucion    = reader.GetInt32("idDevolucion");
                devolucion.IdCliente       = reader.GetInt32("idCliente");
                devolucion.RucDni          = reader.GetString("rucDni");
                devolucion.GuiaDevolucion  = reader.GetString("guiaDevolucion");
                devolucion.FechaDevolucion = reader.GetDateTime("fechaDevolucion");
                devolucion.Observacion     = reader.GetString("observacion");
                devolucion.Estado          = reader.GetInt32("estado");
            }

            objManager.conexion.Close();
            objManager.conexion.Dispose();
            objManager.cmd.Dispose();


            sql    = "Select * From devolucion_det where idDevolucion=" + idDevolucion + " ;";
            reader = objManager.MostrarInformacion(sql);

            while (reader.Read())
            {
                DevolucionDetalle det = new DevolucionDetalle();
                det.IdDetalle       = reader.GetInt32("idDevolucionDet");
                det.IdDevolucion    = reader.GetInt32("idDevolucion");
                det.IdSalidaDetalle = reader.GetInt32("idSalidaDet");
                det.IdSucursal      = reader.GetInt32("idSucursal");
                det.IdLC            = reader.GetInt32("idLC");
                det.CodigoLC        = reader.GetString("codigoLC");
                det.MarcaLC         = reader.GetString("marcaLC");
                det.ModeloLC        = reader.GetString("modeloLC");
                det.Cobrar          = reader.GetInt32("pagaraCliente");
                det.Danado          = reader.GetInt32("danoLC");
                det.Caracteristicas = reader.GetString("caracteristicas");
                det.EstadoLC        = reader.GetInt32("estadoLC");
                det.Observacion     = reader.GetString("observacion");
                det.Estado          = reader.GetInt32("estado");
                devolucion.Detalles.Add(det);
            }

            objManager.conexion.Close();
            objManager.conexion.Dispose();
            objManager.cmd.Dispose();


            return(devolucion);
        }
 public ActionResult Edit([Bind(Include = "idDevolucion,Descripcion,Fecha,idPrestamo")] Devolucion devolucion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(devolucion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idPrestamo = new SelectList(db.Prestamo, "idPrestamo", "Descripcion", devolucion.idPrestamo);
     return(View(devolucion));
 }
Beispiel #17
0
 private void Fill(out Devolucion oObj, NullableDataReader dr)
 {
     oObj = new Devolucion(dr.GetDateTime("fechaMovimiento"),
                           dr.GetNullableString("destino") == null  ? "" : dr.GetString("destino"),
                           dr.GetNullableString("Observaciones") == null?"":dr.GetString("Observaciones"),
                           dr.GetNullableString("Certificado") == null ? "" : dr.GetString("Certificado"),
                           this.TraeFaltanteDevolucionXFechaMovimiento(dr.GetInt64("id_Beneficiario"), dr.GetInt16("codPrestacion"), dr.GetDateTime("fechaMovimiento").ToShortDateString()),
                           dr.GetNullableDateTime("fechaNotificacion"),
                           dr.GetNullableDateTime("fechaPresentacion")
                           );
 }
        private void lstDevolucion_Click_1(object sender, EventArgs e)
        {
            Devolucion devolucion = (Devolucion)lstDevolucion.SelectedItem;

            if (devolucion != null)
            {
                txtIDDevolucion.Text        = Convert.ToString(devolucion.Id);
                txtMotivoDevolucion.Text    = devolucion.Motivo_Devolucion;
                dtpFechaDevolucion.Value    = devolucion.FechaDevol;
                cmbDescripcion.SelectedItem = devolucion.Articulo;
            }
        }
Beispiel #19
0
        public void Put(int id, [FromBody] Devolucion newObj)
        {
            var oldObj = db.Devolucion.Find(id);

            if (oldObj == null)
            {
                return;
            }
            newObj.Id = oldObj.Id;
            db.Entry(oldObj).CurrentValues.SetValues(newObj);
            db.SaveChanges();
        }
        public async Task <IActionResult> Create([Bind("DevolucionID,PrestamoID,Fecha")] Devolucion devolucion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(devolucion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PrestamoID"] = new SelectList(_context.Prestamo, "PrestamoID", "PrestamoID", devolucion.PrestamoID);
            return(View(devolucion));
        }
Beispiel #21
0
        public async Task <IActionResult> Create([Bind("Id,FechaDevolucion,PrecioFinal,AlquilerId")] Devolucion devolucion)
        {
            if (ModelState.IsValid)
            {
                devolucion.Id = Guid.NewGuid();
                _context.Add(devolucion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AlquilerId"] = new SelectList(_context.Alquileres, "Id", "Id", devolucion.AlquilerId);
            return(View(devolucion));
        }
        public string SaveChanges()
        {
            string message = null;

            try
            {
                var devolucionDataModel = new Devolucion();
                devolucionDataModel.IdDevolucion    = IdDevolucion;
                devolucionDataModel.IdCompra        = IdCompra;
                devolucionDataModel.IdVenta         = IdVenta;
                devolucionDataModel.TotalDevolucion = TotalDevolucion;
                devolucionDataModel.FechaDevolucion = FechaDevolucion;

                switch (State)
                {
                case EntityState.Added:
                {
                    genericRepoitory.Add(devolucionDataModel);
                    message = "devolucion registrada correctamente";
                    break;
                }

                case EntityState.deleted:
                {
                    genericRepoitory.Remove(IdDevolucion);
                    message = "devolucion eliminda exitosamente";
                    break;
                }

                case EntityState.Modified:
                {
                    genericRepoitory.Edit(devolucionDataModel);
                    message = "devolucion Modificada Exitosamente";
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                SqlException sqlEx = ex as SqlException;
                if (sqlEx != null && sqlEx.Number == 2267)
                {
                    message = "Registro duplicado";
                }
                else
                {
                    message = ex.Message;
                }
            }
            return(message);
        }
Beispiel #23
0
 private void CreaDevolucion()
 {
     TxtFecha.Text = DateTime.Now.ToString("dd-MM-yyyy");
     devolucion    = new Devolucion();
     devolucion.ConceptoMovInvId = "";
     devolucion.EstadoDocId      = "PEN";
     devolucion.ProveedorId      = null;
     devolucion.CreatedAt        = DateTime.Now;
     devolucion.CreatedBy        = Ambiente.LoggedUser.UsuarioId;
     devolucion.Subtotal         = 0;
     devolucion.Impuesto         = 0;
     devolucion.Total            = 0;
     devolucionController.InsertOne(devolucion);
 }
        // GET: Devolucion/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Devolucion devolucion = db.Devolucion.Find(id);

            if (devolucion == null)
            {
                return(HttpNotFound());
            }
            return(View(devolucion));
        }
Beispiel #25
0
        public void DevolverProducto()
        {
            DevolucionBuilder devolucionBuilder = new DevolucionBuilder(venta);

            devolucionBuilder.AgregarDetalle(leche, 10).AgregarDetalle(yogurt, 2).AgregarDescripcion("Descripcion...");

            Devolucion devolucion = devolucionBuilder.Build();

            Assert.AreEqual(1, devolucion.DevolucionDetalles.Count);

            int cantidadEnVenta = venta.VentaDetalles.FirstOrDefault(x => x.ProductoBodega.Producto == yogurt).Cantidad;

            Assert.AreEqual(3, cantidadEnVenta);
        }
Beispiel #26
0
        public Devolucion Find(int DevolucionId)
        {
            var result = new Devolucion();

            try
            {
                result = _context.Devoluciones.Include(x => x.Libro).Single(x => x.DevolucionId == DevolucionId);
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
        public static List <SqlParameter> buildParametrosDevolucion(Devolucion devolucion)
        {
            List <SqlParameter> parametros_devolucion = new List <SqlParameter>();

            parametros_devolucion.Add(new SqlParameter("@motivo", devolucion.motivo));

            parametros_devolucion.Add(new SqlParameter("@fecha_devolucion", devolucion.fecha_devolucion));

            SqlParameter output = new SqlParameter("@devolucion_id", devolucion.id);

            output.Direction = ParameterDirection.Output;
            parametros_devolucion.Add(output);
            return(parametros_devolucion);
        }
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            Devolucion devolucion = (Devolucion)lstDevolucion.SelectedItem;

            if (this.lstDevolucion.SelectedItems.Count == 0)
            {
                MessageBox.Show("Favor seleccionar una fila de la lista");
            }
            else
            {
                Devolucion.EliminarDevolucion(devolucion);
                ActualizarListaDevolucion();
                LimpiarFormulario();
            }
        }
        // GET: Devolucion/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Devolucion devolucion = db.Devolucion.Find(id);

            if (devolucion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idPrestamo = new SelectList(db.Prestamo, "idPrestamo", "Descripcion", devolucion.idPrestamo);
            return(View(devolucion));
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (ValidarCampos())
            {
                modo = "AGREGAR";
                Devolucion devolucion = new Devolucion();
                devolucion.Motivo_Devolucion = txtMotivoDevolucion.Text;
                devolucion.FechaDevol        = dtpFechaDevolucion.Value.Date;
                devolucion.Articulo          = (Articulo)cmbDescripcion.SelectedItem;

                Devolucion.AgregarDevolucion(devolucion);
                LimpiarFormulario();
            }

            ActualizarListaDevolucion();
        }