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
            {
            }
        }
예제 #2
0
        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;
                        }
                    }
                }
            }
        }