예제 #1
0
        public IList <DB.Revenue> getRevenues()
        {
            IList <DB.Revenue> lRevs = new List <DB.Revenue>();

            foreach (RevenueModel rM in _ValidRevenues)
            {
                var type   = rM.revType.ElementAt(0);
                var isType = type.Name;
                var types  = DB.RevenueType.GetRevenueTypes();

                int actualType = 0;
                foreach (DB.RevenueType rt in types)
                {
                    if (rt.Name.Equals(isType))
                    {
                        actualType = rt.RevenueTypeID;
                    }
                }

                var aRev = new DB.Revenue();
                aRev.RevenueType = new RevenueType();
                aRev.Amount      = Convert.ToDouble(rM.revAmount.Replace(".", ","));
                aRev.Description = rM.revDescription;
                aRev.RevenueType.RevenueTypeID = actualType;
                aRev.StartDate = rM.revStartDate;
                aRev.EndDate   = rM.revEndDate;
                aRev.RevenueID = rM.revenueID;

                aRev.Person = _currentPerson;

                lRevs.Add(aRev);
            }
            return(lRevs);
        }
예제 #2
0
        /// <summary>
        /// Fügt einen Einkommenseintrag der Datenbank hinzu
        /// </summary>
        /// <param name="personID">Die benötigte Personen ID</param>
        /// <param name="revenueTypeID">Die Einkommensart ID</param>
        /// <param name="amount">Der Betrag</param>
        /// <param name="description">Optionale Beschreibung</param>
        /// <returns>Gibt die ID des Eintrags aus der Datenbank zurück</returns>
        public static int Add(int personID, int revenueTypeID, double amount, DateTime startDate, DateTime? endDate = null, string description = null)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var revenue = new Revenue
                {
                    Amount = amount,
                    Description = description,
                    RevenueType = db.RevenueTypes.Single(r => r.RevenueTypeID == revenueTypeID),
                    Person = db.Persons.Single(p => p.PersonID == personID),
                    StartDate = startDate,
                    EndDate = endDate
                };

                db.Revenues.AddObject(revenue);
                db.SaveChanges();

                return revenue.RevenueID;
            }
        }
예제 #3
0
        /// <summary>
        /// Fügt einen Einkommenseintrag der Datenbank hinzu
        /// </summary>
        /// <param name="personID">Die benötigte Personen ID</param>
        /// <param name="revenueTypeID">Die Einkommensart ID</param>
        /// <param name="amount">Der Betrag</param>
        /// <param name="description">Optionale Beschreibung</param>
        /// <returns>Gibt die ID des Eintrags aus der Datenbank zurück</returns>
        public static int Add(int personID, int revenueTypeID, double amount, DateTime startDate, DateTime?endDate = null, string description = null)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var revenue = new Revenue
                {
                    Amount      = amount,
                    Description = description,
                    RevenueType = db.RevenueTypes.Single(r => r.RevenueTypeID == revenueTypeID),
                    Person      = db.Persons.Single(p => p.PersonID == personID),
                    StartDate   = startDate,
                    EndDate     = endDate
                };

                db.Revenues.AddObject(revenue);
                db.SaveChanges();

                return(revenue.RevenueID);
            }
        }
예제 #4
0
        /// <summary>
        /// Gibt eine Liste mit den abgelegten Einkommen zurück
        /// Author: Antonios Fesenmeier
        /// </summary>
        /// <returns></returns>
        public IList<DB.Revenue> getRevenues()
        {
            IList<DB.Revenue> lRevs = new List<DB.Revenue>();
            foreach (RevenueModel rM in _ValidRevenues)
            {
                var type = rM.revType.ElementAt(0);
                var isType = type.Name;
                var types = DB.RevenueType.GetRevenueTypes();

                int actualType = 0;
                foreach (DB.RevenueType rt in types)
                {
                    if (rt.Name.Equals(isType))
                        actualType = rt.RevenueTypeID;
                }

                var aRev = new DB.Revenue();
                aRev.RevenueType = new RevenueType();
                aRev.Amount = Convert.ToDouble(rM.revAmount.Replace(".", ","));
                aRev.Description = rM.revDescription;
                aRev.RevenueType.RevenueTypeID = actualType;
                aRev.StartDate = rM.revStartDate;
                aRev.EndDate = rM.revEndDate;

                lRevs.Add(aRev);
            }
            return lRevs;
        }
예제 #5
0
 /// <summary>
 /// Veraltete Methode zum Hinzufügen eines neuen Objekts zum EntitySet 'Revenues'. Verwenden Sie stattdessen die Methode '.Add' der zugeordneten Eigenschaft 'ObjectSet&lt;T&gt;'.
 /// </summary>
 public void AddToRevenues(Revenue revenue)
 {
     base.AddObject("Revenues", revenue);
 }
예제 #6
0
 /// <summary>
 /// Erstellt ein neues Revenue-Objekt.
 /// </summary>
 /// <param name="revenueID">Anfangswert der Eigenschaft RevenueID.</param>
 /// <param name="amount">Anfangswert der Eigenschaft Amount.</param>
 /// <param name="startDate">Anfangswert der Eigenschaft StartDate.</param>
 public static Revenue CreateRevenue(global::System.Int32 revenueID, global::System.Double amount, global::System.DateTime startDate)
 {
     Revenue revenue = new Revenue();
     revenue.RevenueID = revenueID;
     revenue.Amount = amount;
     revenue.StartDate = startDate;
     return revenue;
 }