예제 #1
0
        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();
            }
        }
예제 #3
0
        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.");
            }
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
 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);
            }
        }
예제 #7
0
 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);
     }
 }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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.");
            }

        }
예제 #11
0
        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();
                }
            }
        }
예제 #12
0
        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.");
            }
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        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.");
            }
        }