private async void btn_CheckOut_Click(object sender, EventArgs e) { try { MessageBox.Show("" + _idHab + " " + tb_CodHab.Text); Alquileres checkout = new Alquileres { id_alquiler = _idHab, codigo_habA = tb_CodHab.Text }; HttpResponseMessage respuesta = await Task.Run(() => connection.UpdateHTTP(checkout, "/alquiler/update")); var contents = await respuesta.Content.ReadAsStringAsync(); dynamic json = JObject.Parse(contents); if (json.success == "true") { MessageBox.Show("" + json.msg); this.Close(); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("" + json.msg); } } catch (Exception ex) { MessageBox.Show("ERROR REGISTRO ALQUILER: \n" + ex.Message); } }
public void ModificarReserva(int id, Alquileres cancelacion) { var query = (from x in contexto.Alquileres where x.ID == id select x).First(); query.Estado = 3; query.FechaAlquiler = null; query.FechaDevolucion = null; query.FechaReserva = null; contexto.Update(query); contexto.SaveChanges(); }
private void LlenaCampos(Alquileres alquileres) { IDTextBox.Text = Convert.ToString(alquileres.IdAlquilar); MatriculaTextBox.Text = alquileres.Matricula; NombreTextBox.Text = alquileres.NombreCliente; TelefonoTextBox.Text = alquileres.Telefono; CedulaTextBox.Text = alquileres.Cedula; FechaE.SelectedDate = alquileres.FechaEntrada; DuracionTextbox.Text = Convert.ToString(alquileres.Duracion); PrecioTextBox.Text = Convert.ToString(alquileres.PrecioDiario); TotalTextbox.Text = Convert.ToString(Calcular()); ObservarTextbox.Text = alquileres.Observacion; }
private void btnRecibir_Click(object sender, EventArgs e) { using (BibliotecaprogramEntities db = new BibliotecaprogramEntities()) { if (int.Parse(txtCantidad.Text) > cantidad || int.Parse(txtCantidad.Text) > 0) { MessageBox.Show("Cantidad incorrecta"); } else if (int.Parse(txtCantidad.Text) < cantidad && int.Parse(txtCantidad.Text) > 0) { alqu = db.Alquileres.Where(buscarID => buscarID.Id_alquiler == idAlquiler).First(); alqu.Id_Lector = idLector; alqu.Id_libro = IdLibro; alqu.cantidad = int.Parse(txtCantidad.Text); alqu.Entregado = IdEntregado; alqu.fecha_salida = fecha_salida; alqu.fecha_prevista_de_entrega = fecha_pre; alqu.fecha_de_entrega = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); alqu.Recibido = idAdmin; db.Entry(alqu).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Alquileres alqui = new Alquileres(); alqui.Id_Lector = idLector; alqui.Id_libro = IdLibro; alqui.cantidad = cantidad - int.Parse(txtCantidad.Text); alqui.Entregado = IdEntregado; alqui.fecha_salida = fecha_salida; alqui.fecha_prevista_de_entrega = fecha_pre; db.Alquileres.Add(alqui); db.SaveChanges(); } else if (int.Parse(txtCantidad.Text) == cantidad && int.Parse(txtCantidad.Text) > 0) { alqu = db.Alquileres.Where(buscarID => buscarID.Id_alquiler == idAlquiler).First(); alqu.Id_Lector = idLector; alqu.Id_libro = IdLibro; alqu.cantidad = int.Parse(txtCantidad.Text); alqu.Entregado = IdEntregado; alqu.fecha_salida = fecha_salida; alqu.fecha_prevista_de_entrega = fecha_pre; alqu.fecha_de_entrega = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); alqu.Recibido = idAdmin; db.Entry(alqu).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } limpiar(); frmPrincipal.prestamos.CargarDatos(); this.Close(); }
private void btnRecibir_Click(object sender, EventArgs e) { using (BibliotecaEntities4 db = new BibliotecaEntities4()) { alqu = db.Alquileres.Where(buscarID => buscarID.Id_alquiler == idAlquiler).First(); alqu.Id_Lector = idLector; alqu.Id_libro = IdLibro; alqu.Entregado = IdEntregado; alqu.fecha_salida = fecha_salida; alqu.fecha_prevista_de_entrega = fecha_pre; alqu.fecha_de_entrega = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); alqu.Recibido = idAdmin; db.Entry(alqu).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } limpiar(); frmPrincipal.prestamos.CargarDatos(); }
private void BuscarButton_Click(object sender, RoutedEventArgs e) { int id; Alquileres alquileres = new Alquileres(); int.TryParse(IDTextBox.Text, out id); Limpiar(); alquileres = AlquilarBll.Buscar(id); if (alquileres != null) { LlenaCampos(alquileres); } else { System.Windows.MessageBox.Show("No Encontrada"); } }
public static Alquileres Buscar(int id) { Contexto contexto = new Contexto(); Alquileres alquileres = new Alquileres(); try { alquileres = contexto.Alquileres.Find(id); } catch { throw; } finally { contexto.Dispose(); } return(alquileres); }
public static bool Modificar(Alquileres alquileres) { bool paso = false; Contexto contexto = new Contexto(); try { contexto.Entry(alquileres).State = EntityState.Modified; paso = (contexto.SaveChanges() > 0); } catch (Exception) { throw; } finally { contexto.Dispose(); } return(paso); }
private Alquileres Proceso(AlquilerDTO procesoDTO, bool descuento) { Alquileres alqui = new Alquileres(); { alqui.Cliente = _clienteQuery.getClienteId(procesoDTO.DNI); alqui.ISBN = procesoDTO.ISBN; if (descuento) { _libroQuery.DescuentoStock(procesoDTO.ISBN); } else { _libroQuery.AumentoStock(procesoDTO.ISBN); } alqui.Estado = procesoDTO.Estado; alqui.FechaAlquiler = procesoDTO.FechaAlquiler; alqui.FechaReserva = procesoDTO.FechaReserva; alqui.FechaDevolucion = procesoDTO.FechaDevolucion; }; return(alqui); }
private async void btn_Alquilar_Click(object sender, EventArgs e) { try { Alquileres alquilar = new Alquileres() { cedula_cliA = tb_CedCli.Text, codigo_habA = tb_CodHab.Text, cedula_empA = Properties.Settings.Default.Cedula, fechaIng_alq = dt_FIngreso.Text, fechaSal_alq = dt_FSalida.Text, numDias_alq = _dias, temp_alq = cb_Temp.SelectedItem.ToString(), prcTotal_alq = total, estado_alq = "O" }; HttpResponseMessage respuesta = await Task.Run(() => connection.PostHTTP(alquilar, "/alquilar")); var contents = await respuesta.Content.ReadAsStringAsync(); dynamic json = JObject.Parse(contents); if (json.success == "true") { MessageBox.Show("" + json.msg); this.Close(); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("" + json.msg); } } catch (Exception ex) { MessageBox.Show("ERROR REGISTRO ALQUILER: \n" + ex.Message); } }
private Alquileres LlenaClases() { Alquileres alquileres = new Alquileres(); if (string.IsNullOrWhiteSpace(IDTextBox.Text)) { IDTextBox.Text = "0"; } else { alquileres.IdAlquilar = Convert.ToInt32(IDTextBox.Text); } alquileres.Matricula = MatriculaTextBox.Text; alquileres.NombreCliente = NombreTextBox.Text; alquileres.Telefono = TelefonoTextBox.Text; alquileres.Cedula = CedulaTextBox.Text; alquileres.FechaEntrada = Convert.ToDateTime(FechaE.SelectedDate); alquileres.Duracion = Convert.ToDecimal(DuracionTextbox.Text); alquileres.PrecioDiario = Convert.ToDecimal(PrecioTextBox.Text); alquileres.Total = Convert.ToDecimal(Calcular()); alquileres.Observacion = ObservarTextbox.Text; return(alquileres); }
public static bool Guardar(Alquileres alquileres) { bool paso = false; Contexto contexto = new Contexto(); try { if (contexto.Alquileres.Add(alquileres) != null) { paso = contexto.SaveChanges() > 0; } } catch (Exception) { throw; } finally { contexto.Dispose(); } return(paso); }
private bool ExisteBD() { Alquileres alquileres = AlquilarBll.Buscar(Convert.ToInt32(IDTextBox.Text)); return(alquileres != null); }
public string RegistrarProceso(AlquilerDTO procesoDTO) { if (_clienteQuery.ExisteCliente(procesoDTO.DNI) && _libroQuery.ExisteIsbn(procesoDTO.ISBN)) { switch (procesoDTO.Estado) { case 1: if (_libroQuery.ExisteStock(procesoDTO.ISBN)) { Alquileres alquiler = Proceso(procesoDTO, true); _repository.Add <Alquileres>(alquiler); return("El alquiler se registro exitosamente"); } else { return("No contamos con stock para realizar el alquiler"); } case 2: if (_libroQuery.ExisteStock(procesoDTO.ISBN)) { Alquileres reserva = Proceso(procesoDTO, true); _repository.Add <Alquileres>(reserva); return("La reserva se registro exitosamente"); } else { return("No contamos con stock para realizar la reserva"); } case 3: if (_alquileresQuery.ExisteReserva(_clienteQuery.getClienteId(procesoDTO.DNI), procesoDTO.ISBN)) { Alquileres cancelacion = Proceso(procesoDTO, false); int id = _alquileresQuery.getIdReservaAntigua(_clienteQuery.getClienteId(procesoDTO.DNI), procesoDTO.ISBN); _alquileresQuery.ModificarReserva(id, cancelacion); return("Se cancelo la reserva"); } else { return("El cliente y el libro no tienen reserva asociada para cancelar"); } default: return("Ocurrio un error inesperado vuelva a intentarlo por favor"); } } else { if (!_clienteQuery.ExisteCliente(procesoDTO.DNI)) { return("El dni ingresado no pertence a ningun cliente registrado"); } if (!_libroQuery.ExisteIsbn(procesoDTO.ISBN)) { return("El isbn ingresado no pertence a ningun libro registrado"); } else { return("Ocurrio un error inesperado vuelva a intentarlo por favor"); } } }