コード例 #1
0
        public User getUser(int id)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            User loggedInUser           = db.Users.Find(id);

            return(loggedInUser);
        }
コード例 #2
0
 public void Delete(int id)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User u = db.Users.Find(id);
     db.Users.Add(u);
     db.SaveChanges();
 }
コード例 #3
0
 public List<Expens> getAllExpeces()
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     List<Expens> list = new List<Expens>();
     list = db.Expenses.ToList();
     return list;
 }
コード例 #4
0
        public void Delete(int id)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            User u = db.Users.Find(id);

            db.Users.Add(u);
            db.SaveChanges();
        }
コード例 #5
0
        public void unSlect(int Bid, int uid)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            Budget b = db.Budgets.Find(Bid);

            b.isCurrent = false;
            db.SaveChanges();
        }
コード例 #6
0
        public List <Expens> getAllExpeces()
        {
            MoneyManagementEntities2 db   = new MoneyManagementEntities2();
            List <Expens>            list = new List <Expens>();

            list = db.Expenses.ToList();
            return(list);
        }
コード例 #7
0
        public void AddBudgetFromFile(String path, int UserId)
        {
            FileStream   fs                  = new FileStream(path, FileMode.Open);
            StreamReader sr                  = new StreamReader(fs);
            String       name                = sr.ReadLine();
            String       StartDate           = sr.ReadLine();
            String       endDate             = sr.ReadLine();
            String       Income              = sr.ReadLine();
            String       ExpCatagories       = sr.ReadLine();
            String       ExpCatagoriesRanges = sr.ReadLine();

            sr.Close();
            fs.Close();

            Budget b = new Budget();

            b.Name      = name;
            b.UID       = UserId;
            b.StartDate = DateTime.ParseExact(StartDate, "dd/MM/yyyy", null);
            b.EndDate   = DateTime.ParseExact(endDate, "dd/MM/yyyy", null);
            b.Income    = Int32.Parse(Income);
            b.isCurrent = true;

            MoneyManagementEntities2 db  = new MoneyManagementEntities2();
            Budget AlreadySelectedBudget = null;

            foreach (Budget curr in db.Budgets)
            {
                if (curr.isCurrent == true)
                {
                    AlreadySelectedBudget = curr;
                }
            }
            if (AlreadySelectedBudget != null)
            {
                AlreadySelectedBudget.isCurrent = false;
                db.SaveChanges();
            }
            db.Budgets.Add(b);
            db.SaveChanges();

            String []       catagories       = ExpCatagories.Split(',');
            String[]        catagoriesRanges = ExpCatagoriesRanges.Split(',');
            ExpenseCatagory Bcatagory        = new ExpenseCatagory();

            for (int i = 0; i < catagories.Length; i++)
            {
                Bcatagory.BID             = b.BID;
                Bcatagory.CatName         = catagories[i];
                Bcatagory.CatRange        = Int32.Parse(catagoriesRanges[i]);
                Bcatagory.Rangepercentage = ((Bcatagory.CatRange / b.Income) * 100);
                Bcatagory.ExpensesSum     = 0;
                db.ExpenseCatagories.Add(Bcatagory);
                db.SaveChanges();
            }
        }
コード例 #8
0
 public bool checkAvailability(String email)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     foreach (User u in db.Users)
     {
         if (u.Email == email)
             return true;
     }
     return false;
 }
コード例 #9
0
 public List<Budget> getAllBudgets(int id)
 {
     List<Budget> budgets = new List<Budget>();
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User LoggedInUser = db.Users.Find(id);
     foreach (Budget b in LoggedInUser.Budgets)
     {
         budgets.Add(b);
     }
     return budgets;
 }
コード例 #10
0
        public List <Budget> getAllBudgets(int id)
        {
            List <Budget>            budgets = new List <Budget>();
            MoneyManagementEntities2 db      = new MoneyManagementEntities2();
            User LoggedInUser = db.Users.Find(id);

            foreach (Budget b in LoggedInUser.Budgets)
            {
                budgets.Add(b);
            }
            return(budgets);
        }
