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(); } }
private void dataGrid_content_CellContentClick(object sender, DataGridViewCellEventArgs e) { selectedId = JournalTask.ContentClickHandler(dataGrid_content, e); if (e.ColumnIndex == 1) { string command = "update monthlytasks " + "set " + "iscompleted = @iscompleted, " + "datecompleted = @completeddate " + "where id = @id"; List <int> ids = JournalTask.GetAllMonthlyTasksId(selectedId); for (int i = 0; i < ids.Count; i++) { SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int) { Value = ids[i] }, new SqlParameter("@iscompleted", SqlDbType.Bit) { Value = true }, new SqlParameter("@completeddate", SqlDbType.DateTime) { Value = DateTime.Now } }; db.GenericNonQueryAction(command, parameter); } OnMonthlyTaskSave(); } }
private void dataGrid_content_CellContentClick(object sender, DataGridViewCellEventArgs e) { selectedId = JournalTask.ContentClickHandler(dataGrid_content, e); string command = "select isvisible from habit where id = @id"; SqlParameter[] paramter = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int) { Value = selectedId } }; bool visibility = db.GenericQueryAction(command, paramter).AsEnumerable().ToList()[0].Field <bool>("isvisible"); command = "update habit " + "set " + "isvisible = @isvisible " + "where id = @id"; paramter = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int) { Value = selectedId }, new SqlParameter("@isvisible", SqlDbType.Bit) { Value = !visibility } }; db.GenericQueryAction(command, paramter); RefreshGrid(); }
private void dataGrid_tracker_CellContentClick(object sender, DataGridViewCellEventArgs e) { taskId = JournalTask.ContentClickHandler(dataGrid_tracker, e); // MessageBox.Show(dataGrid_tracker.Columns[e.ColumnIndex].HeaderText); string headerText = dataGrid_tracker.Columns[e.ColumnIndex].HeaderText; DateTime dateTime = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, int.Parse(headerText)); string command = "select iscompleted from tracker " + "where habitid = @id " + "and habitdate = @habitdate"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int) { Value = taskId }, new SqlParameter("@habitdate", SqlDbType.DateTime) { Value = dateTime } }; DataTable dataTable = db.GenericQueryAction(command, parameter); if (dataTable.Rows.Count > 0) { bool visibility = dataTable.AsEnumerable().ToList()[0].Field <bool>("iscompleted"); command = "update tracker " + "set " + "iscompleted = @iscompleted " + "where habitid = @id " + "and habitdate = @habitdate"; parameter = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int) { Value = taskId }, new SqlParameter("@habitdate", SqlDbType.DateTime) { Value = dateTime }, new SqlParameter("@iscompleted", SqlDbType.Bit) { Value = !visibility } }; db.GenericNonQueryAction(command, parameter); } else { command = "insert into tracker " + "(habitid, habitdate, iscompleted) " + "values" + "(@habitid, @habitdate, @iscompleted)"; parameter = new SqlParameter[] { new SqlParameter("@habitid", SqlDbType.Int) { Value = taskId }, new SqlParameter("@iscompleted", SqlDbType.Bit) { Value = true }, new SqlParameter("@habitdate", SqlDbType.Date) { Value = dateTime } }; db.GenericNonQueryAction(command, parameter); } CheckAllHabits(); }