private void CurrentTasksDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { int selectedRowIndex = CurrentTasksDataGrid.CurrentCell.RowIndex; if (selectedRowIndex >= 0) { GlobalVar.globalstring = "EditCurrentTask"; currenttasks ct = new currenttasks(); string client_name = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[1].Value.ToString(); ct.assignee = GlobalVar.app_user; ct.DateOfAssignment = Convert.ToDateTime(CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[0].Value.ToString()); ct.SubjectWithParty = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[2].Value.ToString(); ct.areaOfWork = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[3].Value.ToString(); ct.priority = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[4].Value.ToString(); ct.TaskDescription = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[5].Value.ToString(); ct.DocumentsSource = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[6].Value.ToString(); ct.assigner = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[7].Value.ToString(); ct.status = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[8].Value.ToString(); ct.remarks = CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[9].Value.ToString(); ct.ID = Convert.ToInt32(CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[10].Value); ct.ClientID = Convert.ToInt32(CurrentTasksDataGrid.Rows[selectedRowIndex].Cells[11].Value); ManageTasks mt = new ManageTasks(ct, client_name); mt.Show(); } }
/// <summary> /// method to update existing as well as new tasks. /// </summary> /// <param name="empID">employee id of user</param> public void updateTasks(currenttasks task) { OfficeDeskDB db = new OfficeDeskDB(); var CD = db; var CT = from currenttaskss in db.currenttaskss where currenttaskss.ID == task.ID select currenttaskss; if (CT.Count() != 0) { foreach (currenttasks ct in CT) { ct.DateOfAssignment = Convert.ToDateTime(task.DateOfAssignment); ct.SubjectWithParty = task.SubjectWithParty; ct.assignee = task.assignee; ct.priority = task.priority; ct.TaskDescription = task.TaskDescription; ct.DocumentsSource = task.TaskDescription; ct.assigner = task.assigner; ct.status = task.status; ct.remarks = task.remarks; ct.ClientID = task.ClientID; db.SaveChanges(); db.Dispose(); } } else { currenttasks ct = new currenttasks(); ct.DateOfAssignment = Convert.ToDateTime(task.DateOfAssignment); ct.ClientID = task.ClientID; ct.SubjectWithParty = task.SubjectWithParty; ct.empId = task.empId; ct.areaOfWork = task.areaOfWork; ct.priority = task.priority; ct.TaskDescription = task.TaskDescription; ct.DocumentsSource = task.DocumentsSource; ct.assignee = task.assignee; ct.assigner = task.assigner; ct.status = task.status; ct.remarks = task.remarks; db.currenttaskss.Add(ct); db.SaveChanges(); db.Dispose(); } }
public ManageTasks(currenttasks CT, string client) { InitializeComponent(); if (CT != null) { client_name.Hide(); task_assignee.Hide(); taskAssignee_textbox.Text = CT.assignee; assignment_date.Text = CT.DateOfAssignment.ToString(); clientname_textbox.Text = client; task_priority.Text = CT.priority; subject_with_party.Text = CT.SubjectWithParty; area_of_work.Text = CT.areaOfWork; task_description.Text = CT.TaskDescription; document_source.Text = CT.DocumentsSource; task_assigner.Text = CT.assigner; task_status.Text = CT.status; task_remarks.Text = CT.remarks; } }
private void btn_save_Click(object sender, EventArgs e) { updateCurrentTasks UCT = new updateCurrentTasks(); currenttasks ct = new currenttasks(); assignee_id.Visible = true; client_id.Visible = true; ct.ID = task_id; ct.empId = Convert.ToInt32(assignee_id.Text); ct.ClientID = Convert.ToInt32(client_id.Text); ct.DateOfAssignment = Convert.ToDateTime(assignment_date.Text); ct.assignee = task_assignee.Text; ct.priority = task_priority.Text; ct.areaOfWork = area_of_work.Text; ct.SubjectWithParty = subject_with_party.Text; ct.TaskDescription = task_description.Text; ct.DocumentsSource = document_source.Text; ct.assigner = task_assigner.Text; ct.status = task_status.Text; ct.remarks = task_remarks.Text; UCT.updateTasks(ct); assignee_id.Visible = false; client_id.Visible = false; }