Пример #1
0
    private static Boolean IsMember(string TeamName, string Type)
    {
        Boolean blnReturn = false; // Intialize False

        //Get Current user
        Sage.SalesLogix.Security.SLXUserService usersvc     = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>();
        Sage.Entity.Interfaces.IUser            currentuser = usersvc.GetUser();
        // get the DataService to get a connection string to the database
        if (currentuser.Id.ToString() == "ADMIN       ")

        {
            blnReturn = true;
        }

        string SQL = "";

        SQL  = "select accessid from secrights where seccodeid = ";
        SQL += " (select seccodeid from seccode where (seccodedesc = '" + TeamName + "') ";
        SQL += " and (seccodetype = '" + Type + "')) and (accessid = '" + currentuser.Id.ToString() + "')";

        Sage.Platform.Data.IDataService datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Data.IDataService>();
        using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString()))
        {
            conn.Open();
            using (System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(SQL, conn))
            {
                OleDbDataReader reader = cmd.ExecuteReader();
                //loop through the reader
                while (reader.Read())
                {
                    if (reader["accessid"].ToString() != string.Empty)
                    {
                        blnReturn = true;
                    }
                }
                reader.Close();
            }
        }
        return(blnReturn);
    }
    public static T GetField <T>(string Field, string Table, string Where)
    {
        string sql = string.Format("select {0} from {1} where {2}", Field, Table, (Where.Equals(string.Empty) ? "1=1" : Where));

        //get the DataService to get a connection string to the database
        Sage.Platform.Data.IDataService datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Data.IDataService>();
        using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString()))
        {
            conn.Open();
            using (OleDbCommand cmd = new OleDbCommand(sql, conn))
            {
                object fieldval = cmd.ExecuteScalar();
                return(fieldval == DBNull.Value ? default(T) : (T)fieldval);
            }
        }
    }