Beispiel #1
0
        /// <summary>
        /// Get menus with where clause
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="whereClause">whereClause where clause w/o the actual WHERE</param>
        /// <returns>MMenu</returns>
        public static MMenu[] Get(Ctx ctx, string whereClause)
        {
            string sql = "SELECT * FROM AD_Menu";

            if (whereClause != null && whereClause.Length > 0)
            {
                sql += " WHERE " + whereClause;
            }
            List <MMenu> list = new List <MMenu>();
            DataSet      ds   = null;

            try
            {
                ds = DataBase.DB.ExecuteDataset(sql, null, null);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    //list.Add(new MColumn(GetCtx(), dr, Get_TrxName()));
                    list.Add(new MMenu(ctx, dr, null));
                }
                ds = null;
            }
            catch (Exception e)
            {
                if (ds != null)
                {
                    ds = null;
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            MMenu[] retValue = new MMenu[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
        }       //	addStatistics

        /// <summary>
        ///   After Save
        /// </summary>
        /// <param name="newRecord">new</param>
        /// <param name="success">success</param>
        /// <returns>success</returns>
        protected override bool AfterSave(bool newRecord, bool success)
        {
            if (newRecord)      //	Add to all automatic roles
            {
                MRole[]        roles = MRole.GetOf(GetCtx(), "IsManual='N'");
                MProcessAccess pa;
                for (int i = 0; i < roles.Length; i++)
                {
                    pa = new MProcessAccess(this, roles[i].GetAD_Role_ID());
                    pa.Save();
                    pa = null;
                }
            }
            //	Menu/Workflow
            else if (Is_ValueChanged("IsActive") || Is_ValueChanged("Name") ||
                     Is_ValueChanged("Description") || Is_ValueChanged("Help"))
            {
                MMenu[] menues = MMenu.Get(GetCtx(), "AD_Process_ID=" + GetAD_Process_ID());
                for (int i = 0; i < menues.Length; i++)
                {
                    menues[i].SetIsActive(IsActive());
                    menues[i].SetName(GetName());
                    menues[i].SetDescription(GetDescription());
                    menues[i].Save();
                }
                X_AD_WF_Node[] nodes = MWindow.GetWFNodes(GetCtx(), "AD_Process_ID=" + GetAD_Process_ID());
                for (int i = 0; i < nodes.Length; i++)
                {
                    bool changed = false;
                    if (nodes[i].IsActive() != IsActive())
                    {
                        nodes[i].SetIsActive(IsActive());
                        changed = true;
                    }
                    if (nodes[i].IsCentrallyMaintained())
                    {
                        nodes[i].SetName(GetName());
                        nodes[i].SetDescription(GetDescription());
                        nodes[i].SetHelp(GetHelp());
                        changed = true;
                    }
                    if (changed)
                    {
                        nodes[i].Save();
                    }
                }
            }
            return(success);
        }