Esempio n. 1
0
        private void dataGrid_content_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            selectedId = JournalTask.ContentClickHandler(dataGrid_content, e);
            string command = "";

            if (entryType == JournalTask.EntryType.daily)
            {
                command = "update currenttasks " +
                          "set " +
                          "iscompleted = @iscompleted, " +
                          "datecompleted = @completeddate " +
                          "where id = @id";
            }
            if (entryType == JournalTask.EntryType.monthly)
            {
                command = "update monthlytasks " +
                          "set " +
                          "iscompleted = @iscompleted, " +
                          "datecompleted = @completeddate " +
                          "where id = @id";
            }
            if (entryType == JournalTask.EntryType.future)
            {
                command = "update futuretasks " +
                          "set " +
                          "iscompleted = @iscompleted, " +
                          "datecompleted = @completeddate " +
                          "where id = @id";
            }


            if (e.ColumnIndex == 0)
            {
                foreach (int pickedId in JournalTask.GetAllPreviousLayerId(selectedId, entryType))
                {
                    SqlParameter[] parameter = new SqlParameter[]
                    {
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = pickedId
                        },
                        new SqlParameter("@iscompleted", SqlDbType.Bit)
                        {
                            Value = false
                        },
                        new SqlParameter("@completeddate", SqlDbType.DateTime)
                        {
                            Value = DBNull.Value
                        }
                    };

                    db.GenericNonQueryAction(command, parameter);
                }

                OnRefreshGrid();
            }
        }