Ejemplo n.º 1
0
        private void Save_Click(object sender, EventArgs e)
        {
            String data = "";

            for (int rows = 0; rows < this.toDo.DataGridView.Rows.Count - 1; rows++)
            {
                data += $"{this.userName},";
                for (int col = 0; col < this.toDo.DataGridView.Rows[rows].Cells.Count - 1; col++)
                {
                    if (this.toDo.DataGridView.Rows[rows].Cells[col].Value != null)
                    {
                        data += this.toDo.DataGridView.Rows[rows].Cells[col].Value.ToString() + ",";
                    }
                }
                if (this.toDo.DataGridView.Rows[rows].Cells[this.toDo.DataGridView.Rows[rows].Cells.Count - 1].Value != null)
                {
                    data += this.toDo.DataGridView.Rows[rows].Cells[this.toDo.DataGridView.Rows[rows].Cells.Count - 1].Value.ToString() + "\n";
                }
                else
                {
                    data += "False\n";
                }
            }

            toDoList myList = new toDoList();

            myList.exportAppend("toDoList.txt", data);
            MessageBox.Show("Saved!");
            this.Hide();
        }
Ejemplo n.º 2
0
        private void loadToDoForm(String userName)
        {
            var myForm = new toDoListForm(this.textBoxUserName.Text);

            myForm.Show();
            toDoList myList = new toDoList();

            myList.import("toDoList.txt");
            String newData = "";

            for (int i = 0; i < myList.toDo.Count; i++)
            {
                if (myList.userName[i] == userName)
                {
                    myForm.toDo.DataGridView.Rows.Add(myList.toDo[i], myList.checkBox[i]);
                }
                else
                {
                    newData += $"{myList.userName[i]},{myList.toDo[i]},{myList.checkBox[i]}\n";
                }
            }
            myList.exportOverwrite("toDoList.txt", newData);
        }