public void Print(BarcodeHerbstschiessen barcodeInfo) { DocumentClass doc = new DocumentClass(); const string path = @".\Templates\Herbstschiessen.lbx"; string fullPath = Path.GetFullPath(path); if (doc.Open(fullPath)) { IObject barcode = doc.GetObject("barcode"); barcode.Text = Convert.ToString(barcodeInfo.Barcode); IObject shooterName = doc.GetObject("shooterName"); shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName); IObject dateOfBirth = doc.GetObject("dateOfBirth"); dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty); IObject groupName = doc.GetObject("GroupName"); groupName.Text = Convert.ToString(barcodeInfo.Gruppenstich); IObject sieUndErName = doc.GetObject("SieUndErName"); sieUndErName.Text = Convert.ToString(barcodeInfo.SieUndEr); IObject isGruppenstich = doc.GetObject("pass_103"); isGruppenstich.Text = Convert.ToString(barcodeInfo.IsGruppenstich ? "x" : string.Empty); IObject isNachwuchsstich = doc.GetObject("pass_104"); isNachwuchsstich.Text = Convert.ToString(barcodeInfo.IsNachwuchsstich ? "x" : string.Empty); IObject isWorschtUndBrot = doc.GetObject("pass_101"); isWorschtUndBrot.Text = Convert.ToString(barcodeInfo.IsWorschtUndBrot ? "x" : string.Empty); IObject isSieUndEr = doc.GetObject("pass_102"); isSieUndEr.Text = Convert.ToString(barcodeInfo.IsSieUndEr ? "x" : string.Empty); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); } else { throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath)); } }
private void ExecutePrintBarcodeCommand(UiShooter uiShooter) { try { bool isNachwuchs = (from sp in _shooterParticipationDataStore.GetAll() join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId where p.ParticipationName == "Nachwuchsstich" && sp.ShooterId == uiShooter.ShooterId select p.ParticipationId). Any(); bool isGruppe = (from sp in _shooterParticipationDataStore.GetAll() join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId where p.ParticipationName == "Gruppenstich" && sp.ShooterId == uiShooter.ShooterId select p.ParticipationId). Any(); bool isSieUndEr = (from sp in _shooterParticipationDataStore.GetAll() join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId where p.ParticipationName == "Sie & Er" && sp.ShooterId == uiShooter.ShooterId select p.ParticipationId). Any(); bool isWorschtUndBrot = (from sp in _shooterParticipationDataStore.GetAll() join p in _participationDataStore.GetAll() on sp.ParticipationId equals p.ParticipationId where p.ParticipationName == "Worscht & Brot" && sp.ShooterId == uiShooter.ShooterId select p.ParticipationId). Any(); string groupName = (from cs in _collectionShooterDataStore.GetAll() join sc in _shooterCollectionDataStore.GetAll() on cs.ShooterCollectionId equals sc.ShooterCollectionId join scp in _shooterCollectionParticipationDataStore.GetAll() on cs.ShooterCollectionId equals scp.ShooterCollectionId join p in _participationDataStore.GetAll() on scp.ParticipationId equals p.ParticipationId where p.ParticipationName == "Gruppenstich" && cs.ShooterId == uiShooter.ShooterId select sc.CollectionName).SingleOrDefault(); string sieUndErName = (from cs in _collectionShooterDataStore.GetAll() join sc in _shooterCollectionDataStore.GetAll() on cs.ShooterCollectionId equals sc.ShooterCollectionId join scp in _shooterCollectionParticipationDataStore.GetAll() on cs.ShooterCollectionId equals scp.ShooterCollectionId join p in _participationDataStore.GetAll() on scp.ParticipationId equals p.ParticipationId where p.ParticipationName == "Sie & Er" && cs.ShooterId == uiShooter.ShooterId select sc.CollectionName).SingleOrDefault(); Person person = uiShooter.PersonId == null ? new Person() { FirstName = "unknown", LastName = "unknown" } : _personDataStore.FindById((int)uiShooter.PersonId); BarcodeHerbstschiessen barcodeInfo = new BarcodeHerbstschiessen { FirstName = person.FirstName, LastName = person.LastName, DateOfBirth = person.DateOfBirth, Gruppenstich = groupName ?? string.Empty, SieUndEr = sieUndErName ?? string.Empty, Barcode = _barcodeBuilderService.BuildBarcode(uiShooter.ShooterNumber, uiShooter.Legalization), IsGruppenstich = isGruppe, IsNachwuchsstich = isNachwuchs, IsWorschtUndBrot = isWorschtUndBrot, IsSieUndEr = isSieUndEr }; _barcodePrintService.Print(barcodeInfo); } catch (Exception e) { ReportException(e); } }