Esempio n. 1
0
        private void Login()
        {
            var user = MainContext.GetEntities <User>().FirstOrDefault(a => a.Id == UserId && a.Password == Password);

            if (user != null && UserId != "Any")
            {
                var Auth    = new Authorize();
                var machine = MainContext.GetEntities <Machine>().FirstOrDefault(a => a.ProcessorId == Machine.GetProcessorId() && a.Name == Environment.MachineName);
                if (machine == null)
                {
                    machine             = new Machine();
                    machine.ProcessorId = Machine.GetProcessorId();
                    machine.Name        = Environment.MachineName;
                }
                Auth.Machine = machine;
                Auth.User    = user;
                MainContext.AddEntity(Auth);
                MainContext.SaveChanges();
                Helper.OpenWindow <MainViewModel>();
                TryClose();
            }
            else
            {
                Model.Helpers.Message.ShowErrorMsg("Incorrect login or password");
            }
        }
Esempio n. 2
0
 public void LoadData()
 {
     base.Load();
     Users    = new ObservableCollection <User>(MainContext.GetEntities <User>());
     Projects = new ObservableCollection <Project>(MainContext.GetEntities <Project>());
     NotifyTasks();
 }
Esempio n. 3
0
 public MenuViewModel()
 {
     Context       = new MainContext();
     Subjects      = Context.GetEntities <Subject>().ToList();
     TestViewModel = new TestViewModel();
     ActiveItem    = TestViewModel;
 }
Esempio n. 4
0
        private void SaveCmd()
        {
            try
            {
                var exists = false;
                try
                {
                    exists = MainContext.GetEntities<DTask>().Any(t => t.PeriodId == SelectedTask.Period.Id &&
                                    t.Period.ProjectId == SelectedTask.Period.Project.Id && t.Title == SelectedTask.Title && t.Id != SelectedTask.Id);
                }
                catch
                {

                }
                if (exists)
                {
                    throw new Exception("This Task is Already exists! Change title of Task!");
                }
                MainContext.SaveChanges();
                string sql = string.Format("INSERT INTO [timer_types] (pmo_number, description) VALUES ('{0}', '{1}')", SelectedTask.Id.ToString(), SelectedTask.Title);
                LocalSqllite.ExecSQLCommand(sql);
                Model.Helpers.Message.ShowComMsg("Save Complated!");
            }
            catch (Exception ex)
            {
                string msg = Helper.GetMessage(ex);
                Model.Helpers.Message.ShowErrorMsg(msg);
            }
        }
Esempio n. 5
0
 public MyUsersViewModel()
 {
     Users       = MainContext.GetEntities <User>().Where(u => u.Id != "Any").ToList();
     Possessions = new List <UserPossession>();
     Possessions.Add(UserPossession.Expert);
     Possessions.Add(UserPossession.Junior);
     Possessions.Add(UserPossession.Middle);
     Possessions.Add(UserPossession.Super);
 }
Esempio n. 6
0
 private void AddCommentCmd()
 {
     if (Task != null && TextComment != "")
     {
         Comment comment = new Comment();
         comment.Date = DateTime.Now;
         comment.Task = Task;
         comment.User = MainContext.GetEntities <User>().Single(a => a.Id == User.Id);
         comment.Text = TextComment;
         MainContext.AddEntity(comment);
         MainContext.SaveChanges();
         TextComment = "";
     }
 }
Esempio n. 7
0
        public TaskViewModel(DTask task)
        {
            Users = new ObservableCollection<User>(MainContext.GetEntities<User>());
            Periods = new ObservableCollection<Period>(MainContext.GetEntities<Period>());
            Tasks = new ObservableCollection<DTask>(MainContext.GetEntities<DTask>());
            Statuses.Add(Status.NotStarted);
            Statuses.Add(Status.InProgress);
            Statuses.Add(Status.Done);

            Weights.Add(Weight.Low);
            Weights.Add(Weight.Big);
            Weights.Add(Weight.High);
            SelectedTask = MainContext.GetEntities<DTask>().Single(a => a.Id == task.Id);

        }
Esempio n. 8
0
 private void AddCmd()
 {
     if (!MainContext.GetEntities <User>().Any(a => a.Id == UserId))
     {
         User user = new User
         {
             Id         = UserId,
             Password   = Password,
             Possession = Possession
         };
         MainContext.AddEntity(user);
         MainContext.SaveChanges();
         Message.ShowComMsg("You added new User");
         TryClose();
     }
 }
Esempio n. 9
0
        public void LogIn()
        {
            using (MainContext context = new MainContext())
            {
                var userExists = context.GetEntities <User>().Any(s => s.Login == LoginText && s.Password == PasswordText);

                if (userExists)
                {
                    NavigationHelper.OpenWindow <MenuViewModel>();
                    TryClose();
                }
                else
                {
                    MessageBox.Show("Error");
                }
            }
        }
Esempio n. 10
0
        public TaskViewModel(bool create_new_task = false)
        {
            Users = new ObservableCollection<User>(MainContext.GetEntities<User>());
            Periods = new ObservableCollection<Period>(MainContext.GetEntities<Period>());
            Tasks = new ObservableCollection<DTask>(MainContext.GetEntities<DTask>());
            Statuses.Add(Status.NotStarted);
            Statuses.Add(Status.InProgress);
            Statuses.Add(Status.Done);

            Weights.Add(Weight.Low);
            Weights.Add(Weight.Big);
            Weights.Add(Weight.High);

            if (create_new_task)
            {
                AddTaskCmd();
            }
        }
Esempio n. 11
0
 private void SaveCmd()
 {
     try
     {
         var exists_period = MainContext.GetEntities <Period>().Any(a => a.ProjectId == SelectedPeriod.Project.Id && a.Title == SelectedPeriod.Title && a.Id != SelectedPeriod.Id);
         if (exists_period)
         {
             throw new Exception("SelectedProject already has this Period (Title must be diffenrent) ");
         }
         MainContext.SaveChanges();
         Message.ShowComMsg("Save Complated!");
     }
     catch (Exception ex)
     {
         string msg = Helper.GetMessage(ex);
         Message.ShowErrorMsg("Project is not selected or SelectedProject already has this Period\n" + msg);
     }
 }
Esempio n. 12
0
 public void Load()
 {
     MainContext = Global.MainContext;
     try
     {
         var auth = MainContext.GetEntities <Authorize>().Single(a => a.Machine.ProcessorId == Machine.GetProcessorId());
         Project = MainContext.GetEntities <Project>().OrderByDescending(a => a.Status == Status.InProgress).FirstOrDefault();
         if (Project != null)
         {
             CurrentPeriod = Project.Periods.OrderByDescending(d => d.Status == Status.InProgress).OrderByDescending(a => a.From).FirstOrDefault();
         }
         User = auth.User;
     }
     catch (Exception ex)
     {
         string msg = Helper.GetMessage(ex);
         Model.Helpers.Message.ShowErrorMsg(msg);
     }
 }
Esempio n. 13
0
 void LoadTask(DTask dTask)
 {
     Task = MainContext.GetEntities <DTask>().Single(a => a.Id == dTask.Id);
 }
Esempio n. 14
0
 void LoadProjects()
 {
     Projects = new ObservableCollection <Project>(MainContext.GetEntities <Project>().OrderByDescending(s => s.Status == Status.InProgress));
 }
Esempio n. 15
0
 void LoadPeriods()
 {
     Periods  = new ObservableCollection <Period>(MainContext.GetEntities <Period>().OrderByDescending(s => s.Status));
     Projects = new ObservableCollection <Project>(MainContext.GetEntities <Project>());
 }