예제 #1
0
        private void Login_Click(object sender, EventArgs e)
        {
            var user = Cache.Get <User>("user");

            using (var ctx = new Database.ApplicationContext())
            {
                var secondUser = ctx.Users.FirstOrDefault(it => it.Email == email.Text);

                if (secondUser == null)
                {
                    Add_Failed.Visible = true;
                    return;
                }

                Add_Sucess.Visible = true;

                var secUserList = ctx.FriendDetails.Where(it => it.UserId == secondUser.UserId).ToList();
                var userList    = ctx.FriendDetails.Where(it => it.UserId == user.UserId).ToList();

                foreach (var secUserDetail in secUserList)
                {
                    if (userList.FirstOrDefault(it => it.FriendId == secUserDetail.FriendId) != null)
                    {
                        Add_Failed_2.Visible = true;
                    }
                }

                var friendEntity = ctx.Friends.Add(new Friend()
                {
                    AreFriends = false
                });

                ctx.SaveChanges();

                var friend = friendEntity.Entity;

                ctx.FriendDetails.Add(new FriendDetail()
                {
                    FriendId = friend.FriendId,
                    UserId   = user.UserId,
                    Type     = "Sender"
                });
                ctx.FriendDetails.Add(new FriendDetail()
                {
                    FriendId = friend.FriendId,
                    UserId   = secondUser.UserId,
                    Type     = "ToUser"
                });

                ctx.SaveChanges();
            }
        }
예제 #2
0
        private void table_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var taskStatus = table.SelectedCells[0].Value as string;

                using (var ctx = new Database.ApplicationContext())
                {
                    var task = ctx.ProjectTasks

                               .Where(it => it.Summary == taskStatus)
                               .FirstOrDefault();

                    task.Status     = "Завершено";
                    task.FinishedOn = DateTime.Now;
                    ctx.ProjectTasks.Update(task);
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Для завершения задания нажмите дважды на поле 'Название'", "Error #1", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var user = Cache.Get <User>("user");

            table.Columns.Clear();
            using (var ctx = new Database.ApplicationContext())
            {
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Название",
                    DataPropertyName = "Summary"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Описание",
                    DataPropertyName = "Description"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Приоритет",
                    DataPropertyName = "Priority"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Статус",
                    DataPropertyName = "Status"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Создан",
                    DataPropertyName = "CreatedOn"
                });
                table.AutoGenerateColumns = false;

                table.DataSource = ctx.ProjectTasks.Where(it => it.ProjectId == user.UserId).ToList()
                                   .ToList();
            }
        }
예제 #3
0
        private void Create_Click(object sender, EventArgs e)
        {
            if (summary.Text != "" || description.Text != "")
            {
                using (var ctx = new Database.ApplicationContext())
                {
                    var user = Cache.Get <User>("user");
                    ctx.SoloProjects.Add(new Database.SoloProject()
                    {
                        Summary     = summary.Text,
                        Description = description.Text,
                        Status      = "В процессе",
                        CreatedOn   = DateTime.Now,
                        UserId      = user.UserId
                    });
                    ctx.SaveChanges();

                    Add_Sucess.Visible = true;
                }
            }
            else
            {
                label5.Visible = true;
                return;
            }

            refreshTable();
        }
예제 #4
0
        private void Create_Click(object sender, EventArgs e)
        {
            var task = Cache.Get <Task>("task_value");
            var user = Cache.Get <User>("user");

            if (com.Text != "")
            {
                using (var ctx = new Database.ApplicationContext())
                {
                    ctx.Commentaries.Add(new Database.Commentary()
                    {
                        TaskId    = task.TaskId,
                        UserId    = user.UserId,
                        CreatedOn = DateTime.Now,
                        Text      = com.Text
                    });

                    ctx.SaveChanges();
                }
                this.Close();
            }
            else
            {
                label5.Visible = true;
            }
        }
예제 #5
0
        private void label2_Click(object sender, EventArgs e)
        {
            var teamName = table.SelectedCells[0].Value as string;
            var user     = Cache.Get <User>("user");

            if (teamName == null)
            {
                Add_Failed_2.Visible = true;
                return;
            }

            using (var ctx = new Database.ApplicationContext())
            {
                var team = ctx.Teams.First(it => it.TeamName == teamName);
                ctx.UsersInTeams.Remove(ctx.UsersInTeams.FirstOrDefault(it => it.TeamId == team.TeamId && it.UserId == user.UserId));

                ctx.SaveChanges();
            }

            table.Columns.Clear();
            using (var ctx = new Database.ApplicationContext())
            {
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Название",
                    DataPropertyName = "TeamName"
                });
                table.AutoGenerateColumns = false;

                table.DataSource = ctx.UsersInTeams.Where(it => it.UserId == user.UserId).Select(it => it.Team)
                                   .ToList();
            }
        }
예제 #6
0
        private void label4_Click(object sender, EventArgs e)
        {
            try
            {
                var taskName = table.SelectedCells[0].Value as string;

                using (var ctx = new Database.ApplicationContext())
                {
                    ctx.SoloTasks.Remove(ctx.SoloTasks.First(it => it.Summary == taskName));
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Список заданий пуст!", "Error #2", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var user = Cache.Get <User>("user");

            table.Columns.Clear();
            using (var ctx = new Database.ApplicationContext())
            {
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Название",
                    DataPropertyName = "Summary"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Описание",
                    DataPropertyName = "Description"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Приоритет",
                    DataPropertyName = "Priority"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Статус",
                    DataPropertyName = "Status"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Создан",
                    DataPropertyName = "CreatedOn"
                });
                table.AutoGenerateColumns = false;
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Завершено",
                    DataPropertyName = "FinishedOn"
                });
                table.AutoGenerateColumns = false;

                table.DataSource = ctx.SoloTasks.Where(it => it.UserId == user.UserId).ToList()
                                   .ToList();
            }
        }
예제 #7
0
        private void Login_Click(object sender, EventArgs e)
        {
            var team = Cache.Get <Team>("team");
            var user = Cache.Get <User>("user");

            var userEmail = table.SelectedCells[0].Value as string;

            using (var ctx = new Database.ApplicationContext())
            {
                var secUser = ctx.Users.FirstOrDefault(it => it.Email == userEmail);

                if (secUser == null)
                {
                    Auth_Failed.Visible = true;
                    return;
                }

                if (ctx.UsersInTeams.FirstOrDefault(it => it.UserId == secUser.UserId && it.TeamId == team.TeamId) !=
                    null)
                {
                    label2.Visible = true;
                    return;
                }

                var allFriends = ctx.FriendDetails.Include(it => it.Friend).Where(it => it.UserId == user.UserId && it.Friend.AreFriends).Select(it => it.Friend)
                                 .ToList();

                var ok = false;
                foreach (var friend in allFriends)
                {
                    var fr = ctx.FriendDetails.FirstOrDefault(it =>
                                                              it.FriendId == friend.FriendId && it.UserId != user.UserId && it.UserId == secUser.UserId);

                    if (fr != null)
                    {
                        ok = true;
                        break;
                    }
                }

                if (!ok)
                {
                    label3.Visible = true;
                    return;
                }

                ctx.UsersInTeams.Add(new UserInTeam()
                {
                    TeamId = team.TeamId,
                    UserId = secUser.UserId
                });
                ctx.SaveChanges();
                Add_Sucess.Visible = true;
            }
            refreshTable();
            Close();
        }
예제 #8
0
        private void table_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var projectName = table.SelectedCells[0].Value as string;

                using (var ctx = new Database.ApplicationContext())
                {
                    var project = ctx.SoloProjects

                                  .Where(it => it.Status == projectName)
                                  .FirstOrDefault();

                    project.Status = "Завершено";
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Для завершения проекта нажмите дважды на поле 'Статус'", "Error #1", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var user = Cache.Get <User>("user");

            table.Columns.Clear();
            using (var ctx = new Database.ApplicationContext())
            {
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Название",
                    DataPropertyName = "Summary"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Описание",
                    DataPropertyName = "Description"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Статус",
                    DataPropertyName = "Status"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Создан",
                    DataPropertyName = "CreatedOn"
                });
                table.AutoGenerateColumns = false;

                table.DataSource = ctx.SoloProjects.Where(it => it.UserId == user.UserId).ToList()
                                   .ToList();
            }
        }
예제 #9
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            var task = Cache.Get <Database.Task>("task_value");

            using (var ctx = new Database.ApplicationContext())
            {
                task.Status     = "Завершено";
                task.FinishedOn = DateTime.Now;
                ctx.Tasks.Update(task);
                ctx.SaveChanges();
            }
            Close();
        }
예제 #10
0
        private void Create_Click(object sender, EventArgs e)
        {
            var user = Cache.Get <User>("user");


            if (team_name.Text != "")
            {
                using (var ctx = new Database.ApplicationContext())
                {
                    var entryEntity = ctx.Teams.Add(new Team()
                    {
                        TeamName = team_name.Text
                    });
                    ctx.SaveChanges();

                    var team = entryEntity.Entity;

                    //  ctx.Users.Where(it => it.isAdmin == true);
                    user.isAdmin = true;
                    ctx.Users.Update(user);

                    ctx.UsersInTeams.Add(new UserInTeam()
                    {
                        TeamId = team.TeamId,
                        UserId = user.UserId
                    });
                    ctx.SaveChanges();
                }
                Add_Sucess.Visible = true;

                refreshTable();
            }
            else
            {
                label5.Visible = true;
                return;
            }
        }