コード例 #11
0
 public List<ExpenseCatagory> getAllExpCatagoriesOfSelectedBudget(int UserID)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User u = db.Users.Find(UserID);
     List<ExpenseCatagory> list = new List<ExpenseCatagory>();
     foreach(Budget b in u.Budgets)
     {
         if (b.isCurrent == true)
             list = b.ExpenseCatagories.ToList();
     }
     return list;
 }
コード例 #12
0
 public void SaveEditProfile(User u,int loggedInUserId)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User loggedInUser = db.Users.Find(loggedInUserId);
     if (u.Name != null)
         loggedInUser.Name = u.Name;
     if (u.Email != null)
         loggedInUser.Email = u.Email;
     if (u.password != null)
         loggedInUser.password = u.password;
     db.SaveChanges();
 }
コード例 #13
0
        public bool checkAvailability(String email)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();

            foreach (User u in db.Users)
            {
                if (u.Email == email)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #14
0
        public void AddBudgetFromFile(String path,int UserId)
        {
            FileStream fs = new FileStream(path, FileMode.Open);
            StreamReader sr = new StreamReader(fs);
            String name = sr.ReadLine();
            String StartDate = sr.ReadLine();
            String endDate = sr.ReadLine();
            String Income = sr.ReadLine();
            String ExpCatagories = sr.ReadLine();
            String ExpCatagoriesRanges = sr.ReadLine();

            sr.Close();
            fs.Close();

            Budget b = new Budget();
            b.Name = name;
            b.UID = UserId;
            b.StartDate = DateTime.ParseExact(StartDate, "dd/MM/yyyy", null);
            b.EndDate = DateTime.ParseExact(endDate, "dd/MM/yyyy", null);
            b.Income = Int32.Parse(Income);
            b.isCurrent = true;

            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            Budget AlreadySelectedBudget = null;
            foreach (Budget curr in db.Budgets)
            {
                if (curr.isCurrent == true)
                    AlreadySelectedBudget = curr;
            }
            if (AlreadySelectedBudget != null)
            {
                AlreadySelectedBudget.isCurrent = false;
                db.SaveChanges();
            }
            db.Budgets.Add(b);
            db.SaveChanges();

            String [] catagories = ExpCatagories.Split(',');
            String[] catagoriesRanges = ExpCatagoriesRanges.Split(',');
            ExpenseCatagory Bcatagory = new ExpenseCatagory();
            for (int i = 0; i < catagories.Length; i++ )
            {
                Bcatagory.BID = b.BID;
                Bcatagory.CatName = catagories[i];
                Bcatagory.CatRange = Int32.Parse(catagoriesRanges[i]);
                Bcatagory.Rangepercentage = ( (Bcatagory.CatRange / b.Income) * 100 );
                Bcatagory.ExpensesSum = 0;
                db.ExpenseCatagories.Add(Bcatagory);
                db.SaveChanges();
            }
        }
コード例 #15
0
        bool IsAlreadyExist(String Email)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();

            foreach (User user in db.Users)
            {
                if (user.Email == Email)
                {
                    //User already exists... we Don't have to add it again
                    return(true);
                }
            }
            return(false);
        }
コード例 #16
0
        public List <Expens> getAllExpecesOfSelectedBudget(int userID)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            User          u             = db.Users.Find(userID);
            List <Expens> list          = new List <Expens>();

            foreach (Budget b in u.Budgets)
            {
                if (b.isCurrent == true)
                {
                    list = b.Expenses.ToList();
                }
            }
            return(list);
        }
コード例 #17
0
 public void DeleteBudget(int id)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     Budget b = db.Budgets.Find(id);
     List<ExpenseCatagory> catagories = new List<ExpenseCatagory>();
     foreach (ExpenseCatagory c in b.ExpenseCatagories)
     {
         catagories.Add(c);
     }
     foreach (ExpenseCatagory c in catagories)
     {
         db.ExpenseCatagories.Remove(c);
     }
     db.Budgets.Remove(b);
     db.SaveChanges();
 }
コード例 #18
0
        public void DeleteBudget(int id)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            Budget b = db.Budgets.Find(id);
            List <ExpenseCatagory> catagories = new List <ExpenseCatagory>();

            foreach (ExpenseCatagory c in b.ExpenseCatagories)
            {
                catagories.Add(c);
            }
            foreach (ExpenseCatagory c in catagories)
            {
                db.ExpenseCatagories.Remove(c);
            }
            db.Budgets.Remove(b);
            db.SaveChanges();
        }
