private void BtnImprimir_Click(object sender, EventArgs e)
 {
     FacturaDetails();
     using (SaveFileDialog sfd = new SaveFileDialog()
     {
         Filter = "PDF file |*.pdf", ValidateNames = true
     })
     {
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A4.Rotate());
             try
             {
                 PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create));
                 doc.Open();
                 doc.Add(new iTextSharp.text.Paragraph(txtBoxFactura.Text));
             }
             catch (Exception ex)
             {
                 FrmSeguroCerrar.confirmacionForm("ERROR");
             }
             finally
             {
                 doc.Close();
             }
         }
     }
 }
Exemplo n.º 2
0
        private void BtnIngresar_Click(object sender, EventArgs e)
        {
            string usuario = txtUsuario.Text;
            string contra  = txtContra.Text;

            if (usuario == "" || contra == "")
            {
                MessageBox.Show("Se han detectado campos vacíos, por favor llenarlos.");
                return;
            }
            bool r = validate_login(usuario, contra);

            if (r)
            {
                MainScreen abrir = new MainScreen();
                abrir.Show();
                //this.Close();
            }
            else
            {
                FrmSeguroCerrar.confirmacionForm("ERROR");
            }
        }
Exemplo n.º 3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (editar == false)
            {
                if (this.txtBoxNombre.Text == string.Empty || this.txtBoxTipoHabitacion.Text == string.Empty || this.txtBoxNoches.Text == string.Empty || this.txtBoxTotal.Text == string.Empty)
                {
                    ErrorDatosFaltantes.confirmacionForm("ERROR");
                }
                else
                {
                    r.CantidadAdultos  = Convert.ToInt32(numAdultos.Value);
                    r.CantidadInfantes = Convert.ToInt32(numInfantes.Value);
                    r.Canal            = txtBoxCanal.Text;
                    r.Comentario       = txtBoxComentarios.Text;
                    r.PrecioPorNoche   = float.Parse(txtBoxPrecio.Text, CultureInfo.InvariantCulture.NumberFormat);
                    r.TotalPorEstadia  = float.Parse(txtBoxTotal.Text, CultureInfo.InvariantCulture.NumberFormat);


                    if (r.Insert(r) == true)
                    {
                        if (r.Insert_reservacion_habitacion(r.SelectIdReservacion(), r.IdHabitacion) == true)
                        {
                            Habitacion hab = new Habitacion();
                            hab.IsReserved(r.IdHabitacion, 1);
                            // MessageBox.Show("Sure");
                            Clear();

                            dateTimePickerLlegada.MinDate = DateTime.Today;
                            dateTimePickerSalida.MinDate  = DateTime.Today.AddDays(1);
                            calcularNoches();


                            FrmCorrecto.confirmacionForm("CORRECTO");
                        }
                    }
                    else
                    {
                        FrmSeguroCerrar.confirmacionForm("ERROR");
                    }
                }
            }
            if (editar == true)
            {
                if (this.txtBoxNombre.Text == string.Empty || this.txtBoxTipoHabitacion.Text == string.Empty || this.txtBoxNoches.Text == string.Empty || this.txtBoxTotal.Text == string.Empty)
                {
                    ErrorDatosFaltantes.confirmacionForm("ERROR");
                }
                else
                {
                    r.CantidadAdultos  = Convert.ToInt32(numAdultos.Value);
                    r.CantidadInfantes = Convert.ToInt32(numInfantes.Value);
                    r.Canal            = txtBoxCanal.Text;
                    r.Comentario       = txtBoxComentarios.Text;
                    r.PrecioPorNoche   = float.Parse(txtBoxPrecio.Text, CultureInfo.InvariantCulture.NumberFormat);
                    r.TotalPorEstadia  = float.Parse(txtBoxTotal.Text, CultureInfo.InvariantCulture.NumberFormat);
                    if (r.Update(r) == true)
                    {
                        if (r.Update_reservacion_habitacion(r.IdReservacion, r.IdHabitacion) == true)
                        {
                            btnBuscarCliente.Enabled = true;
                        }

                        dateTimePickerLlegada.MinDate = DateTime.Today;
                        dateTimePickerSalida.MinDate  = DateTime.Today.AddDays(1);
                        FrmCorrecto.confirmacionForm("CORRECTO");
                    }

                    else
                    {
                        FrmCorrecto.confirmacionForm("CORRECTO");
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static void confirmacionForm(string mensaje)
        {
            FrmSeguroCerrar frm = new FrmSeguroCerrar(mensaje);

            frm.ShowDialog();
        }
Exemplo n.º 5
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (editar == false)
            {
                try
                {
                    if (this.txtBoxNumHab.Text == string.Empty || this.cmbTipoHab.Text == string.Empty || this.cmbEstado.Text == string.Empty || this.txtBoxPrecioPorNoche.Text == string.Empty)
                    {
                        FrmSeguroCerrar.confirmacionForm("ERROR");
                    }
                    else
                    {
                        habitacion.NumHab         = Convert.ToInt32(txtBoxNumHab.Text);
                        habitacion.TipoHab        = cmbTipoHab.Text;
                        habitacion.CantCamas      = Convert.ToInt32(numCantCamas.Value);
                        habitacion.MaxPersonas    = Convert.ToInt32(numMaxPersonas.Value);
                        habitacion.Piso           = Convert.ToInt32(numPiso.Value);
                        habitacion.Estado         = cmbEstado.Text;
                        habitacion.Detalles       = txtBoxDetalles.Text;
                        habitacion.PrecioPorNoche = Convert.ToSingle(txtBoxPrecioPorNoche.Text);


                        if (habitacion.Insert(habitacion) == true)
                        {
                            RefreshDgv();
                            Clear();
                            FrmCorrecto.confirmacionForm("AGREGADO");
                        }
                        else
                        {
                            FrmSeguroCerrar.confirmacionForm("ERROR");
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            if (editar == true)
            {
                if (this.txtBoxNumHab.Text == string.Empty || this.cmbTipoHab.Text == string.Empty || this.cmbEstado.Text == string.Empty || this.txtBoxPrecioPorNoche.Text == string.Empty)
                {
                    MessageBox.Show("Falta ingresar algunos datos");
                }
                else
                {
                    try
                    {
                        //Controller code

                        //Shitty code
                        habitacion.IdHabitacion   = Convert.ToInt32(txtBoxId.Text);
                        habitacion.NumHab         = Convert.ToInt32(txtBoxNumHab.Text);
                        habitacion.TipoHab        = cmbTipoHab.Text;
                        habitacion.CantCamas      = Convert.ToInt32(numCantCamas.Value);
                        habitacion.MaxPersonas    = Convert.ToInt32(numMaxPersonas.Value);
                        habitacion.Piso           = Convert.ToInt32(numPiso.Value);
                        habitacion.Estado         = cmbEstado.Text;
                        habitacion.Detalles       = txtBoxDetalles.Text;
                        habitacion.PrecioPorNoche = Convert.ToSingle(txtBoxPrecioPorNoche.Text);


                        if (habitacion.Update(habitacion) == true)
                        {
                            RefreshDgv();
                            MessageBox.Show("La habitación ha sido actualizada.");
                            Clear();
                            editar = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error al editar los datos. (Error: " + ex + ")");
                    }
                }
            }
        }
        private void BtnConfirmarSalida_Click(object sender, EventArgs e)
        {
            Factura_Reservacion f = new Factura_Reservacion();

            if (txtTotalAPagar.Text == "0")
            {
                //no debe
                f.IdReservacion = id;
                f.IdHuesped     = Convert.ToInt32(txtIdCliente.Text);
                f.Empleado      = txtAtendidoPor.Text;
                f.TotalAPagar   = Convert.ToSingle(txtTotalAPagar.Text);
                f.Fecha         = dtpFechaActual.Value;
                // f.FormaDePago = cmbFormaPago.Text;
                f.SubTotal = Convert.ToSingle(dgvFill.Rows[0].Cells[12].Value);
                // RESERVACION PASA DE CHECKED IN A CHECKED OUT
                Reservacion reserva = new Reservacion();
                reserva.IdReservacion = f.IdReservacion;
                reserva.CheckOut(reserva);
                // HABITACION PASA DE OCUPADA A DISPONIBLE Y SU ESTADO DE RESERVADA PASA A NEGATIVO
                Habitacion hab = new Habitacion();
                hab.IdHabitacion = Convert.ToInt32(dgvFill.Rows[0].Cells[3].Value);
                hab.CambiarEstados(hab.IdHabitacion, "Disponible");
                hab.IsReserved(hab.IdHabitacion, 0);
                FrmCorrecto.confirmacionForm("AGREGADO");
            }
            else
            {
                //debe
                if (cmbFormaPago.Text == string.Empty)
                {
                    ErrorDatosFaltantes.confirmacionForm("ERROR");
                }
                else
                {
                    if (cmbFormaPago.Text == "Tarjeta")
                    {
                        if (txtNombre.Text == string.Empty || txtTotalAPagar.Text == string.Empty || txtBoxDigitos.Text == string.Empty || txtBoxCompania.Text == string.Empty || txtAtendidoPor.Text == string.Empty)
                        {
                            ErrorDatosFaltantes.confirmacionForm("ERROR");
                        }
                        else
                        {
                            f.IdReservacion   = id;
                            f.IdHuesped       = Convert.ToInt32(txtIdCliente.Text);
                            f.Empleado        = txtAtendidoPor.Text;
                            f.TotalAPagar     = Convert.ToSingle(txtTotalAPagar.Text);
                            f.FormaDePago     = cmbFormaPago.Text;
                            f.SubTotal        = Convert.ToSingle(dgvFill.Rows[0].Cells[12].Value);
                            f.Fecha           = dtpFechaActual.Value;
                            f.UltimosDigitos  = Convert.ToInt32(txtBoxDigitos.Text);
                            f.CompaniaTarjeta = txtBoxCompania.Text;
                            if (txtDescuento.Text == string.Empty)
                            {
                                //do nothing
                            }
                            else
                            {
                                f.Descuento = Convert.ToSingle(txtDescuento.Text);
                            }


                            if (f.InsertTarjeta(f) == true)
                            {
                                // RESERVACION PASA DE SIN CONFIRMAR A CHECK IN
                                Reservacion reserva = new Reservacion();
                                reserva.IdReservacion = f.IdReservacion;
                                reserva.Confirmar(reserva);
                                // HABITACION PASA DE DISPONIBLE A OCUPADA
                                Habitacion hab = new Habitacion();
                                hab.IdHabitacion = Convert.ToInt32(dgvFill.Rows[0].Cells[3].Value);
                                hab.CambiarEstados(hab.IdHabitacion, "Disponible");
                                //   hab.IsReserved(hab.IdHabitacion, 1);
                                FrmCorrecto.confirmacionForm("CORRECTO");
                                f.IdFactura         = f.SelectIdFactura();
                                btnImprimir.Enabled = true;
                            }
                            else
                            {
                                FrmSeguroCerrar.confirmacionForm("ERROR");
                            }
                        }
                    }
                    if (cmbFormaPago.Text == "Efectivo")
                    {
                        if (txtNombre.Text == string.Empty || txtEfectivo.Text == string.Empty || txtTotalAPagar.Text == string.Empty || txtCambio.Text == string.Empty || txtAtendidoPor.Text == string.Empty)
                        {
                            ErrorDatosFaltantes.confirmacionForm("ERROR");
                        }
                        else
                        {
                            /*
                             * @IdReservacion, @IdHuesped, @SubTotal, @TotalAPagar, @Fecha, @FormaDePago, @EfectivoRecibido, @Devuelta
                             */
                            f.IdReservacion = id;
                            f.IdHuesped     = Convert.ToInt32(txtIdCliente.Text);
                            f.Empleado      = txtAtendidoPor.Text;
                            f.TotalAPagar   = Convert.ToSingle(txtTotalAPagar.Text);
                            f.Fecha         = dtpFechaActual.Value;
                            f.FormaDePago   = cmbFormaPago.Text;
                            f.SubTotal      = Convert.ToSingle(dgvFill.Rows[0].Cells[12].Value);
                            if (txtDescuento.Text == string.Empty)
                            {
                                //do nothing
                            }
                            else
                            {
                                f.Descuento = Convert.ToSingle(txtDescuento.Text);
                            }
                            if (txtEfectivo.Text == string.Empty)
                            {
                                //do nothing
                            }
                            else
                            {
                                f.EfectivoRecibido = Convert.ToSingle(txtEfectivo.Text);
                            }
                            if (txtCambio.Text == string.Empty)
                            {
                                //do nothing
                                ErrorDatosFaltantes.confirmacionForm("ERROR");
                            }
                            else
                            {
                                f.Devuelta = Convert.ToSingle(txtCambio.Text);
                            }

                            if (f.InsertEfectivo(f) == true && txtCambio.Text != "")
                            {
                                // RESERVACION PASA DE SIN CONFIRMAR A CHECK IN
                                Reservacion reserva = new Reservacion();
                                reserva.IdReservacion = f.IdReservacion;
                                reserva.Confirmar(reserva);
                                // HABITACION PASA DE OCUPADA A DISPONIBLE

                                Habitacion hab = new Habitacion();
                                hab.IdHabitacion = Convert.ToInt32(dgvFill.Rows[0].Cells[3].Value);
                                hab.CambiarEstados(hab.IdHabitacion, "Disponible");
                                //  hab.IsReserved(hab.IdHabitacion, 1);
                                FrmCorrecto.confirmacionForm("CORRECTO");
                                f.IdFactura         = f.SelectIdFactura();
                                btnImprimir.Enabled = true;
                            }
                            else
                            {
                                //  MessageBox.Show("Ha ocurrido un error al facturar.");
                            }
                        }
                    }
                }
            }
        }
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (editar == false)
            {
                if (this.txtPrimerNombre.Text == string.Empty || this.txtPrimerApellido.Text == string.Empty)
                {
                    ErrorDatosFaltantes.confirmacionForm("ERROR");
                }
                else
                {
                    Empleado pEmpleado = new Empleado();
                    pEmpleado.PrimerNombre    = txtPrimerNombre.Text.Trim();
                    pEmpleado.SegundoNombre   = txtSegundoNombre.Text.Trim();
                    pEmpleado.PrimerApellido  = txtPrimerApellido.Text.Trim();
                    pEmpleado.SegundoApellido = txtSegundoApellido.Text.Trim();
                    pEmpleado.RolEmpleado     = txtRolEmpleado.Text.Trim();
                    pEmpleado.TipoDocumento   = cbxTipoIdentificacion.Text.Trim();
                    pEmpleado.NumDocumento    = txtIdentificacion.Text.Trim();
                    pEmpleado.Sexo            = cbxSexo.Text.Trim();
                    pEmpleado.Telefono        = txtTelefono.Text.Trim();
                    pEmpleado.Direccion       = txtDireccion.Text.Trim();
                    pEmpleado.Ciudad          = txtCiudad.Text.Trim();
                    pEmpleado.Provincia       = txtProvincia.Text.Trim();
                    pEmpleado.Pais            = txtPaisNatal.Text.Trim();
                    pEmpleado.Correo          = txtCorreo.Text.Trim();
                    pEmpleado.Usuario         = txtUsuario.Text.Trim();
                    pEmpleado.Contraseña      = txtContra.Text.Trim();

                    int resultado = EmpleadoC.Agregar(pEmpleado);
                    if (resultado > 0)
                    {
                        FrmCorrecto.confirmacionForm("AGREGADO");
                        txtPrimerNombre.Text                = "";
                        txtSegundoNombre.Text               = "";
                        txtPrimerApellido.Text              = "";
                        txtSegundoApellido.Text             = "";
                        txtRolEmpleado.Text                 = "";
                        cbxTipoIdentificacion.SelectedIndex = -1;
                        txtIdentificacion.Text              = "";
                        cbxSexo.SelectedIndex               = -1;
                        txtTelefono.Text  = "";
                        txtDireccion.Text = "";
                        txtCiudad.Text    = "";
                        txtProvincia.Text = "";
                        txtPaisNatal.Text = "";
                        txtCorreo.Text    = "";
                        txtUsuario.Text   = "";
                        txtContra.Text    = "";
                    }
                    else
                    {
                        FrmSeguroCerrar.confirmacionForm("ERROR");
                    }
                }
            }

            if (editar == true)
            {
                try
                {
                    string          MyConnection2 = "server=localhost; database=hostal; Uid=root; pwd=root";
                    string          Query         = "update hostal.empleado set PrimerNombre='" + this.txtPrimerNombre.Text + "',SegundoNombre='" + this.txtSegundoNombre.Text + "',PrimerApellido='" + this.txtPrimerApellido.Text + "',SegundoApellido='" + this.txtSegundoApellido.Text + "' where IdEmpleado='" + this.txtIdEmpleado.Text + "';";
                    MySqlConnection MyConn2       = new MySqlConnection(MyConnection2);
                    MySqlCommand    MyCommand2    = new MySqlCommand(Query, MyConn2);
                    MySqlDataReader MyReader2;
                    MyConn2.Open();
                    MyReader2 = MyCommand2.ExecuteReader();
                    MessageBox.Show("El cliente ha sido modificado.");
                    Huesped limpiar = new Huesped();
                    //limpiar.BorrarCampos(this, groupbox1);
                    //cbxTipoIdentificacion.Items.Clear();
                    //cbxTipoIdentificacion.SelectedIndex = 0;
                    while (MyReader2.Read())
                    {
                    }
                    MyConn2.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }