private void CargarDatos() { IBLLHuesped _BLLHuesped = new BLLHuesped(); IBLLPais _BLLPais = new BLLPais(); List <Pais> lista = null; // Cambiar el estado this.CambiarEstado(EstadoMantenimiento.Ninguno); // Configuracion del DataGridView para que se vea bien la imagen. dgvDatos.AutoGenerateColumns = false; // dgvDatos.RowTemplate.Height = 100; dgvDatos.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; // Cargar el DataGridView this.dgvDatos.DataSource = _BLLHuesped.GetAllHuesped(); // Cargar el combo this.cmbPais.Items.Clear(); lista = _BLLPais.GetAllPais(); foreach (Pais oPais in lista) { this.cmbPais.Items.Add(oPais); } // Colocar el primero como default this.cmbPais.SelectedIndex = 0; }
private void btnAceptar_Click(object sender, EventArgs e) { IBLLHuesped _BLLHuesped = new BLLHuesped(); IBLLPais _Pais = new BLLPais(); try { Huesped oHuesped = new Entities.Huesped(); oHuesped.ID = Double.Parse(this.txtId.Text); oHuesped.Nombre = this.txtNombre.Text; oHuesped.Apellido1 = this.txtApellido1.Text; oHuesped.Apellido2 = this.txtApellido2.Text; oHuesped.Telefono = this.txtTelefono.Text; oHuesped.Correo = this.txtCorreo.Text; oHuesped._Pais = _Pais.GetPaisById(((Pais)(this.cmbPais.SelectedItem)).ID); _BLLHuesped.SaveHuesped(oHuesped); if (oHuesped != null) { this.CargarDatos(); } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // Log error //_MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // Mensaje de Error MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripBtnBuscar_Click(object sender, EventArgs e) { IBLLHuesped _BLLHuesped = new BLLHuesped(); double filtro = 0; try { //filtro = Double.Parse(this.txtFiltro.Text); this.dgvDatos.AutoGenerateColumns = false; this.dgvDatos.DataSource = _BLLHuesped.GetAllHuesped(); } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); MessageBox.Show(msg.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripBtnFacturar_Click(object sender, EventArgs e) { IBLLEncFactura _BLLFactura = new BLLEncFactura(); IBLLTarjeta _BLLTarjeta = new BLLTarjeta(); IBLLHuesped _BLLHuesped = new BLLHuesped(); IBLLHabitacion _BLLHabitacion = new BLLHabitacion(); IBLLImpuesto _BLLImpuesto = new BLLImpuesto(); DetFactura oFacturaDetalle = new DetFactura(); this.cmbEstado.SelectedIndex = 1; IBLLReservacion _BLLReservacion = new BLLReservacion(); Tarjeta oTarjeta = new Tarjeta(); string rutaImagen = @"c:\temp\qr.png"; double numeroFactura = 0d; try { _FacturaEncabezado = new EncFactura() { IDFactura = Double.Parse(this.txtNumeroFactura.Text), _Tarjeta = cmbTarjeta.SelectedItem as Tarjeta,//_BLLTarjeta.GetTarjetaById(Double.Parse(this.txtNumeroTarjeta.Text)), Fecha = DateTime.Now.Date, EstadoFact = this.cmbEstado.SelectedIndex.ToString(), }; oFacturaDetalle._EncFactura = _BLLFactura.GetFactura(Double.Parse(this.txtNumeroFactura.Text)); oFacturaDetalle._Reservacion = _BLLReservacion.GetReserva(Double.Parse(this.mskIDReserva.Text.ToString())); oFacturaDetalle.Precio = Double.Parse(this.txtPrecio.Text.ToString()); // Calcular el Impuesto IBLLImpuesto _BLLImpuestotest = new BLLImpuesto(); oFacturaDetalle._Impuesto = _BLLImpuestotest.GetImpuesto(); // Enumerar la secuencia oFacturaDetalle.Numero = _FacturaEncabezado._ListaFacturaDetalle.Count == 0 ? 1 : _FacturaEncabezado._ListaFacturaDetalle.Max(p => p.Numero) + 1; ; // Agregar _FacturaEncabezado.AddDetalle(oFacturaDetalle); if (_FacturaEncabezado == null) { MessageBox.Show("No hay datos por facturar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_FacturaEncabezado._ListaFacturaDetalle.Count == 0) { MessageBox.Show("No hay items en la factura ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.txtSubtotal.Text = _FacturaEncabezado.GetSubTotal().ToString(); this.txtImpuesto.Text = _FacturaEncabezado.GetImpuesto().ToString(); this.txtTotal.Text = (_FacturaEncabezado.GetSubTotal() + (_FacturaEncabezado.GetImpuesto())).ToString(); _FacturaEncabezado = _BLLFactura.SaveFactura(_FacturaEncabezado); numeroFactura = _BLLFactura.GetCurrentNumeroFactura(); EstadoHabitaciones(); if (_FacturaEncabezado == null) { MessageBox.Show("Error al crear factura!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else //toolStripBtnNuevo_Click(null, null); // Si existe borrelo if (File.Exists(rutaImagen)) { File.Delete(rutaImagen); } // Crear imagen quickresponse Image quickResponseImage = QuickResponse.QuickResponseGenerador(numeroFactura.ToString(), 53); // Salvarla en c:\temp para luego ser leida quickResponseImage.Save(rutaImagen, ImageFormat.Png); frmFacturaImpresion ofrmFacturaImpresion = new frmFacturaImpresion((int)numeroFactura, _BLLHuesped.GetHuespedById(Double.Parse(this.txtIdHuesped.Text)).Nombre); ofrmFacturaImpresion.ShowDialog(); this.txtNumeroTarjeta.Text = ""; this.txtNumHabitacion.Text = ""; this.txtNUMDetalle.Text = "1"; this.txtImpuesto.Text = ""; this.txtIdHuesped.Text = ""; this.txtCantDias.Text = ""; this.txtPrecio.Text = ""; this.txtSubtotal.Text = ""; this.txtTotal.Text = ""; this.cmbEstado.SelectedIndex = 0; this.cmbTarjeta.SelectedIndex = 0; this.Subtotal.Text = ""; this.mskIDReserva.Text = ""; this.dgvDetalleFactura.Rows.Clear(); this.dgvDetalleFactura.Refresh(); } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // Log error _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // Mensaje de Error MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripBtnReservar_Click(object sender, EventArgs e) { try { Reservacion oReservacion = null; IBLLReservacion _IBLLReservacion = new BLLReservacion(); IBLLHabitacion _BLLHabitacion = new BLLHabitacion(); IBLLHuesped _BLLHuesped = new BLLHuesped(); if (this.txtHuespedId == null) { MessageBox.Show(" Es un dato requerido !", "Atención"); return; } oReservacion = new Reservacion(); oReservacion.ID = double.Parse(this.txtNumeroReservacion.Text); oReservacion._Huesped = _BLLHuesped.GetHuespedById(double.Parse(this.txtHuespedId.Text.ToString())); oReservacion._Habitacion = _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString())); foreach (var item in _IBLLReservacion.GetAllReservacion()) { if (item.CheckIN.DayOfYear <= this.dtpCheckIN.Value.DayOfYear && item.CheckOUT.DayOfWeek > this.dtpCheckOut.Value.DayOfWeek && item.CheckIN.Month == this.dtpCheckIN.Value.Month && item._Habitacion.NUM == _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString())).NUM) { MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención"); return; } //else //{ // if (item.CheckIN.Day < this.dtpCheckIN.Value.Day && // item.CheckIN.Month == this.dtpCheckIN.Value.Month) // { // MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención"); // return; // } //} if (item.CheckOUT.DayOfYear == this.dtpCheckOut.Value.DayOfYear && item.CheckOUT.Month == this.dtpCheckOut.Value.Month && item._Habitacion.NUM == _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString())).NUM) { MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención"); return; } //else //{ // if (item.CheckOUT.Day > this.dtpCheckOut.Value.Day // && item.CheckOUT.Month == this.dtpCheckOut.Value.Month) // { // MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención"); // return; // } //} } if (this.dtpCheckIN.Value.DayOfYear < DateTime.Now.DayOfYear || this.dtpCheckIN.Value.Month < DateTime.Now.Month) { MessageBox.Show(" No puede reservar fechas anteriores a la actual !", "Atención"); return; } if (this.dtpCheckOut.Value.DayOfYear < DateTime.Now.DayOfYear || this.dtpCheckOut.Value.Month < DateTime.Now.Month || this.dtpCheckOut.Value.DayOfYear < this.dtpCheckIN.Value.DayOfYear || this.dtpCheckOut.Value.Month < dtpCheckIN.Value.Month) { MessageBox.Show(" No puede reservar fechas anteriores a la actual !", "Atención"); return; } oReservacion.CheckIN = (DateTime)this.dtpCheckIN.Value; oReservacion.CheckOUT = (DateTime)this.dtpCheckOut.Value; oReservacion.CantDias = double.Parse(this.mskCantidad.Text); oReservacion.Subtotal = double.Parse(this.mskCantidad.Text) * _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString())).Precio; txtSub.Text = oReservacion.Subtotal.ToString(); _IBLLReservacion.SaveReserva(oReservacion); if (oReservacion != null) { this.CargarDatos(); } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // Log error _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // Mensaje de Error MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void toolStripBtnBorrar_Click(object sender, EventArgs e) { IBLLHuesped _BLLHuesped = new BLLHuesped(); //IBLLCliente _BLLCliente = new BLLCliente(); //try //{ // this.CambiarEstado(EstadoMantenimiento.Editar); // Cliente _Cliente = null; // if (this.dgvDatos.SelectedRows.Count > 0) // { // // Cambiar de estado // this.CambiarEstado(EstadoMantenimiento.Editar); // _Cliente = this.dgvDatos.SelectedRows[0].DataBoundItem as Cliente; // this.txtIdCliente.Text = _Cliente.IdCliente.ToString(); // this.txtNombre.Text = _Cliente.Nombre; // this.txtApellido1.Text = _Cliente.Apellido1; // this.txtApellido2.Text = _Cliente.Apellido2; // if (_Cliente.Sexo == 1) // { // this.rbnMas.Checked = true; // } // else // { // this.rbnFem.Checked = true; // } // this.dtpFechaNacimiento.Value = _Cliente.FechaNacimiento; // this.cmbProvincia.SelectedIndex = _Cliente.IdProvincia; // _BLLCliente.DeleteCliente(Convert.ToDouble(_Cliente.IdCliente)); // } // else // { // MessageBox.Show("Seleccione el registro !", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} //catch (Exception er) //{ // StringBuilder msg = new StringBuilder(); // msg.AppendFormat("Message {0}\n", er.Message); // msg.AppendFormat("Source {0}\n", er.Source); // msg.AppendFormat("InnerException {0}\n", er.InnerException); // msg.AppendFormat("StackTrace {0}\n", er.StackTrace); // msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // // Log error // _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // // Mensaje de Error // MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //} try { if (this.dgvDatos.SelectedRows.Count > 0) { this.CambiarEstado(EstadoMantenimiento.Borrar); Huesped _Huesped = null; _Huesped = this.dgvDatos.SelectedRows[0].DataBoundItem as Huesped; if (MessageBox.Show($"¿Seguro que desea borrar el registro {_Huesped.ID} {_Huesped.Nombre}?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _BLLHuesped.DeleteHuesped(Convert.ToDouble(_Huesped.ID)); this.CargarDatos(); } } else { MessageBox.Show("Seleccione el registro !", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // Log error //_MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // Mensaje de Error MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }