Exemple #1
0
 /// <summary>
 /// After Save
 /// </summary>
 /// <param name="newRecord">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'");
         for (int i = 0; i < roles.Length; i++)
         {
             MWindowAccess wa = new MWindowAccess(this, roles[i].GetAD_Role_ID());
             wa.Save();
         }
     }
     //	Menu/Workflow
     else if (Is_ValueChanged("IsActive") || Is_ValueChanged("Name") ||
              Is_ValueChanged("Description") || Is_ValueChanged("Help"))
     {
         MMenu[] menues = MMenu.Get(GetCtx(), "AD_Window_ID=" + GetAD_Window_ID());
         for (int i = 0; i < menues.Length; i++)
         {
             menues[i].SetName(GetName());
             menues[i].SetDescription(GetDescription());
             menues[i].SetIsActive(IsActive());
             menues[i].Save();
         }
         //
         X_AD_WF_Node[] nodes = GetWFNodes(GetCtx(), "AD_Window_ID=" + GetAD_Window_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);
 }
        private void InsertNewRecordInRole()
        {
            DataSet ds = DB.ExecuteDataset("SELECT AD_Role_ID FROM AD_Role_Group WHERE ad_groupinfo_id=" + GetAD_GroupInfo_ID());

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    MWindowAccess access = new MWindowAccess(GetCtx(), 0, null);
                    access.SetAD_Window_ID(GetAD_Window_ID());
                    access.SetAD_Role_ID(Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Role_ID"]));
                    access.SetIsReadWrite(true);
                    access.Save();
                }
            }
        }