Beispiel #1
0
 public void AddPersonName(string PersonName)
 {
     using (var db = new InvestmentdbContext())
     {
         db.Add(new People {
             Name = PersonName
         });
         db.SaveChanges();
     }
 }
Beispiel #2
0
 //To update the wrong entry made in Expenditure Table
 public void Update_Expenditure(int id, float expenditure, string purpose)
 {
     using (var db = new InvestmentdbContext())
     {
         var SExpenditure = db.Expenditures.OrderBy(e => e.ExpenditureId);
         foreach (var Eid in SExpenditure)
         {
             if (Eid.ExpenditureId == id)
             {
                 Eid.ExpenseAmount        = expenditure;
                 Eid.PurposeOfExpenditure = purpose;
             }
         }
         db.SaveChanges();
     }
 }
Beispiel #3
0
        //To update the wrong entry made in Income Table

        public void Update_Income(int id, float income, string source)
        {
            using (var db = new InvestmentdbContext())
            {
                var SIncome = db.Incomes.OrderBy(i => i.IncomeId);
                foreach (var Iid in SIncome)
                {
                    if (Iid.IncomeId == id)
                    {
                        Iid.IncomeReceived = income;
                        Iid.SourceOfIncome = source;
                    }
                }
                db.SaveChanges();
            }
        }
Beispiel #4
0
        //to Delete Wrong Expenditure
        public void Delete_Expenditure(int id)
        {
            using (var db = new InvestmentdbContext())
            {
                var queryIncome = db.Expenditures.OrderBy(i => i.ExpenditureId);

                foreach (var Eid in queryIncome)
                {
                    if (Eid.ExpenditureId == id)
                    {
                        db.Remove(Eid);
                    }
                }
                db.SaveChanges();
            }
        }
Beispiel #5
0
        public void Delete_People(int id)
        {
            using (var db = new InvestmentdbContext())
            {
                var peopleId = db.Peoples.OrderBy(i => i.PeopleId);

                foreach (var Pid in peopleId)
                {
                    if (Pid.PeopleId == id)
                    {
                        db.Remove(Pid);
                    }
                }

                db.SaveChanges();
            }
        }
Beispiel #6
0
        //to Delete Wrong Income
        public void Delete_Income(int id)
        {
            using (var db = new InvestmentdbContext())
            {
                var queryIncome = db.Incomes.OrderBy(i => i.IncomeId);

                // var fid = (float)id;
                foreach (var Iid in queryIncome)
                {
                    if (Iid.IncomeId == id)
                    {
                        db.Remove(Iid);
                    }
                }
                db.SaveChanges();
            }
        }
Beispiel #7
0
 public void AddExpenditure(float amount, string purpose, string name)
 {
     if (amount <= 0)
     {
         throw new Exception("Invalid input");
     }
     else
     {
         using (var db = new InvestmentdbContext())
         {
             var q2 = db.Peoples.Where(p => p.Name == name);
             foreach (var p in q2)
             {
                 db.Add(new Expenditure {
                     ExpenseAmount = amount, Day = DateTime.Now, PurposeOfExpenditure = purpose, PeopleId = p.PeopleId
                 });
             }
             db.SaveChanges();
         }
     }
 }
Beispiel #8
0
        // Adding entry to database with exception handling
        public void AddIncome(float amount, string source, string name)
        {
            if (amount <= 0)
            {
                throw new Exception("Invalid input");
            }
            else
            {
                using (var db = new InvestmentdbContext())
                {
                    var q1 = db.Peoples.Where(p => p.Name == name);

                    foreach (var p in q1)
                    {
                        db.Add(new Income {
                            IncomeReceived = amount, Day = DateTime.Now, SourceOfIncome = source, PeopleId = p.PeopleId
                        });
                    }

                    db.SaveChanges();
                }
            }
        }