Example #1
0
        }       //	loadDefault

        /// <summary>
        /// Validate Login.
        /// Creates session and calls ModelValidationEngine
        /// </summary>
        /// <param name="org">log-in org</param>
        /// <returns>error message</returns>
        public String ValidateLogin(KeyNamePair org)
        {
            String info         = m_user + ",R:" + m_role.ToString() + ",O=" + m_org.ToString();
            int    AD_Client_ID = m_ctx.GetAD_Client_ID();
            int    AD_Org_ID    = org.GetKey();
            int    AD_Role_ID   = m_ctx.GetAD_Role_ID();
            int    AD_User_ID   = m_ctx.GetAD_User_ID();
            //
            MSession session = MSession.Get(m_ctx, true);

            if (AD_Client_ID != session.GetAD_Client_ID())
            {
                session.SetAD_Client_ID(AD_Client_ID);
            }
            if (AD_Org_ID != session.GetAD_Org_ID())
            {
                session.SetAD_Org_ID(AD_Org_ID);
            }
            if (AD_Role_ID != session.GetAD_Role_ID())
            {
                session.SetAD_Role_ID(AD_Role_ID);
            }
            //
            String error = ModelValidationEngine.Get().LoginComplete(AD_Client_ID, AD_Org_ID, AD_Role_ID, AD_User_ID);

            if (error != null && error.Length > 0)
            {
                session.SetDescription(error);
                session.Save();
                return(error);
            }
            //	Log
            session.Save();
            return(null);
        }       //	validateLogin
Example #2
0
        /// <summary>
        /// Get the Print Formats for the table.
        /// Fill the list and the popup menu
        /// </summary>
        /// <param name="AD_Table_ID">table</param>
        private void GetPrintFormats(int AD_Table_ID, ToolStripDropDownButton sender)
        {
            ToolStripDropDownButton _popup = sender;

            int AD_Client_ID = Env.GetContext().GetAD_Client_ID();
            //
            String sql = MRole.GetDefault(Env.GetContext()).AddAccessSQL(
                "SELECT AD_PrintFormat_ID, Name, AD_Client_ID "
                + "FROM AD_PrintFormat "
                + "WHERE AD_Table_ID='" + AD_Table_ID + "' AND IsTableBased='Y' "
                + "ORDER BY AD_Client_ID DESC, IsDefault DESC, Name",                   //	Own First
                "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);

            KeyNamePair pp = null;

            IDataReader dr = DataBase.DB.ExecuteReader(sql);

            try
            {
                if (sender != null)
                {
                    _popup.DropDownItems.Clear();
                }
                while (dr.Read())
                {
                    if (Utility.Util.GetValueOfInt(dr[2].ToString()) == AD_Client_ID)
                    {
                        pp = new KeyNamePair(Utility.Util.GetValueOfInt(dr[0].ToString()), dr[1].ToString());
                        _list.Add(pp);
                        String            actionCommand = pp.ToString();
                        ToolStripMenuItem mi            = new System.Windows.Forms.ToolStripMenuItem();
                        mi.Text   = actionCommand;
                        mi.Click += new EventHandler(ReportFormat_Click);
                        if (sender != null)
                        {
                            _popup.DropDownItems.Add(mi);
                        }
                    }
                }
                dr.Close();
                dr = null;
            }
            catch
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }

            if (_list.Count == 0)
            {
                if (pp == null)
                {
                    CreateNewFormat(AD_Table_ID);               //	calls launch
                }
                else
                {
                    CopyFormat(pp.GetKey(), AD_Client_ID);
                }
            }
            //	One Format exists or no invoker - show it
            else if (_list.Count == 1 || sender == null)
            {
                if (sender != null)
                {
                    _popup.DropDownItems.Clear();
                }
                LaunchReport((KeyNamePair)_list[0]);
            }
            //	Multiple Formats exist - show selection
            else
            {
                _popup.ShowDropDown();
            }
        }