コード例 #19
0
 public bool SaveUser(User u)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User Authentic_user = null;
     bool isExist = IsAlreadyExist(u.Email);
     //This means user not already exist in database
     if (isExist == false)
     {
         Authentic_user = u;
     }
     if (Authentic_user != null && u != null)
     {
         db.Users.Add(u);
         db.SaveChanges();
         return true;
     }
     return false;
 }
コード例 #20
0
        public void SaveEditProfile(User u, int loggedInUserId)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            User loggedInUser           = db.Users.Find(loggedInUserId);

            if (u.Name != null)
            {
                loggedInUser.Name = u.Name;
            }
            if (u.Email != null)
            {
                loggedInUser.Email = u.Email;
            }
            if (u.password != null)
            {
                loggedInUser.password = u.password;
            }
            db.SaveChanges();
        }
コード例 #21
0
        public bool SaveUser(User u)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            User Authentic_user         = null;
            bool isExist = IsAlreadyExist(u.Email);

            //This means user not already exist in database
            if (isExist == false)
            {
                Authentic_user = u;
            }
            if (Authentic_user != null && u != null)
            {
                db.Users.Add(u);
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
コード例 #22
0
 public List<SearchExpense> SearchExpenses(String SearchText)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     List<SearchExpense> SearchedExpenses = new List<SearchExpense>();
     List<Expens> all = db.Expenses.ToList();
     for (int i = 0; i < all.Count; i++ )
     {
         Expens e = all[i];
         if (e.Description.Contains(SearchText))
         {
             SearchExpense ex = new SearchExpense();
             ex.Amount = e.Amount;
             ex.Description = e.Description;
             ex.BudgetName = e.Budget.Name;
             SearchedExpenses.Add(ex);
             //SearchedExpenses.Add(e);
         }
     }
     return SearchedExpenses;
 }
コード例 #23
0
 public int Authenticate(User u)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User Authentic_user = null;
     foreach (User user in db.Users)
     {
         if ((user.Email == u.Email) && (user.password == u.password))
         {
             Authentic_user = user;
         }
     }
     if (Authentic_user == null)
     {
         return -1;
     }
     else
     {
         return Authentic_user.UID;
     }
 }
コード例 #24
0
        public List <SearchExpense> SearchExpenses(String SearchText)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            List <SearchExpense>     SearchedExpenses = new List <SearchExpense>();
            List <Expens>            all = db.Expenses.ToList();

            for (int i = 0; i < all.Count; i++)
            {
                Expens e = all[i];
                if (e.Description.Contains(SearchText))
                {
                    SearchExpense ex = new SearchExpense();
                    ex.Amount      = e.Amount;
                    ex.Description = e.Description;
                    ex.BudgetName  = e.Budget.Name;
                    SearchedExpenses.Add(ex);
                    //SearchedExpenses.Add(e);
                }
            }
            return(SearchedExpenses);
        }
コード例 #25
0
        public int Authenticate(User u)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            User Authentic_user         = null;

            foreach (User user in db.Users)
            {
                if ((user.Email == u.Email) && (user.password == u.password))
                {
                    Authentic_user = user;
                }
            }
            if (Authentic_user == null)
            {
                return(-1);
            }
            else
            {
                return(Authentic_user.UID);
            }
        }
コード例 #26
0
        public void Slect(int Bid, int uid)
        {
            MoneyManagementEntities2 db  = new MoneyManagementEntities2();
            Budget AlreadySelectedBudget = null;
            User   u = db.Users.Find(uid);

            foreach (Budget curr in u.Budgets)
            {
                if (curr.isCurrent == true)
                {
                    AlreadySelectedBudget = curr;
                }
            }
            if (AlreadySelectedBudget != null)
            {
                AlreadySelectedBudget.isCurrent = false;
                db.SaveChanges();
            }
            Budget B = db.Budgets.Find(Bid);

            B.isCurrent = true;
            db.SaveChanges();
        }
