Ejemplo n.º 1
0
        /// <summary>
        /// Speichert ein neues Angebot in der Datenbank
        /// </summary>
        /// <param name="gueltigAb"></param>
        /// <param name="gueltigBis"></param>
        /// <param name="preis"></param>
        /// <param name="kundeNr">ForeignKey Beziehung auf einen Kunden</param>
        /// <returns>NULL if SaveOrUpdate Fails else AngebotNrTyp for der persistent AngebotTyp</returns>
        public AngebotNrTyp erstelleAngebot(DateTime gueltigAb, DateTime gueltigBis, double preis, KundeTyp kunde, IDictionary<ProduktNummerTyp, int> prod)
        {
            AngebotNrTyp angebotNr = null;

            using (var session = AuftragserfassungKomp.getDB().OpenSession())
            using (var transaction = session.BeginTransaction())
            {

                try
                {
                    //Holt sich die letzte ID aus der Tabele und erstellt die nächste TransportNummer
                    //Allerdings nicht so schön weil man nicht sicher stellen kann das es auch wirklich die Max ID ist - auf jeden Fall nicht ThreadSicher!
                    var maxID = session.CreateCriteria(typeof(AngebotTyp)).SetProjection(Projections.Max("ID")).UniqueResult();
                    angebotNr = new AngebotNrTyp(maxID != null ? Convert.ToString(maxID) : "0");

                    AngebotTyp angebot = new AngebotTyp(angebotNr, gueltigAb, gueltigBis, preis, kunde, prod);
                    session.SaveOrUpdate(angebot);
                    transaction.Commit();
                }

                catch (NHibernate.Exceptions.GenericADOException ex)
                {
                    Console.WriteLine("ADOException persisting new Angebot!" + ex);
                }
            }
                return angebotNr;
        }
Ejemplo n.º 2
0
 public AuftragTyp(AuftragNrTyp nr, AngebotNrTyp angebot, bool istAbgeschlossen, DateTime erstelltAm, double preis)
 {
     this.nr = nr;
     this.gehoertZuAngebot = angebot;
     this.istAbgeschlossen = istAbgeschlossen;
     this.erstelltAm = erstelltAm;
     this.preis = preis;
 }
Ejemplo n.º 3
0
 public AngebotTyp holeAngebot(AngebotNrTyp nr)
 {
     //Was wenn die Query fehl schlägt??? Bzw. CastException??
     using (var session = AuftragserfassungKomp.getDB().OpenSession())
     using (var transaction = session.BeginTransaction())
     {
         return session.CreateCriteria(typeof(AngebotTyp)).Add(Restrictions.Like("nr", nr)).List<AngebotTyp>().ElementAt(0);
     }
 }
Ejemplo n.º 4
0
 public AngebotTyp(AngebotNrTyp nr, DateTime gueltigAb, DateTime gueltigBis, double addPreis, KundeTyp kunde, IDictionary<ProduktNummerTyp, int> prod)
 {
     this.nr = nr;
      this.gueltigAb = gueltigAb;
      this.gueltigBis = gueltigBis;
      this.gesamtPreis = addPreis;
      this.kunde = kunde;
      this.produkte = prod;
 }
Ejemplo n.º 5
0
        public AuftragNrTyp erstelleAuftrag(AngebotNrTyp nr,bool istAbgeschlosse, DateTime erstelltAm)
        {
            AuftragNrTyp auftragNr;

            using (var session = AuftragserfassungKomp.getDB().OpenSession())
            using (var transaction = session.BeginTransaction())
            {
                //Holt sich die letzte ID aus der Tabele und erstellt die nächste Nummer
                //Allerdings nicht so schön weil man nicht sicher stellen kann das es auch wirklich die Max ID ist - auf jeden Fall nicht ThreadSicher!
                var maxID = session.CreateCriteria(typeof(AuftragTyp)).SetProjection(Projections.Max("ID")).UniqueResult();
                auftragNr = new AuftragNrTyp(maxID != null ? Convert.ToString(maxID) : "0");
                var preis = holeAngebot(nr).gesamtPreis;

                AuftragTyp auftrag = new AuftragTyp(auftragNr, nr, istAbgeschlosse, erstelltAm,preis);
                session.SaveOrUpdate(auftrag);
                transaction.Commit();
            }

            return auftragNr;
        }
Ejemplo n.º 6
0
 public AuftragNrTyp erstelleAuftrag(AngebotNrTyp nr, bool istAbgeschlossen, DateTime erstelltAm)
 {
     return hesCore.getAuftragserfassungComp().erstelleAuftrag(nr, istAbgeschlossen, erstelltAm);
 }
Ejemplo n.º 7
0
 public AngebotTyp holeAngebot(AngebotNrTyp nr)
 {
     return repo.holeAngebot(nr);
 }
Ejemplo n.º 8
0
 public AuftragNrTyp erstelleAuftrag(AngebotNrTyp nr,bool istAbgeschlosse, DateTime erstelltAm)
 {
     return repo.erstelleAuftrag(nr,istAbgeschlosse,erstelltAm);
 }