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; } }
private void label2_Click(object sender, EventArgs e) { var user = Cache.Get <User>("user"); var selectedRows = table.SelectedCells[0].Value as string; using (var ctx = new Database.ApplicationContext()) { var allFriends = ctx.FriendDetails.Include(it => it.Friend).Where(it => it.UserId == user.UserId && it.Friend.AreFriends).Select(it => it.Friend) .ToList(); foreach (var friend in allFriends) { var fr = ctx.FriendDetails.FirstOrDefault(it => it.FriendId == friend.FriendId && it.User.Email == selectedRows); if (fr != null) { ctx.Friends.Remove(friend); ctx.SaveChanges(); } } } table.Columns.Clear(); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Surname", HeaderText = "Фамилия" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Firstname", HeaderText = "Имя" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Lastname", HeaderText = "Отчество" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Email", HeaderText = "Электронная почта" }); table.AutoGenerateColumns = false; using (var ctx = new ApplicationContext()) { var allFriends = ctx.FriendDetails.Include(it => it.Friend).Where(it => it.UserId == user.UserId && it.Friend.AreFriends).Select(it => it.Friend) .ToList(); var list = new List <User>(); foreach (var friend in allFriends) { list.AddRange(ctx.FriendDetails.Where(it => it.FriendId == friend.FriendId && it.UserId != user.UserId).Select(it => it.User).ToList()); } table.DataSource = list; } }
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(); } }
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(); }
public Project_Form() { InitializeComponent(); var user = Cache.Get <User>("user"); 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(); } }
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(); } }
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(); } }
private void timer1_Tick(object sender, EventArgs e) { using (var ctx = new Database.ApplicationContext()) { label18.Text = Convert.ToString(ctx.Users.Count()); label19.Text = Convert.ToString(ctx.SoloProjects.Count()); label20.Text = Convert.ToString(ctx.Teams.Count()); } }
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(); }
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(); } }
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(); } }
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(); }
private void bunifuThinButton21_Click(object sender, EventArgs e) { User user; using (var ctx = new Database.ApplicationContext()) { user = ctx.Users.FirstOrDefault(it => it.Email == email.Text); if (user == null) { label3.Visible = true; return; } Cache.Add("user", user); } user = Cache.Get <User>("user"); var fromAddress = new MailAddress("*****@*****.**", "Trino Support"); var toAddress = user.Email; const string fromPassword = "******"; const string subject = "Тех.Поддержка Trino"; string body = "<h2>Восстановление пароля</h2>" + "Здравствуйте, " + user.Firstname + "<br><br><br>Ваш пароль от аккаунта Trino: " + user.Password + "<br><br><br>С уважением, команда Trino"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(Convert.ToString(fromAddress), toAddress) { IsBodyHtml = true, Subject = subject, Body = body }) { smtp.Send(message); Recovery_Sucess.Visible = true; } }
private void label12_Click(object sender, EventArgs e) { Task_Creation task_Creation = new Task_Creation(() => { 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(); } }); task_Creation.Show(); }
private void label1_Click(object sender, EventArgs e) { Friends_Req_Form FRF = new Friends_Req_Form(() => { table.Columns.Clear(); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Surname", HeaderText = "Фамилия" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Firstname", HeaderText = "Имя" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Lastname", HeaderText = "Отчество" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Email", HeaderText = "Электронная почта" }); table.AutoGenerateColumns = false; var user = Cache.Get <User>("user"); using (var ctx = new ApplicationContext()) { var allFriends = ctx.FriendDetails.Include(it => it.Friend).Where(it => it.UserId == user.UserId && it.Friend.AreFriends).Select(it => it.Friend) .ToList(); var list = new List <User>(); foreach (var friend in allFriends) { list.AddRange(ctx.FriendDetails.Where(it => it.FriendId == friend.FriendId && it.UserId != user.UserId).Select(it => it.User).ToList()); } table.DataSource = list; } table.ColumnHeadersVisible = true; }); FRF.Show(); }
public Team_Task_Creation(Action refreshTable = null) { this.refreshTable = refreshTable; InitializeComponent(); using (var ctx = new Database.ApplicationContext()) { var users = ctx.UsersInTeams.Where(it => it.TeamId == Cache.Get <Team>("team").TeamId).Include(it => it.User).Select(it => it.User).ToList(); foreach (var user in users) { comboBox1.Items.Add(user.Email); } } }
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(); } }
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(); }
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; } }
public Friends_Form() { InitializeComponent(); // Surname, Firstname, Lastname, Email table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Surname", HeaderText = "Фамилия" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Firstname", HeaderText = "Имя" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Lastname", HeaderText = "Отчество" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Email", HeaderText = "Электронная почта" }); table.AutoGenerateColumns = false; var user = Cache.Get <User>("user"); using (var ctx = new ApplicationContext()) { var allFriends = ctx.FriendDetails.Include(it => it.Friend).Where(it => it.UserId == user.UserId && it.Friend.AreFriends).Select(it => it.Friend) .ToList(); var list = new List <User>(); foreach (var friend in allFriends) { list.AddRange(ctx.FriendDetails.Where(it => it.FriendId == friend.FriendId && it.UserId != user.UserId).Select(it => it.User).ToList()); } table.DataSource = list; } table.ColumnHeadersVisible = true; }
public Friends_Req_Form(Action refreshTable = null) { this.refreshTable = refreshTable; InitializeComponent(); var user = Cache.Get <User>("user"); Subscribers.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Surname", HeaderText = "Фамилия" }); Subscribers.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Firstname", HeaderText = "Имя" }); Subscribers.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Lastname", HeaderText = "Отчество" }); Subscribers.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Email", HeaderText = "Электронная почта" }); using (var ctx = new ApplicationContext()) { var allFriends = ctx.FriendDetails.Include(it => it.Friend).Where(it => it.UserId == user.UserId && it.Type == "ToUser" && !it.Friend.AreFriends).Select(it => it.Friend) .ToList(); var list = new List <User>(); foreach (var friend in allFriends) { list.AddRange(ctx.FriendDetails.Where(it => it.FriendId == friend.FriendId && it.UserId != user.UserId).Select(it => it.User).ToList()); } Subscribers.AutoGenerateColumns = false; Subscribers.DataSource = list; } }
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(); } }
private void Login_Click(object sender, EventArgs e) { /* * var Email = email.Text; * var Password = password.Text; * var url = $"http://localhost:1337/login?email={email}&password={password}"; * var request = WebRequest.Create(url); * var response = (HttpWebResponse)request.GetResponse(); * * if (response.StatusCode == HttpStatusCode.OK) * { * MessageBox.Show("пользователь авторизован"); * } * else * { * MessageBox.Show("Ошибка. Повторите ввод данных"); * } */ using (var ctx = new Database.ApplicationContext()) { var user = ctx.Users.FirstOrDefault(it => it.Email == email.Text && it.Password == password.Text); if (user == null) { Auth_Failed.Visible = true; email.LineFocusedColor = Color.Red; password.LineFocusedColor = Color.Red; email.LineIdleColor = Color.Red; password.LineIdleColor = Color.Red; Recovery_button.Visible = true; return; } Cache.Add("user", user); } Preloader_Auth preloader = new Preloader_Auth(); preloader.Show(); }
public Team_Form() { InitializeComponent(); var user = Cache.Get <User>("user"); 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(); } }
private void label1_Click(object sender, EventArgs e) { if (table.SelectedRows.Count == 0) { Add_Failed_2.Visible = true; return; } Team team; using (var ctx = new Database.ApplicationContext()) { team = ctx.Teams.FirstOrDefault(it => it.TeamName == (table.SelectedCells[0].Value as string)); } Cache.Add("team", team); Team_View team_View = new Team_View(); team_View.Show(); Close(); }
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; } }
private void label12_Click(object sender, EventArgs e) { Team_Creation team_Creation = new Team_Creation(() => { table.Columns.Clear(); using (var ctx = new Database.ApplicationContext()) { var user = Cache.Get <User>("user"); 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(); } }); team_Creation.Show(); }
public Team_Users_Add(Action refreshTable = null) { this.refreshTable = refreshTable; InitializeComponent(); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Surname", HeaderText = "Фамилия" }); table.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Email", HeaderText = "E-mail" }); table.AutoGenerateColumns = false; var user = Cache.Get <User>("user"); var team = Cache.Get <Team>("team"); using (var ctx = new Database.ApplicationContext()) { var allFriends = ctx.FriendDetails.Include(it => it.Friend).Where(it => it.UserId == user.UserId && it.Friend.AreFriends).Select(it => it.Friend) .ToList(); var list = new List <User>(); foreach (var friend in allFriends) { list.AddRange(ctx.FriendDetails.Where(it => it.FriendId == friend.FriendId && it.UserId != user.UserId).Select(it => it.User).ToList()); } table.DataSource = list; } table.ColumnHeadersVisible = true; }
public Project_View() { InitializeComponent(); var taskname = Cache.Get <string>("project_name"); 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.SoloProject.Summary == taskname).ToList(); } }
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(); }