コード例 #27
0
        public void SaveBudget(Budget b, String catagories, String ranges)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();

            db.Budgets.Add(b);
            db.SaveChanges();

            String[] catagoriesList = catagories.Split(',');
            String[] rangesList     = ranges.Split(',');
            Budget   currBudget     = db.Budgets.Find(b.BID);

            for (int i = 0; i < catagoriesList.Length; i++)
            {
                ExpenseCatagory cat = new ExpenseCatagory();
                cat.BID             = b.BID;
                cat.CatName         = catagoriesList[i];
                cat.CatRange        = Int32.Parse(rangesList[i]);
                cat.Rangepercentage = ((cat.CatRange / currBudget.Income) * 100);
                cat.ExpensesSum     = 0;
                db.ExpenseCatagories.Add(cat);
                db.SaveChanges();
            }
        }
コード例 #28
0
 public void saveExpense(Expens exp,String catName,int UserID)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User u = db.Users.Find(UserID);
     Budget SelectedBudget = new Budget();
     foreach (Budget b in u.Budgets)
     {
         if (b.isCurrent == true)
         {
             exp.BID = b.BID;
             SelectedBudget = b;
         }
     }
     foreach(ExpenseCatagory expCat in SelectedBudget.ExpenseCatagories)
     {
         if (expCat.CatName == catName)
         {
             exp.ExpCat = expCat.ExpCatId;
         }
     }
     db.Expenses.Add(exp);
     db.SaveChanges();
 }
コード例 #29
0
        public void saveExpense(Expens exp, String catName, int UserID)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            User   u = db.Users.Find(UserID);
            Budget SelectedBudget = new Budget();

            foreach (Budget b in u.Budgets)
            {
                if (b.isCurrent == true)
                {
                    exp.BID        = b.BID;
                    SelectedBudget = b;
                }
            }
            foreach (ExpenseCatagory expCat in SelectedBudget.ExpenseCatagories)
            {
                if (expCat.CatName == catName)
                {
                    exp.ExpCat = expCat.ExpCatId;
                }
            }
            db.Expenses.Add(exp);
            db.SaveChanges();
        }
コード例 #30
0
 public void Slect(int Bid,int uid)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     Budget AlreadySelectedBudget = null;
     User u = db.Users.Find(uid);
     foreach (Budget curr in u.Budgets)
     {
         if (curr.isCurrent == true)
             AlreadySelectedBudget = curr;
     }
     if (AlreadySelectedBudget != null)
     {
         AlreadySelectedBudget.isCurrent = false;
         db.SaveChanges();
     }
     Budget B = db.Budgets.Find(Bid);
     B.isCurrent = true;
     db.SaveChanges();
 }
コード例 #31
0
 public User getUser(int id)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     User loggedInUser = db.Users.Find(id);
     return loggedInUser;
 }
コード例 #32
0
 public void unSlect(int Bid,int uid)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     Budget b = db.Budgets.Find(Bid);
     b.isCurrent = false;
     db.SaveChanges();
 }
コード例 #33
0
 bool IsAlreadyExist(String Email)
 {
     MoneyManagementEntities2 db = new MoneyManagementEntities2();
     foreach (User user in db.Users)
     {
         if (user.Email == Email)
         {
             //User already exists... we Don't have to add it again
             return true;
         }
     }
     return false;
 }
コード例 #34
0
        public void SaveBudget(Budget b, String catagories, String ranges)
        {
            MoneyManagementEntities2 db = new MoneyManagementEntities2();
            db.Budgets.Add(b);
            db.SaveChanges();

            String[] catagoriesList = catagories.Split(',');
            String[] rangesList = ranges.Split(',');
            Budget currBudget = db.Budgets.Find(b.BID);
            for (int i = 0; i < catagoriesList.Length; i++)
            {
                ExpenseCatagory cat = new ExpenseCatagory();
                cat.BID = b.BID;
                cat.CatName = catagoriesList[i];
                cat.CatRange = Int32.Parse(rangesList[i]);
                cat.Rangepercentage = ((cat.CatRange / currBudget.Income) * 100);
                cat.ExpensesSum = 0;
                db.ExpenseCatagories.Add(cat);
                db.SaveChanges();
            }
        }