private void gridGraph_CellClick(object sender, ODGridClickEventArgs e) { //only allow clicking on the 'Desired Graph Status' column if (e.Col != 3 || gridGraph.Rows[e.Row].Tag == null || !(gridGraph.Rows[e.Row].Tag is PhoneEmpDefault)) { return; } PhoneEmpDefault phoneEmpDefault = (PhoneEmpDefault)gridGraph.Rows[e.Row].Tag; bool uiGraphStatus = gridGraph.Rows[e.Row].Cells[e.Col].Text.ToLower() == "x"; bool dbGraphStatus = PhoneEmpDefaults.GetGraphedStatusForEmployeeDate(phoneEmpDefault.EmployeeNum, DateEdit); if (uiGraphStatus != dbGraphStatus) { MessageBox.Show(Lan.g(this, "Graph status has changed unexpectedly for employee: ") + phoneEmpDefault.EmpName + Lan.g(this, ". Exit and reopen this form, and try again.")); return; } //flip the bit in the db and reload the grid PhoneGraph pg = new PhoneGraph(); pg.EmployeeNum = phoneEmpDefault.EmployeeNum; pg.DateEntry = DateEdit; pg.IsGraphed = !uiGraphStatus; //flip the bit PhoneGraphs.InsertOrUpdate(pg); //update the db FillGrid(); }