private void button1_Click(object sender, EventArgs e) { DataBase.GetInstance().Transaccion_Comenzar(); ClienteDAO cl_dao = new ClienteDAO(); Cliente responsable = cl_dao.Cliente_FindByDni(Convert.ToInt32(txtDni.Text)); if (responsable == null) responsable = new Cliente(); responsable.Dni = Convert.ToInt32(txtDni.Text); responsable.Nombre = txtNombre.Text; responsable.Apellido = txtApellido.Text; responsable.Direccion = txtDireccion.Text; responsable.Mail = txtMail.Text; responsable.Telefono = Convert.ToInt32(txtTelefono.Text); responsable.FechaNac = new DateTime(cmbAnio.SelectedIndex + 1900, cmbMes.SelectedIndex + 1, (int)cmbDia.SelectedValue); cl_dao.Guardar_cliente(responsable); string base64Guid = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8).ToUpper(); detalle.PNR = base64Guid; detalle.FechaCompra = DateTime.Now; detalle.Responsable_Pago = responsable; if (rdbTarjeta.Checked) { if (txtTC_Venc.Text.Length != 4) { MessageBox.Show("El vencimiento de la tarjeta es invalido"); return; } detalle.TC_Numero = Convert.ToInt32(txtTC_Numero.Text); detalle.TC_Tipo = cmbTC_Tipo.SelectedValue.ToString(); detalle.Cuotas = Convert.ToInt32(cmbTC_Cuotas.SelectedValue); detalle.TC_Vencimiento = txtTC_Venc.Text; detalle.MedioPago = "TC"; } else { detalle.MedioPago = "Efectivo"; } new DetalleCompraDAO().Guardar_detalleCompra(detalle); PasajeDAO pasaje_dao = new PasajeDAO(); foreach (Pasaje p in pasajes) { pasaje_dao.Guardar_pasaje(p); } if (paquete != null) new PaqueteDAO().Guardar_paquete(paquete); DataBase.GetInstance().Transaccion_Commit(); MessageBox.Show("Gracias por su compra. Su PNR es: " + base64Guid); Main form = new Main(); form.Show(); this.Hide(); }
private void btnNext_Click(object sender, EventArgs e) { ClienteDAO dao = new ClienteDAO(); if (enRevision == null) enRevision = new Cliente(); enRevision.Dni = Convert.ToInt32(txtDni.Text); enRevision.Nombre = txtNombre.Text; enRevision.Apellido = txtApellido.Text; enRevision.Direccion = txtDireccion.Text; enRevision.Mail = txtMail.Text; enRevision.Telefono = Convert.ToInt32(txtTelefono.Text); enRevision.FechaNac = new DateTime(cmbAnio.SelectedIndex + 1900, cmbMes.SelectedIndex+1, (int)cmbDia.SelectedValue); dao.Guardar_cliente(enRevision); //save Random rnd = new Random(); int codigo = rnd.Next(10000000, 99999999); // creates a 8 digit random no. if (indice <= cant_pasajes) { if (butaca_elegida == null) { MessageBox.Show("Debe elegir una butaca"); return; } Pasaje pasaje = new Pasaje(); pasaje.Butaca = butaca_elegida; pasaje.Cliente = enRevision; pasaje.Codigo = codigo; pasajes.Add(pasaje); butacas_disponibles.Remove(butaca_elegida); } else { Paquete paq = new Paquete(); paq.Kgs = kgs; paq.Cliente = enRevision; paquete = paq; } indice++; if (indice > total) { //paso al form de pago Pago form = new Pago(pasajes, paquete, viaje); form.Show(); this.Hide(); } else { SetCaption(); ClearFields(); } }