private void butDelete_Click(object sender, EventArgs e) { if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete?")) { return; } if (TaskNoteCur.IsNew) { DialogResult = DialogResult.Cancel; Close(); //Needed because the window is called as a non-modal window. return; } TaskNotes.Delete(TaskNoteCur.TaskNoteNum); DialogResult = DialogResult.OK; OnEditComplete(); Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Deleted note from task"), Tasks.GetOne(TaskNoteCur.TaskNum)); Close(); //Needed because the window is called as a non-modal window. }
private void butOK_Click(object sender, EventArgs e) { if (textNote.Text == "") { MsgBox.Show(this, "Please enter a note, or delete this entry."); return; } if (Tasks.IsTaskDeleted(TaskNoteCur.TaskNum)) //If this is for a new task we do have a valid TaskNum because of pre-insert { MsgBox.Show(this, "The task for this note was deleted."); return; //Don't allow user to create orphaned notes, or try to edit a tasknote that was probably deleted too. } //We need the old datetime to check if the user made any changes. We overrite TaskNoteCur's date time below so need to get it here. DateTime dateTimeNoteOld = TaskNoteCur.DateTimeNote; try { TaskNoteCur.DateTimeNote = DateTime.Parse(textDateTime.Text); } catch { MsgBox.Show(this, "Please fix date."); return; } if (TaskNoteCur.IsNew) { TaskNoteCur.Note = textNote.Text; TaskNotes.Insert(TaskNoteCur); Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Added task note"), Tasks.GetOne(TaskNoteCur.TaskNum)); DialogResult = DialogResult.OK; OnEditComplete(); } else if (TaskNoteCur.Note != textNote.Text || dateTimeNoteOld != TaskNoteCur.DateTimeNote) { TaskNoteCur.Note = textNote.Text; TaskNotes.Update(TaskNoteCur); Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Task note changed"), Tasks.GetOne(TaskNoteCur.TaskNum)); DialogResult = DialogResult.OK; OnEditComplete(); } else { //Intentionally blank, user opened an existing task note and did not change the note but clicked OK. //This is effectively equivilent to a Cancel click DialogResult = DialogResult.Cancel; } Close(); //Needed because the window is called as a non-modal window. }
private void FillGrid() { long selectedLinkNum = 0; if (gridMain.GetSelectedIndex() != -1) { selectedLinkNum = (long)gridMain.Rows[gridMain.GetSelectedIndex()].Tag; } gridMain.BeginUpdate(); gridMain.Columns.Clear(); gridMain.Rows.Clear(); ODGridColumn col = new ODGridColumn("Type", 70); gridMain.Columns.Add(col); col = new ODGridColumn("Description", 200); gridMain.Columns.Add(col); ODGridRow row; for (int i = 0; i < _jobLinks.Count; i++) { row = new ODGridRow(); row.Cells.Add(_jobLinks[i].LinkType.ToString()); if (_jobLinks[i].LinkType == JobLinkType.Task) { Task task = Tasks.GetOne(_jobLinks[i].FKey); if (task == null) //task was deleted { continue; } if (task.Descript.Length >= 80) { row.Cells.Add(task.Descript.Substring(0, 80) + "..."); } else { row.Cells.Add(task.Descript); } } else if (_jobLinks[i].LinkType == JobLinkType.Bug) { row.Cells.Add("Under Construction"); } else if (_jobLinks[i].LinkType == JobLinkType.Request) { row.Cells.Add("Feature Request #" + _jobLinks[i].FKey); } //else if(_jobLinks[i].LinkType==JobLinkType.Quote) { // JobQuote quote=JobQuotes.GetOne(_jobLinks[i].FKey); // string quoteText="Amount: "+quote.Amount; // if(quote.PatNum!=0) { // Patient pat=Patients.GetPat(quote.PatNum); // quoteText+="\r\nCustomer: "+pat.LName+", "+pat.FName; // } // if(quote.Note!="") { // quoteText+="\r\nNote: "+quote.Note; // } // row.Cells.Add(quoteText); //} row.Tag = _jobLinks[i].JobLinkNum; gridMain.Rows.Add(row); } gridMain.EndUpdate(); for (int i = 0; i < gridMain.Rows.Count; i++) { if ((long)gridMain.Rows[i].Tag == selectedLinkNum) { gridMain.SetSelected(i, true); } } }
private void butOK_Click(object sender, EventArgs e) { if (textNote.Text == "") { MsgBox.Show(this, "Please enter a note, or delete this entry."); return; } //We need the old datetime to check if the user made any changes. We overrite TaskNoteCur's date time below so need to get it here. DateTime dateTimeNoteOld = TaskNoteCur.DateTimeNote; try { TaskNoteCur.DateTimeNote = DateTime.Parse(textDateTime.Text); } catch { MsgBox.Show(this, "Please fix date."); return; } if (TaskNoteCur.IsNew) { TaskNoteCur.Note = textNote.Text; TaskNotes.Insert(TaskNoteCur); Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Added task note"), Tasks.GetOne(TaskNoteCur.TaskNum)); //This refreshes "new" status for the task as appropriate. DataValid.SetInvalidTask(TaskNoteCur.TaskNum, true); //popup DialogResult = DialogResult.OK; OnEditComplete(); } else if (TaskNoteCur.Note != textNote.Text || dateTimeNoteOld != TaskNoteCur.DateTimeNote) { //This refreshes "new" status for the task as appropriate. DataValid.SetInvalidTask(TaskNoteCur.TaskNum, true); //popup TaskNoteCur.Note = textNote.Text; TaskNotes.Update(TaskNoteCur); Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Task note changed"), Tasks.GetOne(TaskNoteCur.TaskNum)); DialogResult = DialogResult.OK; OnEditComplete(); } else { //Intentionally blank, user opened an existing task note and did not change the note but clicked OK. //This is effectively equivilent to a Cancel click DialogResult = DialogResult.Cancel; } Close(); //Needed because the window is called as a non-modal window. }
private void FillGrid() { gridTaskHist.BeginUpdate(); gridTaskHist.ListGridColumns.Clear(); GridColumn col = new GridColumn(Lan.g("TableTaskAudit", "Create Date"), 140); gridTaskHist.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableTaskAudit", "Edit Date"), 140); gridTaskHist.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableTaskAudit", "Editing User"), 80); gridTaskHist.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableTaskAudit", "Changes"), 100); gridTaskHist.ListGridColumns.Add(col); gridTaskHist.ListGridRows.Clear(); GridRow row; //Row describes difference between current row and the Next row. Last row will be the last TaskHist compared to the current Task. for (int i = 1; i < _listTaskAudit.Count; i++) { TaskHist taskHistCur = _listTaskAudit[i - 1]; TaskHist taskHistNext = _listTaskAudit[i]; row = new GridRow(); if (taskHistCur.DateTimeEntry == DateTime.MinValue) { row.Cells.Add(_listTaskAudit[i].DateTimeEntry.ToString()); } else { row.Cells.Add(taskHistCur.DateTimeEntry.ToString()); } row.Cells.Add(taskHistCur.DateTStamp.ToString()); long usernum = taskHistCur.UserNumHist; if (usernum == 0) { usernum = taskHistCur.UserNum; } row.Cells.Add(Userods.GetUser(usernum).UserName); row.Cells.Add(TaskHists.GetChangesDescription(taskHistCur, taskHistNext)); gridTaskHist.ListGridRows.Add(row); } //Compare the current task with the last hist entry (Add the "current revision" of the task if necessary.) if (_listTaskAudit.Count > 0) { TaskHist taskHistCur = _listTaskAudit[_listTaskAudit.Count - 1]; Task task = Tasks.GetOne(TaskNumCur); if (task != null) { TaskHist taskHistNext = new TaskHist(task); row = new GridRow(); if (taskHistCur.DateTimeEntry == DateTime.MinValue) { row.Cells.Add(taskHistNext.DateTimeEntry.ToString()); } else { row.Cells.Add(taskHistCur.DateTimeEntry.ToString()); } row.Cells.Add(taskHistCur.DateTStamp.ToString()); long usernum = taskHistCur.UserNumHist; if (usernum == 0) { usernum = taskHistCur.UserNum; } row.Cells.Add(Userods.GetUser(usernum).UserName); row.Cells.Add(TaskHists.GetChangesDescription(taskHistCur, taskHistNext)); gridTaskHist.ListGridRows.Add(row); } } gridTaskHist.EndUpdate(); }