protected void rgNotifyAction_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { try { GridDataItem item = (GridDataItem)e.Item; NOTIFYACTION notifyAction = (NOTIFYACTION)e.Item.DataItem; Label lbl; HiddenField hf = (HiddenField)item.FindControl("hfNotifyItemID"); hf.Value = notifyAction.NOTIFYACTION_ID.ToString(); LinkButton lnk = (LinkButton)item.FindControl("lnkNotifyItem"); lnk.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE" && x.XLAT_CODE == notifyAction.NOTIFY_SCOPE).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblScopeTask"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == notifyAction.SCOPE_TASK).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblScopeStatus"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TASK_STATUS" && x.XLAT_CODE == notifyAction.TASK_STATUS).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblNotifyTiming"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TIMING" && x.XLAT_CODE == notifyAction.NOTIFY_TIMING.ToString()).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblNotifyDist"); lbl.Text = notifyAction.NOTIFY_DIST; } catch { } } }
protected void lnklNotifyItem_Click(object sender, EventArgs e) { LinkButton lnk = (LinkButton)sender; try { NOTIFYACTION notifyAction = SQMModelMgr.LookupNotifyAction(new PSsqmEntities(), Convert.ToDecimal(lnk.CommandArgument)); if (notifyAction != null) { hfNotifyActionID.Value = notifyAction.NOTIFYACTION_ID.ToString(); if (ddlNotifyScope.FindItemByValue(notifyAction.NOTIFY_SCOPE) != null) { ddlNotifyScope.SelectedValue = notifyAction.NOTIFY_SCOPE; } if (ddlScopeTask.FindItemByValue(notifyAction.SCOPE_TASK) != null) { ddlScopeTask.SelectedValue = notifyAction.SCOPE_TASK; } if (ddlScopeStatus.FindItemByValue(notifyAction.TASK_STATUS) != null) { ddlScopeStatus.SelectedValue = notifyAction.TASK_STATUS; } if (ddlScopeTiming.FindItemByValue(notifyAction.NOTIFY_TIMING.ToString()) != null) { ddlScopeTiming.SelectedValue = notifyAction.NOTIFY_TIMING.ToString(); } ddlNotifyPrivGroup.ClearCheckedItems(); RadComboBoxItem ri = null; foreach (string sv in notifyAction.NOTIFY_DIST.Split(',')) { if (!string.IsNullOrEmpty(sv) && (ri = ddlNotifyPrivGroup.FindItemByValue(sv)) != null) { ri.Checked = true; } } btnDelete.Visible = true; ddlEdit_OnIndexChanged(null, null); } string script = "function f(){OpenNotifyEditWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); } catch { } }
void InitializeForm(PSsqmEntities ctx) { lblStatusMsg.Visible = false; pnlAlert.Visible = true; //pnlBaseForm2.Visible = true; localCtx = ctx; LocalIncident = EHSIncidentMgr.SelectIncidentById(localCtx, IncidentId); //populate form when LocalIncident is not null //if (LocalIncident == null) //{ // return; //} if (LocalIncident != null) { GetAttachments(IncidentId); //To get Privilege information and if Privilege is CEO-Group then CEO-Comments section is editable. string PrivInfo = SessionManager.UserContext.Person.PRIV_GROUP.ToString(); if (PrivInfo == "CEO-GROUP") { tbCeoComments.ReadOnly = false; } INCFORM_ALERT incidentAlert = EHSIncidentMgr.LookupIncidentAlert(localCtx, IncidentId); SQMBasePage.SetLocationList(ddlLocations, SQMModelMgr.SelectBusinessLocationList(1m, 0, true), 0); ddlNotifyGroup.DataSource = SQMModelMgr.SelectPrivGroupList("A", true); ddlNotifyGroup.DataValueField = "PRIV_GROUP"; ddlNotifyGroup.DataTextField = "DESCRIPTION"; ddlNotifyGroup.DataBind(); ddlResponsibleGroup.DataSource = SQMModelMgr.SelectPrivGroupList("A", true); ddlResponsibleGroup.DataValueField = "PRIV_GROUP"; ddlResponsibleGroup.DataTextField = "DESCRIPTION"; ddlResponsibleGroup.DataBind(); rdpDueDate = SQMBasePage.SetRadDateCulture(rdpDueDate, ""); rdpDueDate.SelectedDate = DateTime.UtcNow.AddDays(1); List <NOTIFYACTION> notifyList = SQMModelMgr.SelectNotifyActionList(localCtx, null, null); NOTIFYACTION dfltNotify = notifyList.Where(l => l.NOTIFY_SCOPE == "IN-0" && l.SCOPE_TASK == "400").FirstOrDefault(); // get default alert notification groups btnSave.Enabled = false; pnlAlert.Enabled = btnSave.Visible = EHSIncidentMgr.CanUpdateIncident(LocalIncident, true, SysPriv.admin, LocalIncident.INCFORM_LAST_STEP_COMPLETED); if (incidentAlert == null) { if (dfltNotify != null) { ddlNotifyGroup.Items.Where(i => dfltNotify.NOTIFY_DIST.Split(',').Contains(i.Value)).ToList().ForEach(i => i.Checked = true); } lblAlertStatus.Text = ""; } else { ddlLocations.Items.Where(i => incidentAlert.LOCATION_LIST.Split(',').Contains(i.Value)).ToList().ForEach(i => i.Checked = true); // tbAlertDesc.Text = incidentAlert.ALERT_DESC; tbComments.Text = incidentAlert.COMMENTS; // Get CEO-comments value from database and display it. tbCeoComments.Text = incidentAlert.CEO_COMMENTS; ddlNotifyGroup.Items.Where(i => incidentAlert.ALERT_GROUP.Split(',').Contains(i.Value)).ToList().ForEach(i => i.Checked = true); if ((ddlResponsibleGroup.FindItemByValue(incidentAlert.RESPONSIBLE_GROUP)) != null) { ddlResponsibleGroup.SelectedValue = incidentAlert.RESPONSIBLE_GROUP; } rdpDueDate.SelectedDate = incidentAlert.DUE_DT; lblAlertStatus.Text = XLATList.Where(l => l.XLAT_GROUP == "TASK_STATUS" && l.XLAT_CODE == "0").FirstOrDefault().DESCRIPTION; } lblNotifyGroup.Text = ""; //Apply condotional code to desplay data in grid of Process Description if (LocalIncident.INCFORM_INJURYILLNESS != null) { if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.BUSINESS_TYPE)) { BusinessType.Style.Add("display", "none"); } else { lblBusinessTypeVal.Text = XLATList.Where(p => p.XLAT_CODE == LocalIncident.INCFORM_INJURYILLNESS.BUSINESS_TYPE).Select(p => p.DESCRIPTION_SHORT).FirstOrDefault(); // display: block; // BusinessType.Style.Add("display", "block"); } } else { BusinessType.Style.Add("display", "none"); } if (LocalIncident.INCFORM_INJURYILLNESS != null) { if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.MACRO_PROCESS_TYPE)) { MacroProcessType.Style.Add("display", "none"); } else { lblMacroProcessTypeVal.Text = XLATList.Where(p => p.XLAT_CODE == LocalIncident.INCFORM_INJURYILLNESS.MACRO_PROCESS_TYPE).Select(p => p.DESCRIPTION_SHORT).FirstOrDefault(); // MacroProcessType.Style.Add("display", "block"); } } else { MacroProcessType.Style.Add("display", "none"); } if (LocalIncident.INCFORM_INJURYILLNESS != null) { if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.SPECIFIC_PROCESS_TYPE)) { SpecificProcessType.Style.Add("display", "none"); } else { lblSpecificProcessTypeVal.Text = XLATList.Where(p => p.XLAT_CODE == LocalIncident.INCFORM_INJURYILLNESS.SPECIFIC_PROCESS_TYPE).Select(p => p.DESCRIPTION_SHORT).FirstOrDefault(); //SpecificProcessType.Style.Add("display", "block"); } } else { SpecificProcessType.Style.Add("display", "none"); } if (LocalIncident.INCFORM_INJURYILLNESS != null) { if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.EQUIPMENT_MANUFACTURER_NAME)) { EquipmentManufacturerName.Style.Add("display", "none"); } else { lblEquipmentManufacturerNameVal.Text = LocalIncident.INCFORM_INJURYILLNESS.EQUIPMENT_MANUFACTURER_NAME; // EquipmentManufacturerName.Style.Add("display", "block"); } } else { EquipmentManufacturerName.Style.Add("display", "none"); } foreach (RadComboBoxItem item in ddlNotifyGroup.Items.Where(i => i.Checked == true).ToList()) { lblNotifyGroup.Text += string.IsNullOrEmpty(lblNotifyGroup.Text) ? item.Text : (", " + item.Text); } if (BindTAlertaskList(EHSIncidentMgr.GetAlertTaskList(localCtx, LocalIncident.INCIDENT_ID)) > 0) { btnSave.Enabled = true; } } else { btnSave.Visible = false; pnlAlert.Visible = false; } }
private void SaveNotifyItem() { PSsqmEntities ctx = new PSsqmEntities(); NOTIFYACTION notifyAction = null; bool isNew = false; if (string.IsNullOrEmpty(hfNotifyActionID.Value)) // add new item { notifyAction = new NOTIFYACTION(); if (hfNotifyActionContext.Value == "plant") // plant level { notifyAction.PLANT_ID = Convert.ToDecimal(hfNotifyActionBusLoc.Value); } else { // plant level notifyAction.BUS_ORG_ID = Convert.ToDecimal(hfNotifyActionBusLoc.Value); } isNew = true; } else { notifyAction = SQMModelMgr.LookupNotifyAction(ctx, Convert.ToDecimal(hfNotifyActionID.Value)); } notifyAction.NOTIFY_SCOPE = ddlNotifyScope.SelectedValue; notifyAction.SCOPE_TASK = ddlScopeTask.SelectedValue; notifyAction.TASK_STATUS = ddlScopeStatus.SelectedValue; notifyAction.NOTIFY_TIMING = Convert.ToInt32(ddlScopeTiming.SelectedValue); notifyAction.NOTIFY_DIST = ""; foreach (string sv in SQMBasePage.GetComboBoxSelectedValues(ddlNotifyPrivGroup)) { notifyAction.NOTIFY_DIST += (string.IsNullOrEmpty(notifyAction.NOTIFY_DIST) ? "" : ",") + sv; } if ((notifyAction = SQMModelMgr.UpdateNotifyAction(ctx, notifyAction)) != null) { if (isNew) { if (OnNotifyActionCommand != null) { OnNotifyActionCommand("add"); } } else { foreach (GridDataItem item in rgNotifyAction.Items) { LinkButton lnk = (LinkButton)item.FindControl("lnkNotifyItem"); if (lnk.CommandArgument == hfNotifyActionID.Value) { lnk.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE" && x.XLAT_CODE == notifyAction.NOTIFY_SCOPE).FirstOrDefault().DESCRIPTION_SHORT; Label lbl = (Label)item.FindControl("lblScopeTask"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == notifyAction.SCOPE_TASK).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblScopeStatus"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TASK_STATUS" && x.XLAT_CODE == notifyAction.TASK_STATUS).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblNotifyTiming"); lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TIMING" && x.XLAT_CODE == notifyAction.NOTIFY_TIMING.ToString()).FirstOrDefault().DESCRIPTION_SHORT; lbl = (Label)item.FindControl("lblNotifyDist"); lbl.Text = notifyAction.NOTIFY_DIST; } } } } }