protected void rptAction_ItemCommand(object source, RepeaterCommandEventArgs e) { List <TASK_STATUS> actionList = GetActionListFromGrid(); if (e.CommandArgument.ToString() == "ActionType") { Panel pnl = (Panel)e.Item.FindControl("pnlActionType"); if (pnl.Visible) { pnl.Visible = false; pnl = (Panel)e.Item.FindControl("pnlActionTypeSelect"); pnl.Visible = true; HiddenField hf = (HiddenField)e.Item.FindControl("hfActionType"); XLAT xlat = XLATList.Where(l => l.XLAT_GROUP == "ACTION_CATEGORY" && l.XLAT_CODE == hf.Value).FirstOrDefault(); if (xlat != null) { Label lb = (Label)e.Item.FindControl("lblActionType"); lb.Text = xlat.DESCRIPTION; } } else { pnl.Visible = true; pnl = (Panel)e.Item.FindControl("pnlActionTypeSelect"); pnl.Visible = false; } } if (e.CommandArgument.ToString() == "Delete") { int delId = e.Item.ItemIndex; TASK_STATUS action = actionList.ElementAt(delId); if (action != null) { if (action.TASK_ID > 0) // only delete existing actions { using (PSsqmEntities entities = new PSsqmEntities()) { entities.ExecuteStoreCommand("DELETE FROM TASK_STATUS WHERE TASK_ID = " + action.TASK_ID.ToString()); } } actionList.Remove(action); if (actionList.Count == 0) { actionList.Add(EHSIncidentMgr.CreateEmptyTask(ActionIncident.INCIDENT_ID, ((int)SysPriv.action).ToString(), 1, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ))); } } rptAction.DataSource = actionList; rptAction.DataBind(); decimal incidentId = (IsEditContext) ? IncidentId : NewIncidentId; } }
protected void AddDelete_Click(object sender, EventArgs e) { Button btn = (Button)sender; if (btn.CommandArgument == "AddAnother") { List <TASK_STATUS> actionList = GetActionListFromGrid(); int newSeq = actionList.Max(l => l.TASK_SEQ).Value + 1; actionList.Add(EHSIncidentMgr.CreateEmptyTask(ActionIncident.INCIDENT_ID, ((int)SysPriv.action).ToString(), newSeq, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ))); rptAction.DataSource = actionList; rptAction.DataBind(); } }
protected List <TASK_STATUS> UpdateAlertTaskList(List <TASK_STATUS> alertTaskList) { // create task for each location and/or update existing task TASK_STATUS task = null; int taskSeq = 0; bool isNew = false; RadComboBox ddl = null; HiddenField hf = null; foreach (GridDataItem item in rgAlertTaskList.Items) { hf = (HiddenField)item.FindControl("hfTaskID"); ddl = (RadComboBox)item.FindControl("ddlResponsible"); if (string.IsNullOrEmpty(hf.Value)) // create new { isNew = true; task = new TASK_STATUS(); hf = (HiddenField)item.FindControl("hfLocationTZ"); task = EHSIncidentMgr.CreateEmptyTask(LocalIncident.INCIDENT_ID, ((int)SysPriv.notify).ToString(), ++taskSeq, WebSiteCommon.LocalTime(DateTime.UtcNow, hf.Value)); task.RECORD_TYPE = (int)TaskRecordType.HealthSafetyIncident; hf = (HiddenField)item.FindControl("hfLocation"); task.RECORD_SUBID = Convert.ToDecimal(hf.Value); task.RECORD_ID = LocalIncident.INCIDENT_ID; alertTaskList.Add(task); localCtx.AddToTASK_STATUS(task); } else { isNew = false; task = alertTaskList.Where(l => l.TASK_ID.ToString() == hf.Value).FirstOrDefault(); // existing } // task.DESCRIPTION = tbAlertDesc.Text; task.DETAIL = tbComments.Text; task.DUE_DT = rdpDueDate.SelectedDate; if (!string.IsNullOrEmpty(ddl.SelectedValue)) { task.RESPONSIBLE_ID = Convert.ToDecimal(ddl.SelectedValue); } else { alertTaskList.Remove(task); localCtx.DeleteObject(task); } } return(alertTaskList); }