예제 #11
0
        private void label2_Click(object sender, EventArgs e)
        {
            try
            {
                var projectName = table.SelectedCells[0].Value as string;

                using (var ctx = new Database.ApplicationContext())
                {
                    ctx.SoloProjects.Remove(ctx.SoloProjects.First(it => it.Summary == projectName));
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
            }

            var user = Cache.Get <User>("user");

            table.Columns.Clear();
            using (var ctx = new Database.ApplicationContext())
            {
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Название",
                    DataPropertyName = "Summary"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Описание",
                    DataPropertyName = "Description"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Статус",
                    DataPropertyName = "Status"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Создан",
                    DataPropertyName = "CreatedOn"
                });
                table.AutoGenerateColumns = false;

                table.DataSource = ctx.SoloProjects.Where(it => it.UserId == user.UserId).ToList()
                                   .ToList();
            }
        }
예제 #12
0
        private void Create_Click(object sender, EventArgs e)
        {
            var taskname = Cache.Get <string>("project_name");

            try
            {
                using (var ctx = new Database.ApplicationContext())
                {
                    if (Convert.ToString(priority.Text) == "" || summary.Text == "")
                    {
                        label5.Visible = true;
                        label4.Visible = false;
                    }
                    else
                    {
                        if (Convert.ToInt32(priority.Text) > 0 && Convert.ToInt32(priority.Text) <= 10)
                        {
                            var project = ctx.SoloProjects.First(it => it.Summary == taskname);

                            ctx.ProjectTasks.Add(new Database.ProjectTask()
                            {
                                Summary     = summary.Text,
                                Description = description.Text,
                                Priority    = priority.Text,
                                Status      = "В процессе",
                                CreatedOn   = DateTime.Now,
                                ProjectId   = project.SoloProjectId
                            });
                            Add_Sucess.Visible = true;
                            label4.Visible     = false;
                            ctx.SaveChanges();
                        }
                        else
                        {
                            label4.Visible = true;
                            label5.Visible = false;
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Введите число в поле приоритета");
            }

            refreshTable();
        }
예제 #13
0
        private void Create_Click(object sender, EventArgs e)
        {
            try
            {
                using (var ctx = new Database.ApplicationContext())
                {
                    if (Convert.ToString(priority.Text) == "" || summary.Text == "")
                    {
                        label5.Visible = true;
                        label4.Visible = false;
                    }
                    else
                    {
                        if (Convert.ToInt32(priority.Text) > 0 && Convert.ToInt32(priority.Text) <= 10)
                        {
                            ctx.Tasks.Add(new Database.Task()
                            {
                                Summary     = summary.Text,
                                Description = description.Text,
                                Priority    = priority.Text,
                                Status      = "В процессе",
                                CreatedOn   = DateTime.Now,
                                TeamId      = Cache.Get <Team>("team").TeamId,
                                UserId      = ctx.Users.First(it => it.Email == (comboBox1.SelectedItem as string)).UserId
                            });
                            Add_Failed_2.Visible = true;
                            label4.Visible       = false;
                            ctx.SaveChanges();
                        }
                        else
                        {
                            label4.Visible = true;
                            label5.Visible = false;
                            return;
                        }
                    }
                }


                refreshTable();
            }
            catch (Exception)
            {
                MessageBox.Show("Введите число в поле приоритета");
                return;
            }
        }
예제 #14
0
        private void table_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var cells = table.SelectedCells[0].Value as string;

            using (var ctx = new Database.ApplicationContext())
            {
                var task = ctx.ProjectTasks.First(it => it.Summary == cells);
                task.Status     = "Завершено";
                task.FinishedOn = DateTime.Now;
                ctx.ProjectTasks.Update(task);
                ctx.SaveChanges();

                table.Columns.Clear();
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Название",
                    DataPropertyName = "Summary"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Описание",
                    DataPropertyName = "Description"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Приоритет",
                    DataPropertyName = "Priority"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Статус",
                    DataPropertyName = "Status"
                });
                table.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText       = "Создан",
                    DataPropertyName = "CreatedOn"
                });
                table.AutoGenerateColumns = false;
                var taskname = Cache.Get <string>("project_name");
                table.DataSource = ctx.ProjectTasks.Where(it => it.SoloProject.Summary == taskname).ToList();
            }
        }
예제 #15
0
        private void Reg_Click_1(object sender, EventArgs e)
        {
            try
            {
                using (var ctx = new Database.ApplicationContext())
                {
                    if (!email.Text.Contains("@gmail.com") && !email.Text.Contains("@yandex.by") && !email.Text.Contains("@mail.ru"))
                    {
                        Reg_Failed.Visible = true;
                        return;
                    }
                    else
                    {
                        ctx.Users.Add(new User()
                        {
                            Email    = email.Text,
                            Password = password.Text
                        });
                        ctx.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Пользователь с таким e-mail уже зарегистрирован");
                return;
            }

            Reg_Sucess.Visible = true;

            Auth_Form auth = new Auth_Form();

            auth.Show();

            this.Close();
        }