private void AddBoard_Click(object sender, EventArgs e) { if (BoardNameTextBox.Text == "") { MessageBox.Show("Please enter a valid name for the board."); } else { // Adding to DB LinqToSQLCRUD.CreateBoard(BoardNameTextBox.Text, userId); // Adding to TabControl var lastBoard = LinqToSQLCRUD.GetLastBoardInserted(); foreach (var result in lastBoard) { Board aBoard = new Board(result.BoardId, result.BoardName, (int)result.UserId); BoardArea.TabPages.Add(aBoard); BoardArea.SelectedTab = aBoard; } BoardNameTextBox.Clear(); } }
private void AddList_Click(object sender, EventArgs e) { if (ListNameTextBox.Text == "") { MessageBox.Show("Please enter a valid name for the list."); } else { // Adding List to DB LinqToSQLCRUD.CreateList(ListNameTextBox.Text, this.BoardId); // Adding to ListArea var lastList = LinqToSQLCRUD.GetLastListInserted(); // getting Id generated by MSSQL foreach (var result in lastList) { List aList = new List(result.ListId, result.ListName, (int)result.BoardId); aList.BackColor = Color.FromArgb(rgb.Next(minValue, maxValue), rgb.Next(minValue, maxValue), rgb.Next(minValue, maxValue)); ListArea.Controls.Add(aList); } ListNameTextBox.Clear(); } }
private void AddTask_Click(object sender, EventArgs e) { taskName = taskInputBox.Text; if (taskName != "") { //Add Task to DB LinqToSQLCRUD.CreateTask(taskName, this.ListId); //Reading the record on DB to display on FlowLayoutPanel var lastTask = LinqToSQLCRUD.GetLastTaskInserted(); foreach (var result in lastTask) { LinkLabel taskLink = new LinkLabel(); taskLink.Text = taskMarker + result.TaskName + "\n"; //task.TaskName; taskLink.Tag = result.TasktId; taskLink.Font = taskFont; taskLink.LinkColor = taskLinkColor; taskLink.ActiveLinkColor = taskActiveLinkColor; // passing taskId to build up its view on the function ViewTask_Click taskLink.Click += (mySender, myEventArgs) => ViewTask_Click(mySender, myEventArgs, (int)taskLink.Tag); taskPanel.Controls.Add(taskLink); } taskInputBox.Text = ""; } else { MessageBox.Show("Please enter a title for the task."); } }
private void DeleteListButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you really want to delete list '" + ListNameLabel.Text + "'? \rThis action is not reversible.", "DELETE BOARD!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int listIdToBeDeleted = (ListId); LinqToSQLCRUD.DeleteList(listIdToBeDeleted); // Destroy component in the ListArea this.Dispose(); } }
public Home(int loggedUser) { InitializeComponent(); userId = loggedUser; var boards = LinqToSQLCRUD.ReadBoards(userId); foreach (var board in boards) { Board tab = new Board(board.BoardId, board.BoardName, board.BoardId); BoardArea.TabPages.Add(tab); } }
public BoardContent(int BoarId) { this.BoardId = BoarId; InitializeComponent(); var lists = LinqToSQLCRUD.ReadLists(BoarId); foreach (var list in lists) { List listUserControl = new List(list.ListId, list.ListName, (int)list.BoardId); ListArea.Controls.Add(listUserControl); } }
private void DeleteTaskButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you really want to delete the current task? \rThis action is not reversible.", "DELETE TASK!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { LinqToSQLCRUD.DeleteTask(TasktId); DestroyIt(); Dispose(); } else { Debug.WriteLine(this.Parent); } }
private Dictionary <int, string> PopulateStatusList() { var result = new Dictionary <int, string>(); var status = LinqToSQLCRUD.GetStatus(); foreach (var record in status) { result.Add(record.StatusId, record.StatusName); } return(result); }
private Dictionary <int, string> PopulateUserList() { var result = new Dictionary <int, string>(); var users = LinqToSQLCRUD.GetUsers(); foreach (var user in users) { result.Add(user.UserId, user.UserName); } return(result); }
private void DeleteBoard_Click(object sender, EventArgs e) { if (BoardArea.TabCount > 0) { if(MessageBox.Show("Do you really want to delete the current board? \rThis action is not reversible.", "DELETE BOARD!" , MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int boardIdToBeDeleted = (int)BoardArea.SelectedTab.GetType().GetProperty("BoardId").GetValue(BoardArea.SelectedTab, null); LinqToSQLCRUD.DeleteBoard(boardIdToBeDeleted); BoardArea.TabPages.Remove(BoardArea.SelectedTab); } } else { MessageBox.Show("You do not have any boards to be deleted."); } }
private void ViewTask_Click(object sender, EventArgs e, int taskId) { var result = LinqToSQLCRUD.GetTaskById(taskId); foreach (var item in result) { if (item.TaskDescription is null) // when task was created or not modified { Task task = new Task(item.TasktId, item.TaskName, (int)item.TaskList); task.DestroyIt += () => Refresh(this.ListId); // it updates the list once a task is delete it task.ShowDialog(); } else // once task was already created and updated { Task task = new Task(item.TasktId, item.TaskName, item.TaskDescription, (DateTime)item.TaskDue, (int)item.TaskWho, (int)item.TaskStatus, (int)item.TaskList); task.DestroyIt += () => Refresh(this.ListId); task.ShowDialog(); } } }
private void SaveChangesButton_Click(object sender, EventArgs e) { var id = this.TasktId; string what = TextBoxDescription.Text; DateTime when = DueTimePicker.Value; KeyValuePair <int, string> selectedWho = (KeyValuePair <int, string>)WhoBox.SelectedItem; int who = selectedWho.Key; KeyValuePair <int, string> selectedStatus = (KeyValuePair <int, string>)StatusBox.SelectedItem; int status = selectedStatus.Key; try { LinqToSQLCRUD.UpdateTask(id, what, when, who, status); MessageBox.Show("Task was updated.", "SUCCESS!"); } catch (Exception) { MessageBox.Show("Something went wrong. Your changes were not saved."); } }
public List(string listName, int boardId) { InitializeComponent(); taskPanel.BackColor = Color.FromArgb(rgb.Next(minValue, maxValue), rgb.Next(minValue, maxValue), rgb.Next(minValue, maxValue)); ListNameLabel.Text = listName; var tasks = LinqToSQLCRUD.ReadTasks(ListId); foreach (var task in tasks) { LinkLabel taskLink = new LinkLabel(); taskLink.Text = taskMarker + task.TaskName + "\n"; taskLink.Tag = task.TasktId; taskLink.Font = taskFont; taskLink.LinkColor = taskLinkColor; taskLink.ActiveLinkColor = taskActiveLinkColor; taskLink.Click += (mySender, myEventArgs) => ViewTask_Click(mySender, myEventArgs, (int)taskLink.Tag); taskPanel.Controls.Add(taskLink); } }
private void Refresh(int listId) { var tasks = LinqToSQLCRUD.ReadTasks(listId); taskPanel.Controls.Clear(); foreach (var task in tasks) { LinkLabel taskLink = new LinkLabel(); taskLink.Text = taskMarker + task.TaskName + "\n"; //task.TaskName; taskLink.Tag = task.TasktId; taskLink.Font = taskFont; taskLink.LinkColor = taskLinkColor; taskLink.ActiveLinkColor = taskActiveLinkColor; taskLink.Click += (mySender, myEventArgs) => ViewTask_Click(mySender, myEventArgs, (int)taskLink.Tag); taskPanel.Controls.Add(taskLink); } }
private void LoginButton_Click(object sender, EventArgs e) { if (UserNameTextBox.Text != "" && PasswordTextBox.Text != "") { loggedUserId = LinqToSQLCRUD.LoginUser(UserNameTextBox.Text, PasswordTextBox.Text); if (loggedUserId == 0) { MessageBox.Show("Invalid Credentials."); } else { MessageBox.Show("Login successful."); UserNameTextBox.Text = ""; PasswordTextBox.Text = ""; Home home = new Home(loggedUserId); home.Show(); } } else { MessageBox.Show("Enter UserName and Password."); } }