Esempio n. 1
0
        public Users GetByUsernameAndPassword(string username, string password)
        {
            using (var db = new Index.BloggingContext())
            {
                try
                {
                    Users user = new Users();

                    var result =
                        (from u in db.Users
                         where u.Username == username && u.Pass == password
                         select u).FirstOrDefault();
                    Login.LoggedUser = result;
                    return(result);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message,
                                    "Database operation Failed",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Asterisk,
                                    MessageBoxDefaultButton.Button1);
                }
                return(null);
            }
        }
Esempio n. 2
0
 public List <Users> GetAllUsers()
 {
     using (var db = new Index.BloggingContext())
     {
         var result =
             (from u in db.Users
              select u).ToList();
         return(result);
     }
 }
Esempio n. 3
0
 private List <MTasks> GetAllTasks()
 {
     using (var db = new Index.BloggingContext())
     {
         var result =
             (from m in db.MTasks
              select m).ToList();
         return(result);
     }
 }
Esempio n. 4
0
 private List <TimeSpent> GetAllTime()
 {
     using (var db = new Index.BloggingContext())
     {
         var result =
             (from t in db.TimeSpent
              select t).ToList();
         return(result);
     }
 }
Esempio n. 5
0
 public List <MTasks> GetAllNF()
 {
     using (var db = new Index.BloggingContext())
     {
         var result =
             (from m in db.MTasks
              where m.Final == false
              select m).ToList();
         return(result);
     }
 }
Esempio n. 6
0
 private void NewUser(Users obj)
 {
     using (var db = new Index.BloggingContext())
     {
         var item = new Users {
             Username = obj.Username, Pass = obj.Pass, FName = obj.FName, LName = obj.LName
         };
         db.Users.Add(item);
         db.SaveChanges();
     }
 }
Esempio n. 7
0
 private void DeleteTask(MTasks task)
 {
     using (var db = new Index.BloggingContext())
     {
         var item =
             (from m in db.MTasks
              where m.TaskId == task.TaskId
              select m).First();
         db.MTasks.Remove(item);
         db.SaveChanges();
     }
 }
Esempio n. 8
0
 private void NewTask(MTasks task)
 {
     using (var db = new Index.BloggingContext())
     {
         var now  = DateTime.Now;//.ToString("MM/dd/yyyy HH:mm:ss");
         var item = new MTasks {
             Title = task.Title, Description = task.Description, Creator = task.Creator, EstTime = task.EstTime, Assigned = task.Assigned, CreTime = now, Final = false
         };
         db.MTasks.Add(item);
         db.SaveChanges();
     }
 }
Esempio n. 9
0
 private List <TimeSpent> GetTTime()
 {
     using (var db = new Index.BloggingContext())
     {
         MTasks user   = (MTasks)tasksBindingSource1.Current;
         var    result =
             (from t in db.TimeSpent
              where t.TheTask == user.TaskId
              select t).ToList();
         return(result);
     }
 }
Esempio n. 10
0
 private void DeleteUser(Users user)
 {
     using (var db = new Index.BloggingContext())
     {
         var item =
             (from u in db.Users
              where u.UserId == user.UserId
              select u).First();
         db.Users.Remove(item);
         db.SaveChanges();
     }
 }
Esempio n. 11
0
 public void DeleteTime(TimeSpent time)
 {
     using (var db = new Index.BloggingContext())
     {
         var item =
             (from t in db.TimeSpent
              where t.TSId == time.TSId
              select t).First();
         db.TimeSpent.Remove(item);
         db.SaveChanges();
     }
 }
Esempio n. 12
0
        public void NewTime(TimeSpent time)
        {
            using (var db = new Index.BloggingContext())

            {
                var now  = DateTime.Now;
                var item = new TimeSpent {
                    TheAssi = time.TheAssi, TheTask = time.TheTask, FinTime = now, Hours = time.Hours
                };
                db.TimeSpent.Add(item);
                db.SaveChanges();
            }
        }
Esempio n. 13
0
 private void FinishTask(MTasks task)
 {
     using (var db = new Index.BloggingContext())
     {
         var item =
             (from m in db.MTasks
              where m.TaskId == task.TaskId
              select m).First();
         db.Database.ExecuteSqlCommand("UPDATE MTasks" +
                                       " SET Final={0}" +
                                       " WHERE TaskId={1}", true, task.TaskId);
         db.SaveChanges();
     }
 }
Esempio n. 14
0
 private void EditTask(MTasks task)
 {
     using (var db = new Index.BloggingContext())
     {
         var item =
             (from m in db.MTasks
              where m.TaskId == task.TaskId
              select m).First();
         db.Database.ExecuteSqlCommand("UPDATE MTasks" +
                                       " SET Title={0},Description={1},EstTime={2},Assigned={3},Final={4}" +
                                       " WHERE TaskId={5}", task.Title, task.Description,
                                       task.EstTime, task.Assigned, task.Final, task.TaskId);
         db.SaveChanges();
     }
 }
Esempio n. 15
0
 private void EditUser(Users user)
 {
     using (var db = new Index.BloggingContext())
     {
         var item =
             (from u in db.Users
              where u.UserId == user.UserId
              select u).First();
         db.Database.ExecuteSqlCommand("UPDATE Users" +
                                       " SET Username={0},Pass={1},FName={2},LName={3}" +
                                       " WHERE UserId={4}", user.Username, user.Pass, user.FName,
                                       user.LName, user.UserId);
         db.SaveChanges();
     }
 }